--- loncom/interface/statistics/lonproblemstatistics.pm 2003/08/27 21:33:33 1.56 +++ loncom/interface/statistics/lonproblemstatistics.pm 2003/08/29 21:11:25 1.57 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.56 2003/08/27 21:33:33 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.57 2003/08/29 21:11:25 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -174,6 +174,29 @@ select sections, maps, and output. ############################################### ############################################### +my @OutputOptions = + ( + { name => 'problem statistics grouped by sequence', + value => 'HTML problem statistics grouped', + description => 'Output statistics for the problem parts.', + mode => 'html', + show => 'grouped', + }, + { name => 'problem statistics ungrouped', + value => 'HTML problem statistics ungrouped', + description => 'Output statistics for the problem parts.', + mode => 'html', + show => 'ungrouped', + }, + { name => 'problem statistics, Excel', + value => 'Excel problem statistics', + description => 'Output statistics for the problem parts '. + 'in an Excel workbook', + mode => 'excel', + show => 'all', + }, + ); + sub CreateInterface { my $Str = ''; $Str .= ''."\n"; @@ -201,108 +224,19 @@ sub CreateInterface { $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, $only_seq_with_assessments); $Str .= ''."\n"; $Str .= '
'."\n"; - $Str .= &CreateAndParseOutputSelector(); + my ($html,$outputmode,$show) = + &Apache::lonstatistics::CreateAndParseOutputSelector( + 'statsoutputmode', + 'HTML problem statistics grouped', + @OutputOptions); + $Str .= $html; $Str .= '
'."\n"; $Str .= ''; $Str .= ' 'x5; $Str .= ''; $Str .= ' 'x5; - return $Str; -} - -####################################################### -####################################################### - -=pod - -=item &CreateAndParseOutputSelector() - -Construct a selection list of options for output and parse output selections. -The current output selected is indicated by the values of the two package -variables $output_mode and $show. @OutputOptions holds the descriptions of -the output options and the values for $output_mode and $show. - -Based on code from lonstudentassessment.pm. - -=cut - -####################################################### -####################################################### -my $output_mode; -my $show; - -my @OutputOptions = - ( - { name => 'problem statistics grouped by sequence', - value => 'HTML problem statistics grouped', - description => 'Output statistics for the problem parts.', - mode => 'html', - show => 'grouped', - }, - { name => 'problem statistics ungrouped', - value => 'HTML problem statistics ungrouped', - description => 'Output statistics for the problem parts.', - mode => 'html', - show => 'ungrouped', - }, - { name => 'problem statistics, Excel', - value => 'Excel problem statistics', - description => 'Output statistics for the problem parts '. - 'in an Excel workbook', - mode => 'excel', - show => 'all', - }, - ); - -sub OutputDescriptions { - my $Str = ''; - $Str .= "

Output Modes

\n"; - $Str .= "
\n"; - foreach my $outputmode (@OutputOptions) { - $Str .="
".$outputmode->{'name'}."
\n"; - $Str .="
".$outputmode->{'description'}."
\n"; - } - $Str .= "
\n"; - return $Str; -} - -sub CreateAndParseOutputSelector { - my $Str = ''; - my $elementname = 'statsoutputmode'; - # - # Format for output options is 'mode, restrictions'; - my $selected = 'HTML problem statistics grouped'; - if (exists($ENV{'form.'.$elementname})) { - if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { - $selected = $ENV{'form.'.$elementname}->[0]; - } else { - $selected = $ENV{'form.'.$elementname}; - } - } - # - # Set package variables describing output mode - $output_mode = 'html'; - $show = 'all'; - foreach my $option (@OutputOptions) { - next if ($option->{'value'} ne $selected); - $output_mode = $option->{'mode'}; - $show = $option->{'show'}; - } - # - # Build the form element - $Str = qq/"; - return $Str; + return ($Str,$outputmode,$show); } ############################################### @@ -321,10 +255,8 @@ Main interface to problem statistics. sub BuildProblemStatisticsPage { my ($r,$c)=@_; # - $output_mode = 'html'; - $show = 'grouped'; - # - $r->print(&CreateInterface()); + my ($interface,$output_mode,$show) = &CreateInterface(); + $r->print($interface); $r->print(''); $r->print('');