Diff for /loncom/interface/statistics/lonstudentassessment.pm between versions 1.101 and 1.106

version 1.101, 2004/05/18 17:43:36 version 1.106, 2004/12/07 15:48:29
Line 607  Return a line of the chart for a student Line 607  Return a line of the chart for a student
   
     my $nodata_count; # The number of students for which there is no data      my $nodata_count; # The number of students for which there is no data
     my %prog_state;   # progress state used by loncommon PrgWin routines      my %prog_state;   # progress state used by loncommon PrgWin routines
       my $total_sum_width;
   
 sub html_initialize {  sub html_initialize {
     my ($r) = @_;      my ($r) = @_;
Line 633  sub html_initialize { Line 634  sub html_initialize {
     }      }
     #      #
     # Compute the column widths and output the sequence titles      # Compute the column widths and output the sequence titles
       my $total_count;
     foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()){      foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()){
         #          #
         # Comptue column widths          # Comptue column widths
Line 642  sub html_initialize { Line 644  sub html_initialize {
                 # Use 1 digit for a space                  # Use 1 digit for a space
                 $sequence->{'width_sum'} += 1;                              $sequence->{'width_sum'} += 1;            
             }              }
       $total_count += $sequence->{'num_assess_parts'};
             # Use 3 digits for the sum              # Use 3 digits for the sum
             $sequence->{'width_sum'} += 3;              $sequence->{'width_sum'} += 3;
         }          }
Line 672  sub html_initialize { Line 675  sub html_initialize {
                                       length($sequence->{'title'})                                        length($sequence->{'title'})
                                       ).$padding;                                        ).$padding;
     }      }
     $Str .= "total</pre>\n";      $total_sum_width = length($total_count)+1;
       $Str .= "    total</pre>\n";
     $Str .= "<pre>";      $Str .= "<pre>";
     $r->print($Str);      $r->print($Str);
     $r->rflush();      $r->rflush();
