--- loncom/interface/statistics/lonstudentassessment.pm 2003/05/29 21:41:10 1.50 +++ loncom/interface/statistics/lonstudentassessment.pm 2004/02/12 21:15:47 1.90 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentassessment.pm,v 1.50 2003/05/29 21:41:10 matthew Exp $ +# $Id: lonstudentassessment.pm,v 1.90 2004/02/12 21:15:47 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,9 +52,12 @@ package Apache::lonstudentassessment; use strict; use Apache::lonstatistics; use Apache::lonhtmlcommon; +use Apache::loncommon(); use Apache::loncoursedata; use Apache::lonnet; # for logging porpoises +use Apache::lonlocal; use Spreadsheet::WriteExcel; +use Spreadsheet::WriteExcel::Utility(); ####################################################### ####################################################### @@ -94,7 +97,7 @@ student. ####################################################### my $show_links; my $output_mode; -my $show; +my $chosen_output; my $single_student_mode; ####################################################### @@ -130,31 +133,44 @@ Inputs: ####################################################### sub BuildStudentAssessmentPage { my ($r,$c)=@_; + # undef($Statistics); + undef($show_links); + undef($output_mode); + undef($chosen_output); + undef($single_student_mode); + # + my %Saveable_Parameters = ('Status' => 'scalar', + 'chartoutputmode' => 'scalar', + 'chartoutputdata' => 'scalar', + 'Section' => 'array', + 'StudentData' => 'array', + 'Maps' => 'array'); + &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters); + &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters); + # + &Apache::lonstatistics::PrepareClasslist(); + # + $single_student_mode = 0; $single_student_mode = 1 if ($ENV{'form.SelectedStudent'}); + if ($ENV{'form.selectstudent'}) { + &Apache::lonstatistics::DisplayClasslist($r); + return; + } # # Print out the HTML headers for the interface # This also parses the output mode selector - # This step must always be done. + # This step must *always* be done. $r->print(&CreateInterface()); $r->print(''); $r->print(''); $r->rflush(); + # if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) { - $r->print(< - -Please make your selections in the boxes above and hit -the button marked "Update Display". - -

