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

matthew lon-capa-cvs@mail.lon-capa.org
Tue, 03 Feb 2004 20:44:07 -0000


matthew		Tue Feb  3 15:44:07 2004 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
    /loncom/interface/statistics	lonproblemstatistics.pm 
  Log:
  Further changes reflecting new MySQL table structure.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.114 loncom/interface/loncoursedata.pm:1.115
--- loncom/interface/loncoursedata.pm:1.114	Mon Feb  2 16:45:12 2004
+++ loncom/interface/loncoursedata.pm	Tue Feb  3 15:44:06 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.114 2004/02/02 21:45:12 matthew Exp $
+# $Id: loncoursedata.pm,v 1.115 2004/02/03 20:44:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1919,7 +1919,7 @@
 ################################################
 ################################################
 sub get_problem_statistics {
-    my ($students,$symb,$part,$courseid) = @_;
+    my ($Sections,$status,$symb,$part,$courseid) = @_;
     return if (! defined($symb) || ! defined($part));
     $courseid = $ENV{'request.course.id'} if (! defined($courseid));
     #
@@ -1933,18 +1933,22 @@
     #
     $dbh->do('DROP TABLE '.$stats_table);  # May return an error
     my $request = 
-        'CREATE TEMPORARY TABLE '.$stats_table.
-            ' SELECT student_id,solved,award,awarded,tries FROM '.$performance_table.
-                ' WHERE symb_id='.$symb_id.' AND part_id='.$part_id;
-    if (defined($students)) {
+        'CREATE TEMPORARY TABLE '.$stats_table.' '.
+        'SELECT a.student_id,a.solved,a.award,a.awarded,a.tries '.
+        'FROM '.$performance_table.' AS a ';
+    if ((defined($Sections) && lc($Sections->[0]) ne 'all') || 
+        (defined($status)   && lc($status)        ne 'any')) {
+        $request .= 'NATURAL LEFT JOIN '.$student_table.' AS b ';
+    }
+    $request .= ' WHERE a.symb_id='.$symb_id.' AND a.part_id='.$part_id;
+    if (defined($Sections) && lc($Sections->[0]) ne 'all') {
         $request .= ' AND ('.
-            join(' OR ', map {'student_id='.
-                                  &get_student_id($_->{'username'},
-                                                  $_->{'domain'})
-                                  } @$students
+            join(' OR ', map { "b.section='".$_."'" } @$Sections
                  ).')';
     }
-#    &Apache::lonnet::logthis($request);
+    if (defined($status) && lc($status) ne 'any') {
+        $request .= " AND b.status='".$status."'";
+    }
     $dbh->do($request);
 #    &Apache::lonnet::logthis('request = '.$/.$request);
     $request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '.
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.65 loncom/interface/statistics/lonproblemstatistics.pm:1.66
--- loncom/interface/statistics/lonproblemstatistics.pm:1.65	Mon Feb  2 14:32:11 2004
+++ loncom/interface/statistics/lonproblemstatistics.pm	Tue Feb  3 15:44:06 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonproblemstatistics.pm,v 1.65 2004/02/02 19:32:11 matthew Exp $
+# $Id: lonproblemstatistics.pm,v 1.66 2004/02/03 20:44:06 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -789,12 +789,10 @@
     my $symb = $resource->{'symb'};
     my $courseid = $ENV{'request.course.id'};
     #
-    my $students = \@Apache::lonstatistics::Students;
-    if ($Apache::lonstatistics::SelectedSections[0] eq 'all') {
-        $students = undef;
-    }
     my $data = &Apache::loncoursedata::get_problem_statistics
-                        ($students,$symb,$part,$courseid);
+                        (\@Apache::lonstatistics::SelectedSections,
+                         $Apache::lonstatistics::enrollment_status,
+                         $symb,$part,$courseid);
     $data->{'part'}        = $part;
     $data->{'problem_num'} = $problem_num;
     $data->{'container'}   = $sequence->{'title'};