--- loncom/interface/statistics/lonstudentassessment.pm 2003/03/07 17:01:45 1.39 +++ loncom/interface/statistics/lonstudentassessment.pm 2009/05/17 23:13:49 1.155 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentassessment.pm,v 1.39 2003/03/07 17:01:45 matthew Exp $ +# $Id: lonstudentassessment.pm,v 1.155 2009/05/17 23:13:49 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,11 +50,20 @@ Presents assessment data about a student package Apache::lonstudentassessment; use strict; -use Apache::lonstatistics; -use Apache::lonhtmlcommon; +use Apache::lonstatistics(); +use Apache::lonhtmlcommon(); +use Apache::loncommon(); use Apache::loncoursedata; use Apache::lonnet; # for logging porpoises +use Apache::lonlocal; +use Apache::grades(); +use Apache::lonmsgdisplay(); +use Time::HiRes; use Spreadsheet::WriteExcel; +use Spreadsheet::WriteExcel::Utility(); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + ####################################################### ####################################################### @@ -85,13 +94,17 @@ my $Statistics; =item $show 'all', 'totals', or 'scores' determines how much data is output +=item $single_student_mode evaluates to true if we are showing only one +student. + =cut ####################################################### ####################################################### my $show_links; my $output_mode; -my $show; +my $chosen_output; +my $single_student_mode; ####################################################### ####################################################### @@ -126,27 +139,49 @@ 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', + 'Groups' => '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'}); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['selectstudent']); + 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'})) { - $r->print(< - -Please make your selections in the boxes above and hit -the button marked "Update Display". - -

-ENDMSG -# $r->print(&OutputDescriptions()); + # + if (! exists($env{'form.notfirstrun'}) && ! $single_student_mode) { return; } - # + $r->print('

'. + &Apache::lonstatistics::section_and_enrollment_description(). + '

'); # my $initialize = \&html_initialize; my $output_student = \&html_outputstudent; @@ -156,10 +191,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; @@ -168,9 +199,29 @@ ENDMSG # if($c->aborted()) { return ; } # + # Determine which students we want to look at + my @Students; + if ($single_student_mode) { + @Students = (&Apache::lonstatistics::current_student()); + $r->print(&next_and_previous_buttons()); + $r->rflush(); + } else { + @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 (@Apache::lonstatistics::Students) { + foreach my $student (@Students) { if($c->aborted()) { $finish->($r); return ; @@ -186,6 +237,54 @@ ENDMSG ####################################################### ####################################################### +sub next_and_previous_buttons { + my $Str = ''; + $Str .= ''; + # + # Build the previous student link + my $previous = &Apache::lonstatistics::previous_student(); + my $previousbutton = ''; + if (defined($previous)) { + my $sname = $previous->{'username'}.':'.$previous->{'domain'}; + $previousbutton .= ''; + } else { + $previousbutton .= ''; + } + # + # Build the next student link + my $next = &Apache::lonstatistics::next_student(); + my $nextbutton = ''; + if (defined($next)) { + my $sname = $next->{'username'}.':'.$next->{'domain'}; + $nextbutton .= ''; + } else { + $nextbutton .= ''; + } + # + # Build the 'all students' button + my $all = ''; + $all .= ''; + $Str .= $previousbutton.(' 'x5).$all.(' 'x5).$nextbutton; + return $Str; +} + +####################################################### +####################################################### sub get_student_fields_to_show { my @to_show = @Apache::lonstatistics::SelectedStudentData; @@ -198,19 +297,6 @@ sub get_student_fields_to_show { return @to_show; } -sub get_sequences_to_show { - my @Sequences; - foreach my $map_symb (@Apache::lonstatistics::SelectedMaps) { - foreach my $sequence (@Apache::lonstatistics::Sequences) { - next if ($sequence->{'symb'} ne $map_symb && $map_symb ne 'all'); - next if ($sequence->{'num_assess'} < 1); - push (@Sequences,$sequence); - } - } - return @Sequences; -} - - ####################################################### ####################################################### @@ -232,35 +318,62 @@ the chart page. ####################################################### sub CreateInterface { my $Str = ''; + $Str .= &Apache::lonhtmlcommon::breadcrumbs('Chart','Chart_Description:Chart_Sections:Chart_Student_Data:Chart_Enrollment_Status:Chart_Sequences:Chart_Output_Formats:Chart_Output_Data'); # $Str .= &CreateLegend(); $Str .= ''."\n"; $Str .= ''; - $Str .= ''; - $Str .= ''; - $Str .= ''; - $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; + $Str .= ''; $Str .= ''."\n"; # $Str .= ''."\n"; $Str .= '
SectionsStudent DataProblem SetsOutput Format'.&mt('Sections').''. + &Apache::loncommon::help_open_topic("Chart_Sections"). + ''.&mt('Groups').''. + ''.&mt('Student Data'). + &Apache::loncommon::help_open_topic("Chart_Student_Data"). + ''.&mt('Access Status').''. + &Apache::loncommon::help_open_topic("Chart_Enrollment_Status"). + ''.&mt('Sequences and Folders').''. + &Apache::loncommon::help_open_topic("Chart_Sequences"). + ''.&mt('Output Format').''. + &Apache::loncommon::help_open_topic("Chart_Output_Formats"). + ''.&mt('Output Data').''. + &Apache::loncommon::help_open_topic("Chart_Output_Data"). + '
'."\n"; $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); $Str .= ''; - my $only_seq_with_assessments = sub { - my $s=shift; - if ($s->{'num_assess'} < 1) { - return 0; - } else { - return 1; - } - }; + $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5); + $Str .= ''; $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple', 5,undef); $Str .= ''."\n"; - $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, - $only_seq_with_assessments); + $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); + $Str .= ''."\n"; + $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5); $Str .= ''."\n"; $Str .= &CreateAndParseOutputSelector(); + $Str .= ''."\n"; + $Str .= &CreateAndParseOutputDataSelector(); $Str .= '
'."\n"; + $Str .= ''; + $Str .= ' 'x5; + $Str .= ''; + $Str .= ' 'x5; + $Str .= ''; + $Str .= '

'; + $Str .= + &mt('Status [_1]', + ''); + $Str .= '

'; return $Str; } @@ -281,108 +394,44 @@ 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', + value => 'html, with all links', + description => 'Output HTML with each symbol linked to the problem '. + 'which generated it. '. + 'This includes links for unattempted problems.', + mode => 'html', + show_links => 'all', + }, { name => 'HTML, without links', value => 'html, without links', description => 'Output HTML. By not including links, the size of the'. ' 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.', - 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', + { name => 'Excel', + value => 'excel', + description => 'Output an Excel file (compatable with Excel 95).', 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 separated 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"; @@ -394,26 +443,21 @@ sub OutputDescriptions { sub CreateAndParseOutputSelector { my $Str = ''; - my $elementname = 'outputmode'; + my $elementname = 'chartoutputmode'; + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + [$elementname]); # # Format for output options is 'mode, restrictions'; - my $selected = 'html, with links'; - if (exists($ENV{'form.'.$elementname})) { - if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) { - $selected = $ENV{'form.'.$elementname}->[0]; - } else { - $selected = $ENV{'form.'.$elementname}; - } - } + my $selected = (&Apache::loncommon::get_env_multiple('form.'.$elementname))[0]; + $selected = 'html, without links' if (!$selected); + # # 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'}; } @@ -423,12 +467,150 @@ sub CreateAndParseOutputSelector { foreach my $option (@OutputOptions) { $Str .= "\n".'