-ENDMSG -# $r->print(&OutputDescriptions()); return; } # - # my $initialize = \&html_initialize; my $output_student = \&html_outputstudent; my $finish = \&html_finish; @@ -163,10 +179,6 @@ ENDMSG $initialize = \&excel_initialize; $output_student = \&excel_outputstudent; $finish = \&excel_finish; -# } elsif ($output_mode eq 'multi-sheet excel') { -# $initialize = \&multi_sheet_excel_initialize; -# $output_student = \&multi_sheet_excel_outputstudent; -# $finish = \&multi_sheet_excel_finish; } elsif ($output_mode eq 'csv') { $initialize = \&csv_initialize; $output_student = \&csv_outputstudent; @@ -185,6 +197,16 @@ ENDMSG @Students = @Apache::lonstatistics::Students; } # + # Perform generic initialization tasks + # Since we use lonnet::EXT to retrieve problem weights, + # to ensure current data we must clear the caches out. + # This makes sure that parameter changes at the student level + # are immediately reflected in the chart. + &Apache::lonnet::clear_EXT_cache_status(); + # + # Clean out loncoursedata's package data, just to be safe. + &Apache::loncoursedata::clear_internal_caches(); + # # Call the initialize routine selected above $initialize->($r); foreach my $student (@Students) { @@ -287,11 +309,16 @@ sub CreateInterface { # $Str .= &CreateLegend(); $Str .= ''."\n"; $Str .= ''; - $Str .= ''; - $Str .= ''; - $Str .= ''; - $Str .= ''; - $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; $Str .= ''."\n"; # $Str .= ''."\n"; $Str .= '
SectionsStudent DataEnrollment StatusSequences and FoldersOutput Format'.&mt('Sections').''.&mt('Student Data').''.&mt('Enrollment Status').''.&mt('Sequences and Folders').''.&mt('Output Format').''. + &Apache::loncommon::help_open_topic("Chart_Output_Formats"). + ''.&mt('Output Data').''. + &Apache::loncommon::help_open_topic("Chart_Output_Data"). + '
'."\n"; @@ -314,8 +341,20 @@ sub CreateInterface { $only_seq_with_assessments); $Str .= ''."\n"; $Str .= &CreateAndParseOutputSelector(); + $Str .= ''."\n"; + $Str .= &CreateAndParseOutputDataSelector(); $Str .= '
'."\n"; + $Str .= ''; + $Str .= ' 'x5; + $Str .= ''; + $Str .= ' 'x5; + $Str .= ''; + $Str .= ' 'x5; + $Str .= '
'; return $Str; } @@ -336,7 +375,6 @@ my @OutputOptions = description => 'Output HTML with each symbol linked to the problem '. 'which generated it.', mode => 'html', - show => 'all', show_links => 'yes', }, { name => 'HTML, with all links', @@ -345,7 +383,6 @@ my @OutputOptions = 'which generated it. '. 'This includes links for unattempted problems.', mode => 'html', - show => 'all', show_links => 'all', }, { name => 'HTML, without links', @@ -354,99 +391,28 @@ my @OutputOptions = ' web page is greatly reduced. If your browser crashes on the '. 'full display, try this.', mode => 'html', - show => 'all', show_links => 'no', }, - { name => 'HTML, scores only', - value => 'html, scores only', - description => 'Output HTML, only showing the total number of correct'. - ' problems (or problem parts) and not the maximum possible for '. - 'each student', - mode => 'html', - show => 'scores', - show_links => 'no', - }, - { name => 'HTML, totals', - value => 'html, totals', - description => 'Output HTML, but only the summary statistics for each'. - ' sequence selected for each student.', - mode => 'html', - show => 'totals', - show_links => 'no', - }, - { name => 'HTML, summary table only', - value => 'html summary table only', - description => 'Output HTML, but only the final summary table for '. - 'all students across all sequences.', - mode => 'html', - show => 'final table', - show_links => 'no', - }, - { name => 'Excel, scores only', - value => 'excel, scores only', - description => 'Output an Excel file (compatable with Excel 95), '. - 'with a single column for each sequence showing the students '. - 'score.', + { name => 'Excel', + value => 'excel', + description => 'Output an Excel file (compatable with Excel 95).', mode => 'excel', - show => 'scores', show_links => 'no', - }, - { name => 'Excel, totals', - value => 'excel, totals', - description => 'Output an Excel file (compatable with Excel 95), '. - 'with two columns for each sequence, the students score on the '. - 'sequence and the students maximum possible on the sequence', - mode => 'excel', - show => 'totals', - show_links => 'no', - }, -# { name => 'multi-sheet Excel', -# value => 'multi-sheet excel', -# description => 'Output an Excel file (compatable with Excel 95), '. -# 'with a seperate worksheet for each sequence you have selected '. -# 'the data for each problem part '. -# '(number of tries, status, points awarded) will be listed.', -# mode => 'multi-sheet excel', -# show => 'totals', -# show_links => 'no', -# }, -# { name => 'multi-sheet Excel, by section', -# value => 'multi-sheet excel, by section', -# description => 'Output an Excel file (compatable with Excel 95), '. -# 'with a seperate worksheet for each sequence you have selected '. -# 'the data for each problem part '. -# '(number of tries, status, points awarded) will be listed. '. -# 'There will be one Excel workbook for each section selected.', -# mode => 'multi-sheet excel', -# show => 'by section', -# show_links => 'no', -# }, - { name => 'CSV, everything', - value => 'csv, everything', - description => '', - mode => 'csv', - show => 'all', - show_links => 'no', - }, - { name => 'CSV, scores only', - value => 'csv, scores only', - description => '', - mode => 'csv', - show => 'scores', - show_links => 'no', - }, - { name => 'CSV, totals', - value => 'csv, totals', - description => '', + }, + { name => 'CSV', + value => 'csv', + description => 'Output a comma seperated values file suitable for '. + 'import into a spreadsheet program. Using this method as opposed '. + 'to Excel output allows you to organize your data before importing'. + ' it into a spreadsheet program.', mode => 'csv', - show => 'totals', show_links => 'no', }, ); sub OutputDescriptions { my $Str = ''; - $Str .= "

Output Modes

\n"; + $Str .= "

Output Formats

\n"; $Str .= "
\n"; foreach my $outputmode (@OutputOptions) { $Str .="
".$outputmode->{'name'}."
\n"; @@ -459,6 +425,8 @@ sub OutputDescriptions { sub CreateAndParseOutputSelector { my $Str = ''; my $elementname = 'chartoutputmode'; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + [$elementname]); # # Format for output options is 'mode, restrictions'; my $selected = 'html, without links'; @@ -473,11 +441,9 @@ sub CreateAndParseOutputSelector { # Set package variables describing output mode $show_links = 'no'; $output_mode = 'html'; - $show = 'all'; foreach my $option (@OutputOptions) { next if ($option->{'value'} ne $selected); $output_mode = $option->{'mode'}; - $show = $option->{'show'}; $show_links = $option->{'show_links'}; } @@ -487,10 +453,124 @@ sub CreateAndParseOutputSelector { foreach my $option (@OutputOptions) { $Str .= "\n".'