--- loncom/interface/statistics/lonpercentage.pm 2003/01/11 06:31:26 1.5
+++ loncom/interface/statistics/lonpercentage.pm 2003/01/13 00:15:16 1.6
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonpercentage.pm,v 1.5 2003/01/11 06:31:26 minaeibi Exp $
+# $Id: lonpercentage.pm,v 1.6 2003/01/13 00:15:16 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -193,10 +193,11 @@ sub GraphData {
my %percentages;
my $Ptr = '';
+ my $totalProblems = 0;
foreach(@$students) {
my $totalCorrect = 0;
- my $totalProblems = 0;
+ $totalProblems = 0;
foreach my $sequence (split(':',$cache->{'orderedSequences'})) {
next if($cache->{$sequence.':title'} ne $sequenceSelected &&
@@ -221,9 +222,13 @@ sub GraphData {
}
}
}
-
- my $percent = sprintf("%d", ($totalProblems) ?
- (($totalCorrect/$totalProblems)*100) : 0);
+ my $percent;
+ if ( $totalProblems >= 100 ) {
+ $percent = sprintf("%d", ($totalProblems) ?
+ (($totalCorrect/$totalProblems)*100) : 0);
+ } else {
+ $percent = sprintf("%d", ($totalProblems) ? $totalCorrect : 0);
+ }
if(defined($percentages{$percent})) {
$percentages{$percent} .= ':::'.$_;
} else {
@@ -235,6 +240,11 @@ sub GraphData {
my @percentCount = ();
my $max = 0;
my $pno = 0;
+
+ my $xlabel = ($totalProblems >= 100 ) ?
+ 'Percentage_of_Problems_Correct' :
+ 'Number_of_Problems_Correct';
+
foreach my $key (sort NumericSort keys(%percentages)) {
push(@percent, $key);
my @temp = split(':::', $percentages{$key});
@@ -246,10 +256,6 @@ sub GraphData {
$pno++;
}
-# $r->print('
max='.$max);
-# $r->print('
percentcount='.join(',', @percentCount));
-# $r->print('
percent='.join(',', @percent));
-
my $cId=0;
my @data1=();
my @data2=();
@@ -264,11 +270,15 @@ sub GraphData {
}
}
+# $r->print('
xlable='.$xlabel);
+# $r->print('
max='.$max);
+# $r->print('
percentcount='.join(',', @percentCount));
+# $r->print('
percent='.join(',', @percent));
# $r->print('
percentcount='.join(',', @data1));
# $r->print('
percent='.join(',', @data2));
-
- my @GData = ('','Percentage','Number_of_Students',$max,101 ,
+ my @GData = ("Percentage",$xlabel,
+ 'Number_of_Students',$max,100 ,
join(',',@data1), join(',', @data2));
$Ptr .= ''."\n";