[LON-CAPA-cvs] cvs: loncom /interface/statistics lonpercentage.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Wed, 08 Jan 2003 03:27:54 -0000
minaeibi Tue Jan 7 22:27:54 2003 EDT
Modified files:
/loncom/interface/statistics lonpercentage.pm
Log:
Fixed bug #1020.
lonperntage.pm fixed to show the percentages of correct answers of students correctly.
A field (frequency) added to percentage table.
I don't know why data are not cached and every time are computed.
Maybe it will be repoted in bugzilla so it would be considered to fix.
Index: loncom/interface/statistics/lonpercentage.pm
diff -u loncom/interface/statistics/lonpercentage.pm:1.3 loncom/interface/statistics/lonpercentage.pm:1.4
--- loncom/interface/statistics/lonpercentage.pm:1.3 Fri Dec 13 16:39:19 2002
+++ loncom/interface/statistics/lonpercentage.pm Tue Jan 7 22:27:54 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonpercentage.pm,v 1.3 2002/12/13 21:39:19 albertel Exp $
+# $Id: lonpercentage.pm,v 1.4 2003/01/08 03:27:54 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,7 +34,6 @@
use Apache::loncoursedata;
use GDBM_File;
-#my $jr;
sub BuildPercentageGraph {
my ($cacheDB, $students, $courseID, $c, $r)=@_;
@@ -60,8 +59,8 @@
return;
}
- my ($Ptr, $percentage) = &GraphData(\%cache, $students);
- $r->print($Ptr.'<br><br>');
+ my ($Ptr, $percentage) = &GraphData(\%cache, $students,$r);
+ $r->print($Ptr.'<br>');
$r->print(&TableData(\%cache, $percentage));
@@ -186,7 +185,7 @@
}
sub GraphData {
- my ($cache,$students)=@_;
+ my ($cache,$students,$r)=@_;
my $sequenceSelected = $cache->{'StatisticsMaps'};
my $problemSelected = $cache->{'StatisticsProblemSelect'};
@@ -235,7 +234,8 @@
my @percent = ();
my @percentCount = ();
my $max = 0;
- foreach my $key (sort(keys(%percentages))) {
+ my $pno = 0;
+ foreach my $key (sort NumericSort keys(%percentages)) {
push(@percent, $key);
my @temp = split(':::', $percentages{$key});
my $count = scalar(@temp);
@@ -243,12 +243,21 @@
$max = $count;
}
push(@percentCount, $count);
+ $pno++;
}
- my @GData = ('', 'Percentage', 'Number_of_Students',
- $max, scalar(@percent),
+# $r->print('<br>max='.$max);
+# $r->print('<br> percentcount='.join(',', @percentCount));
+# $r->print('<br> percent='.join(',', @percent));
+
+ my @GData = ('','Percentage','Number_of_Students',$max,$pno,
join(',',@percent), join(',', @percentCount));
+
+# my @GData = ('', 'Percentage', 'Number_of_Students',
+# $max, scalar(@percent),
+# join(',',@percent), join(',', @percentCount));
+
$Ptr .= '</form>'."\n";
$Ptr .= '<IMG src="/cgi-bin/graph.png?'.(join('&', @GData));
$Ptr .= '" border="1" />';
@@ -257,19 +266,29 @@
return ($Ptr, \%percentages);
}
+sub NumericSort {
+ $a <=> $b;
+}
+
sub TableData {
my($cache,$percentage)=@_;
my $Ptr;
- $Ptr .= '<table border="0"><tr><td bgcolor="#777777">'."\n";
+ $Ptr .= '<table border="0"><tr><td bgcolor="#D7D7D7">'."\n";
$Ptr .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n";
$Ptr .= '<tr>'."\n";
- $Ptr .= '<td>Percent Correct</td><td>Students</td>';
+ $Ptr .= '<td>% Correct</td>'.
+ '<td>Frequency</td>'.
+ '<td>Students</td>';
$Ptr .= '</tr>'."\n";
my $alternate=0;
- foreach (sort(keys(%$percentage))) {
+ foreach (sort NumericSort keys(%$percentage)) {
+
+ my @temp = split(':::', $percentage->{$_});
+ my $count = scalar(@temp);
+
if($alternate) {
$Ptr .= '<tr bgcolor="#ffffe6">';
} else {
@@ -277,7 +296,8 @@
}
$alternate = ($alternate + 1) % 2;
- $Ptr .= '<td>'.$_.'</td><td>';
+ $Ptr .= '<td>'.$_.'</td>';
+ $Ptr .= '<td>'.$count.'</td><td>';
foreach my $name (sort(split(':::', $percentage->{$_}))) {
$Ptr .= '<a href="/adm/statistics?reportSelected=';