--- loncom/interface/statistics/lonproblemstatistics.pm 2003/08/29 21:11:25 1.57 +++ loncom/interface/statistics/lonproblemstatistics.pm 2004/03/07 21:42:19 1.70 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.57 2003/08/29 21:11:25 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.70 2004/03/07 21:42:19 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,11 +51,21 @@ package Apache::lonproblemstatistics; use strict; use Apache::lonnet(); +use Apache::loncommon(); use Apache::lonhtmlcommon; use Apache::loncoursedata; use Apache::lonstatistics; +use Apache::lonlocal; use Spreadsheet::WriteExcel; +use Apache::lonstathelpers(); +## +## Localization notes: +## +## in @Fields[0]->{'long_title'} is placed in Excel files and is used as the +## header for plots created with Graph.pm, both of which more than likely do +## not support localization. +## my @Fields = ( { name => 'problem_num', title => 'P#', @@ -138,7 +148,7 @@ my @Fields = ( title => '#YES', align => 'right', color => '#FFDDDD', - format => '%d', + format => '%4.1f',# format => '%d', sortable => 'yes', graphable => 'yes', long_title => 'Number of Students able to Solve' }, @@ -146,7 +156,7 @@ my @Fields = ( title => '#yes', align => 'right', color => '#FFDDDD', - format => '%d', + format => '%4.1f',# format => '%d', sortable => 'yes', graphable => 'yes', long_title => 'Number of Students given Override' }, @@ -176,19 +186,19 @@ select sections, maps, and output. ############################################### my @OutputOptions = ( - { name => 'problem statistics grouped by sequence', + { name => 'grouped by sequence', value => 'HTML problem statistics grouped', description => 'Output statistics for the problem parts.', mode => 'html', show => 'grouped', }, - { name => 'problem statistics ungrouped', + { name => 'ungrouped', value => 'HTML problem statistics ungrouped', description => 'Output statistics for the problem parts.', mode => 'html', show => 'ungrouped', }, - { name => 'problem statistics, Excel', + { name => 'Excel', value => 'Excel problem statistics', description => 'Output statistics for the problem parts '. 'in an Excel workbook', @@ -199,12 +209,16 @@ my @OutputOptions = sub CreateInterface { my $Str = ''; + $Str .= &Apache::lonhtmlcommon::breadcrumbs + (undef,'Overall Problem Statistics','Statistics_Overall_Key'); $Str .= '
Sections | '; - $Str .= 'Enrollment Status | '; - $Str .= 'Sequences and Folders | '; - $Str .= 'Output | '; + $Str .= ''.&mt('Sections').' | '; + $Str .= ''.&mt('Enrollment Status').' | '; + $Str .= ''.&mt('Sequences and Folders').' | '; + $Str .= ''.&mt('Output').' | '; + $Str .= ''. + &Apache::lonstathelpers::limit_by_time_form().' | '; $Str .= '
'."\n"; @@ -232,9 +246,11 @@ sub CreateInterface { $Str .= $html; $Str .= ' |
".&DrawGraph(\@Data,$title,'Problem Number',$yaxis, - $Max)."
\n"); + $r->print("".&Apache::loncommon::DrawBarGraph($title, + 'Problem Number', + $yaxis, + $Max, + undef, # colors + undef, # labels + \@Data)."
\n"); # # Print out the data $ENV{'form.sortby'} = 'Contents'; @@ -747,47 +812,36 @@ sub plot_statistics { return; } -############################################### -############################################### +######################################################## +######################################################## -=pod +=pod -=item &DrawGraph() +=item &get_statistics() -=cut +Wrapper routine from the call to loncoursedata::get_problem_statistics. +Calls lonstathelpers::get_time_limits() to limit the data set by time. -############################################### -############################################### -sub DrawGraph { - my ($values,$title,$xaxis,$yaxis,$Max)=@_; - $title = '' if (! defined($title)); - $xaxis = '' if (! defined($xaxis)); - $yaxis = '' if (! defined($yaxis)); - # - my $sendValues = join(',', @$values); - my $sendCount = scalar(@$values); - $Max =1 if ($Max < 1); - if ( int($Max) < $Max ) { - $Max++; - $Max = int($Max); - } - my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues); - return ''; -} +Inputs: $sequence, $resource, $part, $problem_num +Returns: Hash reference with statistics data from +loncoursedata::get_problem_statistics. + +=cut + +######################################################## +######################################################## sub get_statistics { my ($sequence,$resource,$part,$problem_num) = @_; # + my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); my $symb = $resource->{'symb'}; my $courseid = $ENV{'request.course.id'}; # - my $students = \@Apache::lonstatistics::Students; - if ($Apache::lonstatistics::SelectedSections[0] eq 'all') { - $students = undef; - } my $data = &Apache::loncoursedata::get_problem_statistics - ($students,$symb,$part,$courseid); + (\@Apache::lonstatistics::SelectedSections, + $Apache::lonstatistics::enrollment_status, + $symb,$part,$courseid,$starttime,$endtime); $data->{'part'} = $part; $data->{'problem_num'} = $problem_num; $data->{'container'} = $sequence->{'title'}; @@ -805,6 +859,8 @@ sub get_statistics { =item &ProblemStatisticsLegend() +HELP This needs to be localized, or at least generated automatically. + =cut ###############################################