Line 690  sub html_outputstudent { Line 694  sub html_outputstudent {
     my @to_show = &get_student_fields_to_show();      my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {      foreach my $field (@to_show) {
         my $title=$student->{$field};          my $title=$student->{$field};
           # Deal with 'comments' - how I love special cases
           if ($field eq 'comments') {
               $title = '<a href="/adm/'.$student->{'domain'}.'/'.$student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
           }
         my $base = length($title);          my $base = length($title);
         my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};          my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
         $Str .= $title.' 'x($width-$base).$padding;          $Str .= $title.' 'x($width-$base).$padding;
Line 767  sub html_outputstudent { Line 775  sub html_outputstudent {
         $max   += $seq_stats->{'max'};          $max   += $seq_stats->{'max'};
     }      }
     if (! defined($score)) {      if (! defined($score)) {
         $score = ' 'x3;          $score = ' ' x $total_sum_width;
       } else {
           $score = sprintf("%.0f",$score);
     }      }
     $Str .= ' '.' 'x(length($max)-length($score)).$score.'/'.$max;      $Str .= ' '.' 'x($total_sum_width-length($score)).$score.' / '.$max;
     $Str .= " \n";      $Str .= " \n";
     #      #
     $r->print($Str);      $r->print($Str);
Line 795  sub html_finish { Line 805  sub html_finish {
 }  }
   
 sub StudentAverageTotal {  sub StudentAverageTotal {
     my $Str = "<h3>Summary Tables</h3>\n";      my $Str = '<h3>'.&mt('Summary Tables').'</h3>'.$/;
 #    my $max_students;  
 #    my $total_ave = 0;  
 #    my $total_max = 0;  
     $Str .= '<table border=2 cellspacing="1">'."\n";      $Str .= '<table border=2 cellspacing="1">'."\n";
     $Str .= "<tr><th>Title</th><th>Average</th><th>Maximum</th></tr>\n";      $Str .= '<tr>'.
           '<th>'.&mt('Title').'</th>'.
           '<th>'.&mt('Average').'</th>'.
           '<th>'.&mt('Maximum').'</th>'.
           '</tr>'.$/;
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {      foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
         my $ave;          my $ave;
         my $num_students = $Statistics->{$seq->{'symb'}}->{'num_students'};          my $num_students = $Statistics->{$seq->{'symb'}}->{'num_students'};
 #        if ($num_students > $max_students) {  
 #            $max_students = $num_students;  
 #        }  
         if ($num_students > 0) {          if ($num_students > 0) {
             $ave = int(100*              $ave = int(100*
                        ($Statistics->{$seq->{'symb'}}->{'score'}/$num_students)                         ($Statistics->{$seq->{'symb'}}->{'score'}/$num_students)
Line 814  sub StudentAverageTotal { Line 822  sub StudentAverageTotal {
         } else {          } else {
             $ave = 0;              $ave = 0;
         }          }
 #        $total_ave += $ave;  
         my $max = $Statistics->{$seq->{'symb'}}->{'max'};          my $max = $Statistics->{$seq->{'symb'}}->{'max'};
 #        $total_max += $max;  
         $ave = sprintf("%.2f",$ave);          $ave = sprintf("%.2f",$ave);
         $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.          $Str .= '<tr><td>'.$seq->{'title'}.'</td>'.
             '<td align="right">'.$ave.'&nbsp;</td>'.              '<td align="right">'.$ave.'&nbsp;</td>'.
             '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";              '<td align="right">'.$max.'&nbsp;'.'</td></tr>'."\n";
     }      }
 #    $total_ave = sprintf('%.2f',$total_ave); # only two digit  
     $Str .= "</table>\n";      $Str .= "</table>\n";
 #    $Str .= '<table border=2 cellspacing="1">'."\n";  
 #    $Str .= '<tr><th>Number of Students</th><th>Average</th>'.  
 #        "<th>Maximum</th></tr>\n";  
 #    $Str .= '<tr>'.  
 #        '<td align="right">'.$max_students.'</td>'.  
 #        '<td align="right">'.$total_ave.'&nbsp;'.'</td>'.  
 #        '<td align="right">'.$total_max.'&nbsp;'.'</td>';  
 #    $Str .= "</table>\n";  
     return $Str;      return $Str;
 }  }
   
 sub SingleStudentTotal {  sub SingleStudentTotal {
     my $student = &Apache::lonstatistics::current_student();      my $student = &Apache::lonstatistics::current_student();
     my $Str = "<h3>Summary table for ".$student->{'fullname'}." ".      my $Str = '<h3>'.&mt('Summary table for [_1] ([_2]@[_3])',
         $student->{'username'}.'@'.$student->{'domain'}."</h3>\n";                           $student->{'fullname'},
                            $student->{'username'},$student->{'domain'}).'</h3>';
       $Str .= $/;
     $Str .= '<table border=2 cellspacing="1">'."\n";      $Str .= '<table border=2 cellspacing="1">'."\n";
     $Str .=       $Str .= 
         "<tr><th>Sequence or Folder</th><th>Score</th><th>Maximum</th></tr>\n";          '<tr>'.
           '<th>'.&mt('Sequence or Folder').'</th>';
       if ($chosen_output->{'base'} eq 'tries') {
           $Str .= '<th>'.&mt('Parts Correct').'</th>';
       } else {
           $Str .= '<th>'.&mt('Score').'</th>';
       }
       $Str .= '<th>'.&mt('Maximum').'</th>'."</tr>\n";
     my $total = 0;      my $total = 0;
     my $total_max = 0;      my $total_max = 0;
     foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {      foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
Line 853  sub SingleStudentTotal { Line 859  sub SingleStudentTotal {
         $total += $value;          $total += $value;
         $total_max +=$max;          $total_max +=$max;
     }      }
     $Str .= '<tr><td><b>Total</b></td>'.      $Str .= '<tr><td><b>'.&mt('Total').'</b></td>'.
         '<td align="right">'.$total.'</td>'.          '<td align="right">'.$total.'</td>'.
         '<td align="right">'.$total_max."</td></tr>\n";          '<td align="right">'.$total_max."</td></tr>\n";
     $Str .= "</table>\n";      $Str .= "</table>\n";
Line 917  sub excel_initialize { Line 923  sub excel_initialize {
         # Add 2 because we need a 'sequence_sum' and 'total' column for each          # Add 2 because we need a 'sequence_sum' and 'total' column for each
         $total_columns += 2;          $total_columns += 2;
     }      }
       my $too_many_cols_error_message = 
           '<h2>'.&mt('Unable to Complete Request').'</h2>'.$/.
           '<p>'.&mt('LON-CAPA is unable to produce your Excel spreadsheet because your selections will result in more than 255 columns.  Excel allows only 255 columns in a spreadsheet.').'</p>'.$/.
           '<p>'.&mt('You may consider reducing the number of <b>Sequences or Folders</b> you have selected.').'</p>'.$/.
           '<p>'.&mt('LON-CAPA can produce <b>CSV</b> files of this data or Excel files of the <b>Scores Summary</b> data.').'</p>'.$/;
     if ($chosen_output->{'base'} eq 'tries' && $total_columns > 255) {      if ($chosen_output->{'base'} eq 'tries' && $total_columns > 255) {
         $r->print(<<END);          $r->print($too_many_cols_error_message);
 <h2>Unable to Complete Request</h2>          $request_aborted = 1;
 <p>  
 LON-CAPA is unable to produce your Excel spreadsheet because your selections  
 will result in more than 255 columns.  Excel allows only 255 columns in a  
 spreadsheet.  
 </p><p>  
 You may consider reducing the number of <b>Sequences or Folders</b> you  
 have selected.    
 </p><p>  
 LON-CAPA can produce <b>CSV</b> files of this data or Excel files of the  
 summary data (<b>Parts Correct</b> or <b>Parts Correct & Totals</b>).  
 </p>  
 END  
        $request_aborted = 1;  
     }      }
     if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {      if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {
         $r->print(<<END);          $r->print($too_many_cols_error_message);
 <h2>Unable to Complete Request</h2>          $request_aborted = 1;
 <p>  
 LON-CAPA is unable to produce your Excel spreadsheet because your selections  
 will result in more than 255 columns.  Excel allows only 255 columns in a  
 spreadsheet.  
 </p><p>  
 You may consider reducing the number of <b>Sequences or Folders</b> you  
 have selected.    
 </p><p>  
 LON-CAPA can produce <b>CSV</b> files of this data or Excel files of the  
 <b>Scores Summary</b> data.  
 </p>  
 END  
        $request_aborted = 1;  
     }      }
     return if ($request_aborted);      return if ($request_aborted);
     #      #
Line 1079  END Line 1064  END
                                             $cols_output++,                                              $cols_output++,
                                             $res->{'title'}.' part '.$part,                                              $res->{'title'}.' part '.$part,
                                             $format->{'bold'});                                              $format->{'bold'});
                           $count++;
                     }                      }
                 } else {                  } else {
                     $excel_sheet->write($resource_name_row,                      $excel_sheet->write($resource_name_row,
                                         $cols_output++,                                          $cols_output++,
                                         $res->{'title'},$format->{'bold'});                                          $res->{'title'},$format->{'bold'});
                       $count++;
                 }                  }
                 $count++;  
             }              }
         }          }
         # Determine ending cell          # Determine ending cell
