[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemstatistics.pm
minaeibi
lon-capa-cvs@mail.lon-capa.org
Fri, 01 Nov 2002 22:09:39 -0000
minaeibi Fri Nov 1 17:09:39 2002 EDT
Modified files:
/loncom/interface/statistics lonproblemstatistics.pm
Log:
fixed bug #899
sepate the degree of difficulty and %worong garph in relation to every homework set
Index: loncom/interface/statistics/lonproblemstatistics.pm
diff -u loncom/interface/statistics/lonproblemstatistics.pm:1.34 loncom/interface/statistics/lonproblemstatistics.pm:1.35
--- loncom/interface/statistics/lonproblemstatistics.pm:1.34 Wed Oct 30 13:37:00 2002
+++ loncom/interface/statistics/lonproblemstatistics.pm Fri Nov 1 17:09:39 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# (Publication Handler
#
-# $Id: lonproblemstatistics.pm,v 1.34 2002/10/30 18:37:00 minaeibi Exp $
+# $Id: lonproblemstatistics.pm,v 1.35 2002/11/01 22:09:39 minaeibi Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -30,8 +30,8 @@
# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
# YEAR=2002
-# 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
-# 5/12,5/14,5/15,5/19,5/26,7/16,7/25,7/29,8/5 Behrouz Minaei
+# 1/22,2/1,2/6,2/25,3/2,3/26,4/7,5/6 Behrouz Minaei
+# 5/12,5/26,7/16,7/29,8/5,10/31 Behrouz Minaei
#
###
@@ -43,14 +43,11 @@
use Apache::loncoursedata;
use GDBM_File;
-my $jr;
sub InitializeProblemStatistics {
my ($cacheDB, $students, $courseID, $c, $r)=@_;
my %cache;
- $jr = $r;
-
unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
$r->print('Unable to tie database1.');
return ('ERROR', undef);
@@ -229,8 +226,6 @@
return 'Unable to tie database.7';
}
-# my @problems = split(':::', $cache{'problemList'});
-
my $title = '';
if($graph eq 'DoDiffGraph') {
$title = 'Degree-of-Difficulty';
@@ -238,22 +233,6 @@
$title = 'Wrong-Percentage';
}
-
- # 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);
- # }
-
-
- my $count = 1;
my $currentSequence = -1;
my $sortProblems = 'Sort Within Sequence';
@@ -269,31 +248,21 @@
my ($sequence,$problem,$part)=split(':', $_);
if($cache{'StatisticsMaps'} ne 'All Maps' &&
$cache{'StatisticsMaps'} ne $cache{$sequence.':title'}) {
- next;
+ next;
}
- if($currentSequence == -1 ||
- ($sortProblems eq 'Sort Within Sequence' &&
+ if( $currentSequence == -1 ||
+ ($sortProblems eq 'Sort Within Sequence' &&
$currentSequence != $sequence)) {
- if($currentSequence ne -1) {
- #$r->print('<br>finish a graph<br>');
- }
+ if($currentSequence != -1) {
+ &DrawGraph(\@values,$courseDescription,$title,$max,$r);
+ }
if($sortProblems eq 'Sort Within Sequence') {
$r->print('<b>'.$cache{$sequence.':title'}.'</b>');
}
- my $sendValues = join(',', @values);
- my $sendCount = scalar(@values);
-
- my @GData = ($courseDescription, 'Problems',
- $title, $max, $sendCount, $sendValues);
- $r->print('</form>'."\n");
- $r->print('<IMG src="/cgi-bin/graph.gif?'.
- (join('&', @GData)).'" border="1" />');
- $r->print('<form>'."\n");
$currentSequence = $sequence;
@values = ();
-
}
my $data = 0;
if($graph eq 'DoDiffGraph') {
@@ -305,17 +274,36 @@
$max = $data;
}
push(@values, $data);
-
}
-
-#$r->print('<br>');
-
untie(%cache);
+ &DrawGraph(\@values,$courseDescription,$title,$max,$r);
+
return;
}
+sub DrawGraph {
+ my ($values,$courseDescription,$title,$Max,$r)=@_;
+ my $sendValues = join(',', @$values);
+ my $sendCount = scalar(@$values);
+
+ if ( $Max > 1 ) {
+ if ($Max % 10) {
+ $Max++;
+ }
+ #(10 - $Max % 10);
+ $Max = int($Max);
+ } else { $Max = 1; }
+
+ my @GData = ($courseDescription, 'Problem_number',
+ $title, $Max, $sendCount, $sendValues);
+ $r->print('</form>'."\n");
+ $r->print('<IMG src="/cgi-bin/graph.gif?'.
+ (join('&', @GData)).'" border="1" />');
+ $r->print('<form>'."\n");
+}
+
#---- Problem Statistics Web Page ---------------------------------------
sub CreateProblemStatisticsTableHeading {
@@ -343,7 +331,7 @@
my $count = 1;
my $currentSequence = -1;
foreach(@$orderedProblems) {
- my ($sequence,$problem,$part)=split(':', $_);
+ my ($sequence,$problem,$part)=split(':', $_);
if($cache->{'StatisticsMaps'} ne 'All Maps' &&
$cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) {
next;