[LON-CAPA-cvs] cvs: loncom /interface loncoursedata.pm /interface/statistics loncorrectproblemplot.pm

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 07 Mar 2005 20:12:08 -0000


This is a MIME encoded message

--matthew1110226328
Content-Type: text/plain

matthew		Mon Mar  7 15:12:08 2005 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
    /loncom/interface/statistics	loncorrectproblemplot.pm 
  Log:
  Bug 3529: correct problems plot now shows scores instead of parts correct.
  
  
--matthew1110226328
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20050307151208.txt"

Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.144 loncom/interface/loncoursedata.pm:1.145
--- loncom/interface/loncoursedata.pm:1.144	Thu Mar  3 13:57:36 2005
+++ loncom/interface/loncoursedata.pm	Mon Mar  7 15:12:08 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.144 2005/03/03 18:57:36 matthew Exp $
+# $Id: loncoursedata.pm,v 1.145 2005/03/07 20:12:08 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2526,12 +2526,15 @@
 ################################################
 ################################################
 sub get_student_scores {
-    my ($Sections,$Symbs,$enrollment,$courseid,$starttime,$endtime) = @_;
+    my ($sections,$Symbs,$enrollment,$courseid,$starttime,$endtime) = @_;
     $courseid = $ENV{'request.course.id'} if (! defined($courseid));
     &setup_table_names($courseid);
     my $dbh = &Apache::lonmysql::get_dbh();
     return (undef) if (! defined($dbh));
     my $tmptable = $courseid.'_temp_'.time;
+    my $request = 'DROP TABLE IF EXISTS '.$tmptable;
+#    &Apache::lonnet::logthis('request = '.$/.$request);
+    $dbh->do($request);
     #
     my $symb_requirements;
     if (defined($Symbs)  && @$Symbs) {
@@ -2542,34 +2545,17 @@
                               } @$Symbs).')';
     }
     #
-    my $student_requirements;
-    if ( (defined($Sections) && $Sections->[0] ne 'all')) {
-        $student_requirements = '('.
-            join(' OR ', map { "b.section='".$_."'" } @$Sections
-                 ).')';
-    }
-    #
-    my $enrollment_requirements=undef;
-    if (defined($enrollment) && $enrollment ne 'Any') {
-        $enrollment_requirements = "b.status='".$enrollment."'";
-    }
+    my ($student_requirements,$enrollment_requirements) = 
+        &limit_by_section_and_status($sections,$enrollment,'b');
     #
-    my $time_requirements = undef;
-    if (defined($starttime)) {
-        $time_requirements .= "a.timestamp>='".$starttime."'";
-        if (defined($endtime)) {
-            $time_requirements .= " AND a.timestamp<='".$endtime."'";
-        }
-    } elsif (defined($endtime)) {
-        $time_requirements .= "a.timestamp<='".$endtime."'";
-    }
-    ##
+    my $time_requirements = &limit_by_start_end_time($starttime,$endtime,'a');
     ##
-    my $request = 'CREATE TEMPORARY TABLE IF NOT EXISTS '.$tmptable.
-        ' SELECT a.student_id,SUM(a.awarded) AS score FROM '.
+    $request = 'CREATE TEMPORARY TABLE IF NOT EXISTS '.$tmptable.
+        ' SELECT a.student_id,SUM(a.awarded*c.weight) AS score FROM '.
         $performance_table.' AS a ';
