[LON-CAPA-cvs] cvs: loncom /interface/statistics lonpercentage.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Mon, 13 Jan 2003 00:15:16 -0000
minaeibi Sun Jan 12 19:15:16 2003 EDT
Modified files:
/loncom/interface/statistics lonpercentage.pm
Log:
I had these Suggestions to fix bug #1052:
1)a) If the number of problems involved is less than 100
it would be better to change the plotting to
display "number of problems correct" on the x-axis
and the range would be from 0 to 99
b) If the number of problems is > or = 100
Plot the % leave as it is currently.
So I chnged the lonpercentage module:
if ( $totalProblems >= 100 ) {
$percent = sprintf("%d", ($totalProblems) ?
(($totalCorrect/$totalProblems)*100) : 0);
} else {
$percent = sprintf("%d", ($totalProblems) ? $totalCorrect : 0);
}
...
my $xlabel = ($totalProblems >= 100 ) ?
'Percentage_of_Problems_Correct' :
'Number_of_Problems_Correct';
I hope will work well.
Let me know any feedback
Index: loncom/interface/statistics/lonpercentage.pm
diff -u loncom/interface/statistics/lonpercentage.pm:1.5 loncom/interface/statistics/lonpercentage.pm:1.6
--- loncom/interface/statistics/lonpercentage.pm:1.5 Sat Jan 11 01:31:26 2003
+++ loncom/interface/statistics/lonpercentage.pm Sun Jan 12 19:15:16 2003
@@ -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 @@
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 @@
}
}
}
-
- 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 @@
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 @@
$pno++;
}
-# $r->print('<br>max='.$max);
-# $r->print('<br> percentcount='.join(',', @percentCount));
-# $r->print('<br> percent='.join(',', @percent));
-
my $cId=0;
my @data1=();
my @data2=();
@@ -264,11 +270,15 @@
}
}
+# $r->print('<br> xlable='.$xlabel);
+# $r->print('<br>max='.$max);
+# $r->print('<br> percentcount='.join(',', @percentCount));
+# $r->print('<br> percent='.join(',', @percent));
# $r->print('<br> percentcount='.join(',', @data1));
# $r->print('<br> 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 .= '</form>'."\n";