--- loncom/interface/statistics/lonproblemstatistics.pm 2003/06/02 13:58:43 1.51 +++ loncom/interface/statistics/lonproblemstatistics.pm 2004/02/20 16:38:49 1.68 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.51 2003/06/02 13:58:43 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.68 2004/02/20 16:38:49 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -51,11 +51,20 @@ 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; +## +## 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#', @@ -75,7 +84,8 @@ my @Fields = ( { name => 'part', title => 'Part', align => 'left', - color => '#FFFFE6' }, + color => '#FFFFE6', + }, { name => 'num_students', title => '#Stdnts', align => 'right', @@ -131,12 +141,13 @@ my @Fields = ( format => '%5.2f', sortable => 'yes', graphable => 'yes', - long_title => 'Degree of Difficulty' }, + long_title => 'Degree of Difficulty'. + '[ 1 - ((#YES+#yes) / Tries) ]'}, { name => 'num_solved', 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' }, @@ -144,7 +155,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' }, @@ -155,7 +166,7 @@ my @Fields = ( format => '%4.1f', sortable => 'yes', graphable => 'yes', - long_title => 'Percent Wrong' }, + long_title => 'Percent of students whose final answer is wrong' }, ); ############################################### @@ -172,60 +183,6 @@ select sections, maps, and output. ############################################### ############################################### -sub CreateInterface { - my $Str = ''; - $Str .= '
Sections | '; - $Str .= 'Enrollment Status | '; - $Str .= 'Sequences and Folders | '; - $Str .= 'Output | '; - $Str .= '
'."\n"; - $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); - $Str .= ' | '; - $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); - $Str .= ' | '; - # - my $only_seq_with_assessments = sub { - my $s=shift; - if ($s->{'num_assess'} < 1) { - return 0; - } else { - return 1; - } - }; - $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, - $only_seq_with_assessments); - $Str .= ' | '."\n"; - $Str .= &CreateAndParseOutputSelector(); - $Str .= ' |
'.&mt('Sections').' | '; + $Str .= ''.&mt('Enrollment Status').' | '; + $Str .= ''.&mt('Sequences and Folders').' | '; + $Str .= ''.&mt('Output').' | '; + $Str .= '
'."\n"; + $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); + $Str .= ' | '; + $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); + $Str .= ' | '; # - # Build the form element - $Str = qq/"; - return $Str; -} - -############################################### -############################################### - -=pod - -=item &Gather_Student_Data() - -Ensures all student data is up to date. - -=cut - -############################################### -############################################### -sub Gather_Student_Data { - my ($r) = @_; - my $c = $r->connection(); - # - my @Sequences = &Apache::lonstatistics::Sequences_with_Assess(); - # - my @Students = @Apache::lonstatistics::Students; - # - # Open the progress window - my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin - ($r,'Statistics Compilation Status', - 'Statistics Compilation Progress', scalar(@Students)); - # - while (my $student = shift @Students) { - return if ($c->aborted()); - my ($status,undef) = &Apache::loncoursedata::ensure_current_data - ($student->{'username'},$student->{'domain'}, - $ENV{'request.course.id'}); - &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, - 'last student'); - } - &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); - $r->rflush(); + }; + $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, + $only_seq_with_assessments); + $Str .= ' | '."\n"; + my ($html,$outputmode,$show) = + &Apache::lonstatistics::CreateAndParseOutputSelector( + 'statsoutputmode', + 'HTML problem statistics grouped', + @OutputOptions); + $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'; @@ -845,52 +782,22 @@ sub plot_statistics { return; } -############################################### -############################################### - -=pod - -=item &DrawGraph() - -=cut - -############################################### -############################################### -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 ''; -} - sub get_statistics { my ($sequence,$resource,$part,$problem_num) = @_; # 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); $data->{'part'} = $part; $data->{'problem_num'} = $problem_num; $data->{'container'} = $sequence->{'title'}; $data->{'title'} = $resource->{'title'}; - $data->{'title.link'} = $resource->{'src'}; + $data->{'title.link'} = $resource->{'src'}.'?symb='. + &Apache::lonnet::escape($resource->{'symb'}); # return $data; } @@ -902,6 +809,8 @@ sub get_statistics { =item &ProblemStatisticsLegend() +HELP This needs to be localized, or at least generated automatically. + =cut ###############################################