--- loncom/interface/statistics/lonproblemstatistics.pm 2002/10/30 18:37:00 1.34 +++ loncom/interface/statistics/lonproblemstatistics.pm 2002/11/01 22:09:39 1.35 @@ -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::lonhtmlcommon; 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 @@ sub BuildGraphicChart { 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 @@ sub BuildGraphicChart { $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 @@ sub BuildGraphicChart { 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('
finish a graph
'); - } + if($currentSequence != -1) { + &DrawGraph(\@values,$courseDescription,$title,$max,$r); + } if($sortProblems eq 'Sort Within Sequence') { $r->print(''.$cache{$sequence.':title'}.''); } - my $sendValues = join(',', @values); - my $sendCount = scalar(@values); - - my @GData = ($courseDescription, 'Problems', - $title, $max, $sendCount, $sendValues); - $r->print(''."\n"); - $r->print(''); - $r->print('
'."\n"); $currentSequence = $sequence; @values = (); - } my $data = 0; if($graph eq 'DoDiffGraph') { @@ -305,17 +274,36 @@ sub BuildGraphicChart { $max = $data; } push(@values, $data); - } - -#$r->print('
'); - 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('
'."\n"); + $r->print(''); + $r->print('
'."\n"); +} + #---- Problem Statistics Web Page --------------------------------------- sub CreateProblemStatisticsTableHeading { @@ -343,7 +331,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;