[LON-CAPA-cvs] cvs: loncom /interface lonstatistics.pm /interface/statistics lonproblemstatistics.pm
stredwic
lon-capa-cvs@mail.lon-capa.org
Tue, 13 Aug 2002 15:01:07 -0000
stredwic Tue Aug 13 11:01:07 2002 EDT
Modified files:
/loncom/interface lonstatistics.pm
/loncom/interface/statistics lonproblemstatistics.pm
Log:
Now the degree of difficulty and percent wrong graphs work correctly. There
data is based off of the cached statistical data.
Index: loncom/interface/lonstatistics.pm
diff -u loncom/interface/lonstatistics.pm:1.42 loncom/interface/lonstatistics.pm:1.43
--- loncom/interface/lonstatistics.pm:1.42 Tue Aug 13 08:21:46 2002
+++ loncom/interface/lonstatistics.pm Tue Aug 13 11:01:07 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonstatistics.pm,v 1.42 2002/08/13 12:21:46 stredwic Exp $
+# $Id: lonstatistics.pm,v 1.43 2002/08/13 15:01:07 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -577,7 +577,11 @@
&Apache::lonproblemanalysis::BuildAnalyzePage($cacheDB, $students,
$courseID, $r);
} elsif($GoToPage eq 'DoDiffGraph' || $GoToPage eq 'PercentWrongGraph') {
- &Apache::lonproblemstatistics::BuildGraphicChart($GoToPage,$r,$cacheDB);
+ my $courseDescription = $ENV{'course.'.$courseID.'.description'};
+ $courseDescription =~ s/\ /"_"/eg;
+ &Apache::lonproblemstatistics::BuildGraphicChart($GoToPage, $cacheDB,
+ $courseDescription,
+ $r);
} elsif($GoToPage eq 'Class list') {
&BuildClasslist($cacheDB, $students, \@studentInformation,
\@headings, $r);
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.21 loncom/interface/statistics/lonproblemstatistics.pm:1.22
--- loncom/interface/statistics/lonproblemstatistics.pm:1.21 Tue Aug 13 09:57:25 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm Tue Aug 13 11:01:07 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemstatistics.pm,v 1.21 2002/08/13 13:57:25 stredwic Exp $
+# $Id: lonproblemstatistics.pm,v 1.22 2002/08/13 15:01:07 stredwic Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -627,49 +627,46 @@
# ------------------------------------------- Prepare data for Graphical chart
sub BuildGraphicChart {
- my ($ylab,$r,$cacheDB)=@_;
+ my ($graph,$cacheDB,$courseDescription,$r)=@_;
my %cache;
- my $Col;
- my $data='';
- my $count = 0;
- my $Max = 0;
+ my $max = 0;
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
return '<html><body>Unable to tie database.</body></html>';
}
- my $p_count = $cache{'ProblemCount'};
-
- for ( my $k=0; $k<$p_count;$k++) {
- my @Temp=split(/\:/,$cache{'GraphGif:'.$k});
- my $inf = $Temp[$Col];
- if ( $Max < $inf ) {$Max = $inf;}
- $data .= $inf.',';
- $count++;
+ my @problems = split(':::', $cache{'problemList'});
+ my @values = ();
+ foreach (@problems) {
+ my $data = 0;
+ if($graph eq 'DoDiffGraph') {
+ $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
+ } else {
+ $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
+ }
+ if($max < $data) {
+ $max = $data;
+ }
+ push(@values, $data);
}
untie(%cache);
-# $r->print("<br>count=$p_count >>data= $data");
- if ( $Max > 1 ) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
- } else { $Max = 1; }
-
- my $cid=$ENV{'request.course.id'};
-
- if ( $ylab eq 'DoDiff Graph' ) {
- $ylab = 'Degree-of-Difficulty';
- $Col = 0;
+ my $sendValues = join(',', @values);
+# my $sendCount = $#values;
+ my $sendCount = scalar(@values);
+
+ my $title = '';
+ if($graph eq 'DoDiffGraph') {
+ $title = 'Degree-of-Difficulty';
} else {
- $ylab = 'Wrong-Percentage';
- $Col = 1;
+ $title = 'Wrong-Percentage';
}
- my $Course = $ENV{'course.'.$cid.'.description'};
- $Course =~ s/\ /"_"/eg;
- my $GData=$Course.'&'.'Problems#'.'&'.$ylab.'&'.
- $Max.'&'.$count.'&'.$data;
+ my @GData = ($courseDescription, 'Problems', $title, $max, $sendCount,
+ $sendValues);
- $r->print('<IMG src="/cgi-bin/graph.gif?'.$GData.'" />');
+ $r->print('</form>'."\n");
+ $r->print('<IMG src="/cgi-bin/graph.gif?'.(join('&', @GData)).'" border="1" />');
+ $r->print('<form>'."\n");
return;
}