Line 1321  sub excel_outputstudent { Line 1307  sub excel_outputstudent {
     # Write out student data      # Write out student data
     my @to_show = &get_student_fields_to_show();      my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {      foreach my $field (@to_show) {
         $excel_sheet->write($rows_output,$cols_output++,$student->{$field});          my $value = $student->{$field};
           if ($field eq 'comments') {
               $value = &Apache::lonmsg::retrieve_instructor_comments
                   ($student->{'username'},$student->{'domain'});
           }
           $excel_sheet->write($rows_output,$cols_output++,$value);
     }      }
     #      #
     # Get student assessment data      # Get student assessment data
Line 1582  sub csv_outputstudent { Line 1573  sub csv_outputstudent {
     # Output student fields      # Output student fields
     my @to_show = &get_student_fields_to_show();      my @to_show = &get_student_fields_to_show();
     foreach my $field (@to_show) {      foreach my $field (@to_show) {
         $Str .= '"'.&Apache::loncommon::csv_translate($student->{$field}).'",';          my $value = $student->{$field};
           if ($field eq 'comments') {
               $value = &Apache::lonmsg::retrieve_instructor_comments
                   ($student->{'username'},$student->{'domain'});
           }        
           $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
     }      }
     #      #
     # Get student assessment data      # Get student assessment data
Line 1768  sub StudentTriesOnSequence { Line 1764  sub StudentTriesOnSequence {
                 }                  }
             }              }
             #              #
             if (! defined($tries)) {              if (! defined($tries) || $symbol eq '.') {
                 $tries = $symbol;                  $tries = $symbol;
             }              }
             push (@TriesData,$tries);              push (@TriesData,$tries);

Removed from v.1.101  
changed lines
  Added in v.1.106


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