[LON-CAPA-cvs] cvs: loncom /interface/statistics lonstudentassessment.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 09 Jan 2003 15:59:17 -0000
matthew Thu Jan 9 10:59:17 2003 EDT
Modified files:
/loncom/interface/statistics lonstudentassessment.pm
Log:
Fix bug 1149, which was a server crash due to division by zero.
Index: loncom/interface/statistics/lonstudentassessment.pm
diff -u loncom/interface/statistics/lonstudentassessment.pm:1.24 loncom/interface/statistics/lonstudentassessment.pm:1.25
--- loncom/interface/statistics/lonstudentassessment.pm:1.24 Fri Jan 3 18:54:05 2003
+++ loncom/interface/statistics/lonstudentassessment.pm Thu Jan 9 10:59:17 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstudentassessment.pm,v 1.24 2003/01/03 23:54:05 minaeibi Exp $
+# $Id: lonstudentassessment.pm,v 1.25 2003/01/09 15:59:17 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -425,9 +425,13 @@
$ProblemsSolved += $cache->{$name.':problemsSolved'};
$TotalProblems += $cache->{$name.':totalProblems'};
}
- $ProblemsSolved /= $StudentCount;
- $TotalProblems /= $StudentCount;
-
+ if ($StudentCount) {
+ $ProblemsSolved /= $StudentCount;
+ $TotalProblems /= $StudentCount;
+ } else {
+ $ProblemsSolved = 0;
+ $TotalProblems = 0;
+ }
$Str .= '<table border=2 cellspacing="1">'."\n";
$Str .= '<tr><td><b>Students Count</b></td><td><b>'.
$StudentCount.'</b></td></tr>'."\n";
@@ -446,7 +450,12 @@
#my @problems=split(':', $cache->{$S.':problems'});
#my $pCount=scalar @problems;
my $pCount=MaxSeqPr($cache,@$students[0],$S);
- my $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount );
+ my $crr;
+ if ($StudentCount) {
+ $crr=sprintf( "%.2f", $Correct{$S}/$StudentCount );
+ } else {
+ $crr="0.00";
+ }
$Str .= '<tr><td>'.$title.
'</td><td align=center>'.$pCount.
'</td><td align=center>'.$crr.