--- loncom/interface/statistics/lonstudentassessment.pm 2003/05/13 15:00:42 1.47 +++ loncom/interface/statistics/lonstudentassessment.pm 2003/05/29 21:38:32 1.49 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentassessment.pm,v 1.47 2003/05/13 15:00:42 matthew Exp $ +# $Id: lonstudentassessment.pm,v 1.49 2003/05/29 21:38:32 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -85,6 +85,9 @@ 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 ####################################################### @@ -92,6 +95,7 @@ my $Statistics; my $show_links; my $output_mode; my $show; +my $single_student_mode; ####################################################### ####################################################### @@ -127,17 +131,20 @@ Inputs: sub BuildStudentAssessmentPage { my ($r,$c)=@_; undef($Statistics); + $single_student_mode = 1 if ($ENV{'form.SelectedStudent'}); # # Print out the HTML headers for the interface # This also parses the output mode selector # This step must always be done. $r->print(&CreateInterface()); $r->print('<input type="hidden" name="notfirstrun" value="true" />'); + $r->print('<input type="hidden" name="sort" value="'. + $ENV{'form.sort'}.'" />'); $r->rflush(); - if (! exists($ENV{'form.notfirstrun'})) { + if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) { $r->print(<<ENDMSG); <p> -<font size="+1"> +<font size="+2"> Please make your selections in the boxes above and hit the button marked "Update Display". </font> @@ -156,10 +163,10 @@ 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 '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 +175,19 @@ 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; + } + # # 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 +203,54 @@ ENDMSG ####################################################### ####################################################### +sub next_and_previous_buttons { + my $Str = ''; + $Str .= '<input type="hidden" name="SelectedStudent" value="'. + $ENV{'form.SelectedStudent'}.'" />'; + # + # Build the previous student link + my $previous = &Apache::lonstatistics::previous_student(); + my $previousbutton = ''; + if (defined($previous)) { + my $sname = $previous->{'username'}.':'.$previous->{'domain'}; + $previousbutton .= '<input type="button" value="'. + 'Previous Student ('. + $previous->{'username'}.'@'.$previous->{'domain'}.')'. + '" onclick="document.Statistics.SelectedStudent.value='. + "'".$sname."'".';'. + 'document.Statistics.submit();" />'; + } else { + $previousbutton .= '<input type="button" value="'. + 'Previous student (none)'.'" />'; + } + # + # Build the next student link + my $next = &Apache::lonstatistics::next_student(); + my $nextbutton = ''; + if (defined($next)) { + my $sname = $next->{'username'}.':'.$next->{'domain'}; + $nextbutton .= '<input type="button" value="'. + 'Next Student ('. + $next->{'username'}.'@'.$next->{'domain'}.')'. + '" onclick="document.Statistics.SelectedStudent.value='. + "'".$sname."'".';'. + 'document.Statistics.submit();" />'; + } else { + $nextbutton .= '<input type="button" value="'. + 'Next student (none)'.'" />'; + } + # + # Build the 'all students' button + my $all = ''; + $all .= '<input type="button" value="All Students" '. + '" onclick="document.Statistics.SelectedStudent.value='. + "''".';'.'document.Statistics.submit();" />'; + $Str .= $previousbutton.(' 'x5).$all.(' 'x5).$nextbutton; + return $Str; +} + +####################################################### +####################################################### sub get_student_fields_to_show { my @to_show = @Apache::lonstatistics::SelectedStudentData; @@ -335,27 +400,27 @@ my @OutputOptions = 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 => '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 => '', @@ -595,7 +660,11 @@ sub html_finish { } else { $r->print("</pre>\n"); } - $r->print(&StudentAverageTotal()); + if ($single_student_mode) { + $r->print(&SingleStudentTotal()); + } else { + $r->print(&StudentAverageTotal()); + } $r->rflush(); return; } @@ -638,6 +707,31 @@ sub StudentAverageTotal { return $Str; } +sub SingleStudentTotal { + my $student = &Apache::lonstatistics::current_student(); + my $Str = "<h3>Summary Table For ".$student->{'username'}.'@'. + $student->{'domain'}."</h3>\n"; + $Str .= '<table border=2 cellspacing="1">'."\n"; + $Str .= + "<tr><th>Sequence or Folder</th><th>Score</th><th>Maximum</th></tr>\n"; + my $total = 0; + my $total_max = 0; + foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { + my $value = $Statistics->{$seq->{'symb'}}->{'score'}; + my $max = $Statistics->{$seq->{'symb'}}->{'max'}; + $Str .= '<tr><td>'.$seq->{'title'}.'</td>'. + '<td align="right">'.$value.'</td>'. + '<td align="right">'.$max.'</td></tr>'."\n"; + $total += $value; + $total_max +=$max; + } + $Str .= '<tr><td><b>Total</b></td>'. + '<td align="right">'.$total.'</td>'. + '<td align="right">'.$total_max."</td></tr>\n"; + $Str .= "</table>\n"; + return $Str; +} + } ####################################################### @@ -1175,6 +1269,9 @@ sub StudentPerformanceOnSequence { # if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) { + if (length($symbol) > 1) { + &Apache::lonnet::logthis('length of symbol "'.$symbol.'" > 1'); + } $symbol = '<a href="/adm/grades'. '?symb='.&Apache::lonnet::escape($resource->{'symb'}). '&student='.$student->{'username'}.