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

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 12 Mar 2003 20:53:53 -0000


matthew		Wed Mar 12 15:53:53 2003 EDT

  Modified files:              
    /loncom/interface/statistics	lonstudentassessment.pm 
  Log:
  If none of the students have any data, we get a division by zero when we
  compute the average.  This is now detected and everything is right with 
  the world.
  
  
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.41 loncom/interface/statistics/lonstudentassessment.pm:1.42
--- loncom/interface/statistics/lonstudentassessment.pm:1.41	Sun Mar  9 13:53:06 2003
+++ loncom/interface/statistics/lonstudentassessment.pm	Wed Mar 12 15:53:53 2003
@@ -1,6 +1,6 @@
 # The LearningOnline Network with CAPA
 #
-# $Id: lonstudentassessment.pm,v 1.41 2003/03/09 18:53:06 matthew Exp $
+# $Id: lonstudentassessment.pm,v 1.42 2003/03/12 20:53:53 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -596,8 +596,13 @@
     $Str .= '<table border=2 cellspacing="1">'."\n";
     $Str .= "<tr><th>Title</th><th>Average</th><th>Maximum</th></tr>\n";
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
-        my $ave = int(100*($Statistics->{$seq->{'symb'}}->{'score'}/
-            ($num_students-$nodata_count)))/100;
+        my $ave;
+        if ($num_students > $nodata_count) {
+            $ave = int(100*($Statistics->{$seq->{'symb'}}->{'score'}/
+                            ($num_students-$nodata_count)))/100;
+        } else {
+            $ave = 0;
+        }
         $total_ave += $ave;
         my $max = $seq->{'num_assess_parts'};
         $total_max += $max;