--- loncom/interface/statistics/lonpercentage.pm 2003/01/11 06:31:26 1.5 +++ loncom/interface/statistics/lonpercentage.pm 2008/12/12 10:01:30 1.11 @@ -1,7 +1,6 @@ # The LearningOnline Network with CAPA -# (Publication Handler # -# $Id: lonpercentage.pm,v 1.5 2003/01/11 06:31:26 minaeibi Exp $ +# $Id: lonpercentage.pm,v 1.11 2008/12/12 10:01:30 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,6 +32,9 @@ use strict; use Apache::lonhtmlcommon; use Apache::loncoursedata; use GDBM_File; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + sub BuildPercentageGraph { @@ -110,9 +112,7 @@ sub CreateInterface { $Ptr .= ''."\n"; my @sections = split(':',$cache->{'sectionList'}); my @sectionsSelected = split(':',$cache->{'sectionsSelected'}); - $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, - \@sectionsSelected, - 'Statistics'); + $Ptr .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); $Ptr .= ''."\n"; $Ptr .= ''; @@ -193,10 +193,11 @@ sub GraphData { my %percentages; my $Ptr = ''; + my $totalProblems = 0; foreach(@$students) { my $totalCorrect = 0; - my $totalProblems = 0; + $totalProblems = 0; foreach my $sequence (split(':',$cache->{'orderedSequences'})) { next if($cache->{$sequence.':title'} ne $sequenceSelected && @@ -221,9 +222,13 @@ sub GraphData { } } } - - my $percent = sprintf("%d", ($totalProblems) ? - (($totalCorrect/$totalProblems)*100) : 0); + my $percent; + if ( $totalProblems >= 100 ) { + $percent = sprintf("%d", ($totalProblems) ? + (($totalCorrect/$totalProblems)*100) : 0); + } else { + $percent = sprintf("%d", ($totalProblems) ? $totalCorrect : 0); + } if(defined($percentages{$percent})) { $percentages{$percent} .= ':::'.$_; } else { @@ -235,6 +240,7 @@ sub GraphData { my @percentCount = (); my $max = 0; my $pno = 0; + foreach my $key (sort NumericSort keys(%percentages)) { push(@percent, $key); my @temp = split(':::', $percentages{$key}); @@ -246,10 +252,6 @@ sub GraphData { $pno++; } -# $r->print('
max='.$max); -# $r->print('
percentcount='.join(',', @percentCount)); -# $r->print('
percent='.join(',', @percent)); - my $cId=0; my @data1=(); my @data2=(); @@ -264,11 +266,25 @@ sub GraphData { } } + my $xlabel; + my $Freq; + if ($totalProblems >= 100 ) { + $xlabel = 'Percentage_of_Problems_Correct'; + $Freq=101; + } else { + $xlabel = 'Number_of_Problems_Correct'; + $Freq = $cId; + } + +# $r->print('
Freq='.$Freq); +# $r->print('
max='.$max); +# $r->print('
percentcount='.join(',', @percentCount)); +# $r->print('
percent='.join(',', @percent)); # $r->print('
percentcount='.join(',', @data1)); # $r->print('
percent='.join(',', @data2)); - - my @GData = ('','Percentage','Number_of_Students',$max,101 , + my @GData = ("Percentage",$xlabel, + 'Number_of_Students',$max,$Freq, join(',',@data1), join(',', @data2)); $Ptr .= ''."\n"; @@ -314,11 +330,11 @@ sub TableData { foreach my $name (sort(split(':::', $percentage->{$_}))) { $Ptr .= ''; + $Ptr .= &escape($cache->{$name.':fullname'}).'">'; $Ptr .= $cache->{$name.':fullname'}; - $Ptr .= ',  '; + $Ptr .= ',  '; } $Ptr .= ''."\n";