Diff for /loncom/interface/statistics/lonstudentassessment.pm between versions 1.43 and 1.50

version 1.43, 2003/03/26 21:42:20 version 1.50, 2003/05/29 21:41:10
Line 85  my $Statistics; Line 85  my $Statistics;
   
 =item $show 'all', 'totals', or 'scores' determines how much data is output  =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  =cut
   
 #######################################################  #######################################################
Line 92  my $Statistics; Line 95  my $Statistics;
 my $show_links;  my $show_links;
 my $output_mode;  my $output_mode;
 my $show;  my $show;
   my $single_student_mode;
   
 #######################################################  #######################################################
 #######################################################  #######################################################
Line 127  Inputs: Line 131  Inputs:
 sub BuildStudentAssessmentPage {  sub BuildStudentAssessmentPage {
     my ($r,$c)=@_;      my ($r,$c)=@_;
     undef($Statistics);      undef($Statistics);
       $single_student_mode = 1 if ($ENV{'form.SelectedStudent'});
     #      #
     # Print out the HTML headers for the interface      # Print out the HTML headers for the interface
     #    This also parses the output mode selector      #    This also parses the output mode selector
     #    This step must always be done.      #    This step must always be done.
     $r->print(&CreateInterface());      $r->print(&CreateInterface());
     $r->print('<input type="hidden" name="notfirstrun" value="true" />');      $r->print('<input type="hidden" name="notfirstrun" value="true" />');
       $r->print('<input type="hidden" name="sort" value="'.
                 $ENV{'form.sort'}.'" />');
     $r->rflush();      $r->rflush();
     if (! exists($ENV{'form.notfirstrun'})) {      if (! exists($ENV{'form.notfirstrun'}) && ! $single_student_mode) {
         $r->print(<<ENDMSG);          $r->print(<<ENDMSG);
 <p>  <p>
 <font size="+1">  <font size="+2">
 Please make your selections in the boxes above and hit   Please make your selections in the boxes above and hit 
 the button marked &quot;Update&nbsp;Display&quot;.  the button marked &quot;Update&nbsp;Display&quot;.
 </font>  </font>
Line 156  ENDMSG Line 163  ENDMSG
         $initialize     = \&excel_initialize;          $initialize     = \&excel_initialize;
         $output_student = \&excel_outputstudent;          $output_student = \&excel_outputstudent;
         $finish         = \&excel_finish;          $finish         = \&excel_finish;
     } elsif ($output_mode eq 'multi-sheet excel') {  #    } elsif ($output_mode eq 'multi-sheet excel') {
         $initialize     = \&multi_sheet_excel_initialize;  #        $initialize     = \&multi_sheet_excel_initialize;
         $output_student = \&multi_sheet_excel_outputstudent;  #        $output_student = \&multi_sheet_excel_outputstudent;
         $finish         = \&multi_sheet_excel_finish;  #        $finish         = \&multi_sheet_excel_finish;
     } elsif ($output_mode eq 'csv') {      } elsif ($output_mode eq 'csv') {
         $initialize     = \&csv_initialize;          $initialize     = \&csv_initialize;
         $output_student = \&csv_outputstudent;          $output_student = \&csv_outputstudent;
Line 168  ENDMSG Line 175  ENDMSG
     #      #
     if($c->aborted()) {  return ; }      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      # Call the initialize routine selected above
     $initialize->($r);      $initialize->($r);
     foreach my $student (@Apache::lonstatistics::Students) {      foreach my $student (@Students) {
         if($c->aborted()) {           if($c->aborted()) { 
             $finish->($r);              $finish->($r);
             return ;               return ; 
Line 186  ENDMSG Line 203  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.('&nbsp;'x5).$all.('&nbsp;'x5).$nextbutton;
       return $Str;
   }
   
   #######################################################
   #######################################################
   
 sub get_student_fields_to_show {  sub get_student_fields_to_show {
     my @to_show = @Apache::lonstatistics::SelectedStudentData;      my @to_show = @Apache::lonstatistics::SelectedStudentData;
Line 224  sub CreateInterface { Line 289  sub CreateInterface {
     $Str .= '<tr>';      $Str .= '<tr>';
     $Str .= '<td align="center"><b>Sections</b></td>';      $Str .= '<td align="center"><b>Sections</b></td>';
     $Str .= '<td align="center"><b>Student Data</b></td>';      $Str .= '<td align="center"><b>Student Data</b></td>';
       $Str .= '<td align="center"><b>Enrollment Status</b></td>';
     $Str .= '<td align="center"><b>Sequences and Folders</b></td>';      $Str .= '<td align="center"><b>Sequences and Folders</b></td>';
     $Str .= '<td align="center"><b>Output Format</b></td>';      $Str .= '<td align="center"><b>Output Format</b></td>';
     $Str .= '</tr>'."\n";      $Str .= '</tr>'."\n";
Line 242  sub CreateInterface { Line 308  sub CreateInterface {
     $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',      $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',
                                                       5,undef);                                                        5,undef);
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
       $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
       $Str .= '</td><td>'."\n";
     $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,      $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
                                               $only_seq_with_assessments);                                                $only_seq_with_assessments);
     $Str .= '</td><td>'."\n";      $Str .= '</td><td>'."\n";
Line 271  my @OutputOptions = Line 339  my @OutputOptions =
        show => 'all',         show => 'all',
        show_links => 'yes',         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 => 'all',
          show_links => 'all',
          },
      { name  => 'HTML, without links',       { name  => 'HTML, without links',
        value => 'html, without links',         value => 'html, without links',
        description => 'Output HTML.  By not including links, the size of the'.         description => 'Output HTML.  By not including links, the size of the'.
Line 323  my @OutputOptions = Line 400  my @OutputOptions =
        show => 'totals',         show => 'totals',
        show_links => 'no',         show_links => 'no',
            },             },
      { name  => 'multi-sheet Excel',  #     { name  => 'multi-sheet Excel',
        value => 'multi-sheet excel',  #       value => 'multi-sheet excel',
        description => 'Output an Excel file (compatable with Excel 95), '.  #       description => 'Output an Excel file (compatable with Excel 95), '.
    'with a seperate worksheet for each sequence you have selected '.  #   'with a seperate worksheet for each sequence you have selected '.
            'the data for each problem part '.  #           'the data for each problem part '.
            '(number of tries, status, points awarded) will be listed.',  #           '(number of tries, status, points awarded) will be listed.',
        mode => 'multi-sheet excel',  #       mode => 'multi-sheet excel',
        show => 'totals',  #       show => 'totals',
        show_links => 'no',  #       show_links => 'no',
            },  #           },
      { name  => 'multi-sheet Excel, by section',  #     { name  => 'multi-sheet Excel, by section',
        value => 'multi-sheet excel, by section',  #       value => 'multi-sheet excel, by section',
        description => 'Output an Excel file (compatable with Excel 95), '.  #       description => 'Output an Excel file (compatable with Excel 95), '.
    'with a seperate worksheet for each sequence you have selected '.  #   'with a seperate worksheet for each sequence you have selected '.
            'the data for each problem part '.  #           'the data for each problem part '.
            '(number of tries, status, points awarded) will be listed.  '.  #           '(number of tries, status, points awarded) will be listed.  '.
            'There will be one Excel workbook for each section selected.',  #           'There will be one Excel workbook for each section selected.',
        mode => 'multi-sheet excel',  #       mode => 'multi-sheet excel',
        show => 'by section',  #       show => 'by section',
        show_links => 'no',  #       show_links => 'no',
            },  #           },
      { name  => 'CSV, everything',       { name  => 'CSV, everything',
        value => 'csv, everything',         value => 'csv, everything',
        description => '',         description => '',
Line 381  sub OutputDescriptions { Line 458  sub OutputDescriptions {
   
 sub CreateAndParseOutputSelector {  sub CreateAndParseOutputSelector {
     my $Str = '';      my $Str = '';
     my $elementname = 'outputmode';      my $elementname = 'chartoutputmode';
     #      #
     # Format for output options is 'mode, restrictions';      # Format for output options is 'mode, restrictions';
     my $selected = 'html, with links';      my $selected = 'html, without links';
     if (exists($ENV{'form.'.$elementname})) {      if (exists($ENV{'form.'.$elementname})) {
         if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {          if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
             $selected = $ENV{'form.'.$elementname}->[0];              $selected = $ENV{'form.'.$elementname}->[0];
Line 583  sub html_finish { Line 660  sub html_finish {
     } else {      } else {
         $r->print("</pre>\n");           $r->print("</pre>\n"); 
     }      }
     $r->print(&StudentAverageTotal());      if ($single_student_mode) {
           $r->print(&SingleStudentTotal());
       } else {
           $r->print(&StudentAverageTotal());
       }
     $r->rflush();      $r->rflush();
     return;      return;
 }  }
Line 626  sub StudentAverageTotal { Line 707  sub StudentAverageTotal {
     return $Str;      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;
   }
   
 }  }
   
 #######################################################  #######################################################
Line 822  sub excel_initialize { Line 928  sub excel_initialize {
         $rows_output += 1;          $rows_output += 1;
     }      }
     #      #
       # Output a row for MAX
       if ($show ne 'totals') {
           $cols_output = 0;
           foreach my $field (&get_student_fields_to_show()) {
               if ($field eq 'username' || $field eq 'fullname' || 
                   $field eq 'id') {
                   $excel_sheet->write($rows_output,$cols_output++,'Maximum');
               } else {
                   $excel_sheet->write($rows_output,$cols_output++,'');
               }
           }
           #
           # Add the Sequence Headers
           foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
               $excel_sheet->write($rows_output,$cols_output++,
                                   $seq->{'num_assess_parts'});
           }
           $rows_output++;
       }
       #
     # Let the user know what we are doing      # Let the user know what we are doing
     my $studentcount = scalar(@Apache::lonstatistics::Students);       my $studentcount = scalar(@Apache::lonstatistics::Students); 
     $r->print("<h1>Compiling Excel spreadsheet for ".      $r->print("<h1>Compiling Excel spreadsheet for ".
Line 1141  sub StudentPerformanceOnSequence { Line 1267  sub StudentPerformanceOnSequence {
                 }                  }
             }              }
             #              #
             if ($links eq 'yes' && $symbol ne ' ') {              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'.                  $symbol = '<a href="/adm/grades'.
                     '?symb='.&Apache::lonnet::escape($resource->{'symb'}).                      '?symb='.&Apache::lonnet::escape($resource->{'symb'}).
                         '&student='.$student->{'username'}.                          '&student='.$student->{'username'}.

Removed from v.1.43  
changed lines
  Added in v.1.50


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>