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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 08 Mar 2004 16:12:36 -0000


matthew		Mon Mar  8 11:12:36 2004 EDT

  Modified files:              
    /loncom/interface	loncoursedata.pm 
  Log:
  Added comments to &get_problem_statistics.
  
  
Index: loncom/interface/loncoursedata.pm
diff -u loncom/interface/loncoursedata.pm:1.122 loncom/interface/loncoursedata.pm:1.123
--- loncom/interface/loncoursedata.pm:1.122	Sun Mar  7 16:42:19 2004
+++ loncom/interface/loncoursedata.pm	Mon Mar  8 11:12:35 2004
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: loncoursedata.pm,v 1.122 2004/03/07 21:42:19 matthew Exp $
+# $Id: loncoursedata.pm,v 1.123 2004/03/08 16:12:35 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1930,16 +1930,21 @@
     my $dbh = &Apache::lonmysql::get_dbh();
     return undef if (! defined($dbh));
     #
+    # Clean out the table
     $dbh->do('DROP TABLE '.$stats_table);  # May return an error
     my $request = 
         'CREATE TEMPORARY TABLE '.$stats_table.' '.
         'SELECT a.student_id,a.solved,a.award,a.awarded,a.tries '.
         'FROM '.$performance_table.' AS a ';
+    #
+    # See if we need to include some requirements on the students
     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;
+    #
+    # Limit the students included to those specified
     if (defined($Sections) && lc($Sections->[0]) ne 'all') {
         $request .= ' AND ('.
             join(' OR ', map { "b.section='".$_."'" } @$Sections
@@ -1949,7 +1954,7 @@
         $request .= " AND b.status='".$status."'";
     }
     #
-    &Apache::lonnet::logthis('starttime = '.$starttime);
+    # Limit by starttime and endtime
     my $time_requirements = undef;
     if (defined($starttime)) {
         $time_requirements .= 'a.timestamp>='.$starttime;
@@ -1962,22 +1967,20 @@
     if (defined($time_requirements)) {
         $request .= ' AND '.$time_requirements;
     }
+    #
+    # Finally, execute the request to create the temporary table
     $dbh->do($request);
-#    &Apache::lonnet::logthis('request = '.$/.$request);
+    #
+    # Collect the first suite of statistics
     $request = 'SELECT COUNT(*),SUM(tries),MAX(tries),AVG(tries),STD(tries) '.
         'FROM '.$stats_table;
     my ($num,$tries,$mod,$mean,$STD) = &execute_SQL_request
         ($dbh,$request);
-#    &Apache::lonnet::logthis('request = '.$/.$request);
     $request = 'SELECT SUM(awarded) FROM '.$stats_table;
     my ($Solved) = &execute_SQL_request($dbh,$request);
-#    &Apache::lonnet::logthis('request = '.$/.$request);
     $request = 'SELECT SUM(awarded) FROM '.$stats_table.
         " WHERE solved='correct_by_override'";
-#    &Apache::lonnet::logthis('request = '.$/.$request);
     my ($solved) = &execute_SQL_request($dbh,$request);
-#    $Solved = int($Solved);
-#    $solved = int($solved);
     #
     $num    = 0 if (! defined($num));
     $tries  = 0 if (! defined($tries));
@@ -1986,9 +1989,10 @@
     $Solved = 0 if (! defined($Solved));
     $solved = 0 if (! defined($solved));
     #
+    # Compute the more complicated statistics
     my $DegOfDiff = 'nan';
     $DegOfDiff = 1-($Solved)/$tries if ($tries>0);
-
+    #
     my $SKEW = 'nan';
     my $wrongpercent = 0;
     if ($num > 0) {
@@ -1998,26 +2002,25 @@
         $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
     }
     #
-#    $dbh->do('DROP TABLE '.$stats_table);  # May return an error
+    # Drop the temporary table
+    $dbh->do('DROP TABLE '.$stats_table);  # May return an error
     #
     # Store in metadata
-    #
     if ($num) {
 	my %storestats=();
-
+        #
         my $urlres=(&Apache::lonnet::decode_symb($symb))[2];
-
+        #
 	$storestats{$courseid.'___'.$urlres.'___timestamp'}=time;       
 	$storestats{$courseid.'___'.$urlres.'___stdno'}=$num;
 	$storestats{$courseid.'___'.$urlres.'___avetries'}=$mean;	   
 	$storestats{$courseid.'___'.$urlres.'___difficulty'}=$DegOfDiff;
-
+        #
 	$urlres=~/^(\w+)\/(\w+)/; 
 	&Apache::lonnet::put('nohist_resevaldata',\%storestats,$1,$2); 
     }
     #
     # Return result
-    #
     return { num_students => $num,
              tries        => $tries,
              max_tries    => $mod,
@@ -2041,6 +2044,7 @@
     }
     return ();
 }
+
 
 sub get_student_data {
     my ($students,$courseid) = @_;