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

stredwic lon-capa-cvs@mail.lon-capa.org
Thu, 15 Aug 2002 13:54:13 -0000


stredwic		Thu Aug 15 09:54:13 2002 EDT

  Modified files:              
    /loncom/interface/statistics	lonproblemstatistics.pm 
  Log:
  Added the storing of certain pieces of data from the statistics table
  into metadata back into the code.
  
  
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.28 loncom/interface/statistics/lonproblemstatistics.pm:1.29
--- loncom/interface/statistics/lonproblemstatistics.pm:1.28	Wed Aug 14 17:51:51 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm	Thu Aug 15 09:54:13 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # (Publication Handler
 #
-# $Id: lonproblemstatistics.pm,v 1.28 2002/08/14 21:51:51 stredwic Exp $
+# $Id: lonproblemstatistics.pm,v 1.29 2002/08/15 13:54:13 stredwic Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -123,7 +123,7 @@
     my $problemData;
     if($isNotCached) {
         ($problemData) = &ExtractStudentData(\%cache, $students);
-        &CalculateStatistics($problemData, \%cache);
+        &CalculateStatistics($problemData, \%cache, $courseID);
     }
     untie(%cache);
 
@@ -699,7 +699,7 @@
 }
 
 sub CalculateStatistics {
-    my ($data, $cache)=@_;
+    my ($data, $cache, $courseID)=@_;
 
     my @problems = split(':::', $data->{'problemList'});
     foreach(@problems) {
@@ -797,6 +797,23 @@
 
         my $df2 = $upper2Sum - $lower2Sum;
         $data->{$_.':discriminationFactor2'} = sprintf("%.2f", $df2);
+
+        my %storestats;
+        my ($sequence) = split(':', $_);
+        my $Average = ($data->{$_.':studentCount'}) ? 
+            $data->{$_.':totalTries'}/$data->{$_.':studentCount'} : 0;
+        $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+                        '___timestamp'}=time;
+        $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+                        '___stdno'}=$data->{$_.':studentCount'};
+        $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+                        '___avetries'}=$Average;
+        $storestats{$courseID.'___'.$cache->{$sequence.':source'}.
+                        '___difficulty'}=$data->{$_.':degreeOfDifficulty'};
+        $cache->{$sequence.':source'} =~ /^(\w+)\/(\w+)/;
+        if($data->{$_.':studentCount'}) { 
+            &Apache::lonnet::put('resevaldata',\%storestats,$1,$2);
+        }
     }
 
     return;