--- loncom/interface/statistics/lonproblemstatistics.pm 2002/08/13 13:57:25 1.21 +++ loncom/interface/statistics/lonproblemstatistics.pm 2002/08/13 15:01:07 1.22 @@ -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 @@ sub Discriminant { # ------------------------------------------- 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 'Unable to tie database.'; } - 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("
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(''); + $r->print(''."\n"); + $r->print(''); + $r->print('
'."\n"); return; }