+    $request .= "LEFT JOIN ".$weight_table.' AS c ON a.symb_id=c.symb_id AND a.part_id=c.part_id ';
     if (defined($student_requirements) || defined($enrollment_requirements)) {
-        $request .= ' NATURAL LEFT JOIN '.$student_table.' AS b ';
+        $request .= ' LEFT JOIN '.$student_table.' AS b ON a.student_id=b.student_id';
     }
     if (defined($symb_requirements)      || 
         defined($student_requirements)   ||
Index: loncom/interface/statistics/loncorrectproblemplot.pm
diff -u loncom/interface/statistics/loncorrectproblemplot.pm:1.15 loncom/interface/statistics/loncorrectproblemplot.pm:1.16
--- loncom/interface/statistics/loncorrectproblemplot.pm:1.15	Tue Mar  1 17:25:59 2005
+++ loncom/interface/statistics/loncorrectproblemplot.pm	Mon Mar  7 15:12:08 2005
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncorrectproblemplot.pm,v 1.15 2005/03/01 22:25:59 matthew Exp $
+# $Id: loncorrectproblemplot.pm,v 1.16 2005/03/07 20:12:08 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -92,7 +92,7 @@
     # Determine which problem symbs we are to sum over
     if (exists($ENV{'form.CreatePlot'})) {
         my @ProblemSymbs;
-        my $total_parts = 0;
+        my $total_weights = 0;
         my $title = '';
         my @maps = &Apache::lonstatistics::get_selected_maps('Maps');
         my ($navmap,@sequences) =
@@ -104,23 +104,21 @@
                 } else {
                     $title = 'Multiple Sequences';
                 }
-                my @resources = 
-                    &Apache::lonstathelpers::get_resources($navmap,$seq);
-                foreach my $res (@resources) {
-                    foreach my $partid (@{$res->parts}) {
-                        $total_parts++;
-                        push(@ProblemSymbs,{symb=>$res->symb,
-                                            part=>$partid});
-                    }
-                }
             }
         } else {
-            $title = "All Problems";
-            foreach my $seq (@sequences) {
-                my @resources = 
-                    &Apache::lonstathelpers::get_resources($navmap,$seq);
-                foreach my $res (@resources) {
-                    $total_parts += scalar(@{$res->parts});
+            $title = 'All Problems';
+        }
+        foreach my $seq (@sequences) {
+            my @resources = 
+                &Apache::lonstathelpers::get_resources($navmap,$seq);
+            foreach my $res (@resources) {
+                foreach my $partid (@{$res->parts}) {
+                    push(@ProblemSymbs,{symb=>$res->symb,
+                                        part=>$partid});
+                    $total_weights += 
+                        &Apache::lonnet::EXT('resource.'.$partid.'.weight',
+                                             $res->symb,
+                                             undef,undef,undef);
                 }
             }
         }
@@ -131,12 +129,13 @@
                           &Apache::lonlocal::locallocaltime($starttime),
                           &Apache::lonlocal::locallocaltime($endtime)));
         }
+        &Apache::loncoursedata::populate_weight_table();
         my $score_data = &Apache::loncoursedata::get_student_scores
             (\@Apache::lonstatistics::SelectedSections,
              \@ProblemSymbs,
              $Apache::lonstatistics::enrollment_status,undef,
              $starttime,$endtime);
-        $r->print(&AnalyzeScoreData($score_data,$title,$total_parts));
+        $r->print(&AnalyzeScoreData($score_data,$title,$total_weights));
     } else {
         $r->print('<h3>'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'</h3>');
     }
@@ -158,7 +157,7 @@
 #########################################################
 #########################################################
 sub AnalyzeScoreData {
-    my ($score_data,$title,$total_parts) = @_;
+    my ($score_data,$title,$maximum) = @_;
     #
     # Basic check first
     if (ref($score_data) ne 'ARRAY' || @$score_data < 1) {
@@ -181,6 +180,9 @@
     my @Bins = &bin_data($score_data,$binsize,$lowest,$highest);
     my @Xdata; my @Ydata; my $max;
     my $Str = 
+        '<p>'.
+        &mt('Problem weights do not reflect individual student settings.')
+        .'</p>'.
         '<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n";
     my $sum = 0;
     while (my $bin = shift(@Bins)) {
@@ -197,14 +199,13 @@
     $max = 5*(int($max/5)+1);
     $Str .= "</table><br />\n";
     $title = &HTML::Entities::decode($title);
-    $Str = "\n<p>".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum,
-                                 'Correct Problems (max possible = '.$total_parts.')',
-                                                       'Number of students',
-                                                       $max,
-                                                       undef, # colors
-                                                       \@Xdata,
-                                                       \@Ydata).
-                                                           "\n<br />\n".$Str;
+    $Str = "\n<p>".
+        &Apache::loncommon::DrawBarGraph($title.' ('.$sum.' students)',
+                              'Correct Problems (max possible = '.$maximum.')',
+                                         'Number of students',
+                                         $max,undef, # colors
+                                         \@Xdata,\@Ydata).
+                                         "\n<br />\n".$Str;
     $Str .= '</p>'."\n";
     return $Str;                                               
 }

--matthew1110226328--