--- loncom/interface/statistics/lonproblemstatistics.pm 2002/11/01 22:09:39 1.35 +++ loncom/interface/statistics/lonproblemstatistics.pm 2002/12/13 21:39:19 1.39 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonproblemstatistics.pm,v 1.35 2002/11/01 22:09:39 minaeibi Exp $ +# $Id: lonproblemstatistics.pm,v 1.39 2002/12/13 21:39:19 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,7 +35,7 @@ # ### -package Apache::lonproblemstatistics; +package Apache::lonproblemstatistics; use strict; use Apache::lonnet(); @@ -221,10 +221,7 @@ sub BuildProblemStatisticsPage { sub BuildGraphicChart { my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_; my %cache; - my $max = 0; - unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { - return 'Unable to tie database.7'; - } + my $max; my $title = ''; if($graph eq 'DoDiffGraph') { @@ -244,6 +241,10 @@ sub BuildGraphicChart { my @values = (); + unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) { + return 'Unable to tie database.7'; + } + foreach(@$orderedProblems) { my ($sequence,$problem,$part)=split(':', $_); if($cache{'StatisticsMaps'} ne 'All Maps' && @@ -258,11 +259,12 @@ sub BuildGraphicChart { &DrawGraph(\@values,$courseDescription,$title,$max,$r); } if($sortProblems eq 'Sort Within Sequence') { - $r->print(''.$cache{$sequence.':title'}.''); + $r->print('
'.$cache{$sequence.':title'}.''."\n"); } $currentSequence = $sequence; @values = (); + $max=0; } my $data = 0; if($graph eq 'DoDiffGraph') { @@ -287,21 +289,25 @@ sub DrawGraph { my ($values,$courseDescription,$title,$Max,$r)=@_; my $sendValues = join(',', @$values); my $sendCount = scalar(@$values); - + $r->print("
The Maximum Value is: $Max"); if ( $Max > 1 ) { if ($Max % 10) { - $Max++; + if ( int($Max) < $Max ) { + $Max++; + $Max = int($Max); + } } - #(10 - $Max % 10); - $Max = int($Max); + #(10 - $Max % 10); } else { $Max = 1; } - my @GData = ($courseDescription, 'Problem_number', - $title, $Max, $sendCount, $sendValues); - $r->print(''."\n"); - $r->print('print('
'."\n"); + $r->print(''); - $r->print('
'."\n"); +# $r->print(''."\n"); + $r->print('
'."\n"); } #---- Problem Statistics Web Page --------------------------------------- @@ -331,7 +337,7 @@ sub BuildStatisticsTable { 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; @@ -652,7 +658,7 @@ sub ExtractStudentData { sub SortDivideByTries { my ($toSort, $data, $sortOn)=@_; - my @orderedData = sort { ($data->{$a.':totalTries'}) ? + my @orderedData = sort { ($data->{$a.':totalTries'}) ? ($data->{$a.$sortOn}/$data->{$a.':totalTries'}):0 <=> ($data->{$b.':totalTries'}) ?