Diff for /loncom/interface/spreadsheet/studentcalc.pm between versions 1.22 and 1.24

version 1.22, 2003/09/18 20:12:40 version 1.24, 2003/11/17 19:55:41
Line 58  use Apache::Spreadsheet(); Line 58  use Apache::Spreadsheet();
 use Apache::assesscalc();  use Apache::assesscalc();
 use HTML::Entities();  use HTML::Entities();
 use Time::HiRes;  use Time::HiRes;
   use Apache::lonlocal;
   
 @Apache::studentcalc::ISA = ('Apache::Spreadsheet');  @Apache::studentcalc::ISA = ('Apache::Spreadsheet');
   
Line 118  sub get_title { Line 119  sub get_title {
   
     push (@title,$name);      push (@title,$name);
     push (@title,$self->{'coursedesc'});      push (@title,$self->{'coursedesc'});
     push (@title,scalar(localtime(time)));      push (@title,&Apache::lonlocal::locallocaltime(time));
     return @title;      return @title;
 }  }
   
Line 140  sub get_html_title { Line 141  sub get_html_title {
   
 sub parent_link {  sub parent_link {
     my $self = shift;      my $self = shift;
     return '<p><a href="/adm/classcalc">Course level sheet</a></p>'."\n";      return '<p><a href="/adm/classcalc">'.&mt('Course level sheet').'</a></p>'."\n";
 }  }
   
 sub convenience_links {  sub convenience_links {
Line 173  sub outsheet_html { Line 174  sub outsheet_html {
     my $editing_is_allowed = &Apache::lonnet::allowed('mgr',      my $editing_is_allowed = &Apache::lonnet::allowed('mgr',
                                                 $ENV{'request.course.id'});                                                  $ENV{'request.course.id'});
     ####################################      ####################################
       # Report any calculation errors    #
       ####################################
       $r->print($self->html_report_error());
       ####################################
     # Determine table structure        #      # Determine table structure        #
     ####################################      ####################################
     my $num_uneditable = 26;      my $num_uneditable = 26;
     my $num_left = 52-$num_uneditable;      my $num_left = 52-$num_uneditable;
       my %lt=&Apache::lonlocal::texthash(
          'st' => 'Student',
          'im' => 'Import',
          'ca' => 'Calculations',
          'as' => 'Assessment',
          'ro' => 'Row',
          );
     my $tableheader =<<"END";      my $tableheader =<<"END";
 <p>  <p>
 <table border="2">  <table border="2">
 <tr>  <tr>
   <th colspan="2" rowspan="2"><font size="+2">Student</font></th>    <th colspan="2" rowspan="2"><font size="+2">$lt{'st'}</font></th>
   <td bgcolor="$importcolor" colspan="$num_uneditable">    <td bgcolor="$importcolor" colspan="$num_uneditable">
       <b><font size="+1">Import</font></b></td>        <b><font size="+1">$lt{'im'}</font></b></td>
   <td colspan="$num_left">    <td colspan="$num_left">
       <b><font size="+1">Calculations</font></b></td>        <b><font size="+1">$lt{'ca'}</font></b></td>
 </tr><tr>  </tr><tr>
 END  END
     my $label_num = 0;      my $label_num = 0;
Line 201  END Line 213  END
     $tableheader .="</tr>\n";      $tableheader .="</tr>\n";
     if ($self->blackout()) {      if ($self->blackout()) {
         $r->print('<font color="red" size="+2"><p>'.          $r->print('<font color="red" size="+2"><p>'.
                   'Some computations are not available at this time.<br />'.                    &mt('Some computations are not available at this time.').'<br />'.
                   'There are problems whose status you are allowed to view.'.                    &mt('There are problems whose status you are not allowed to view.').
                   '</font></p>'."\n");                    '</font></p>'."\n");
     } else {      } else {
         $r->print($tableheader);          $r->print($tableheader);
Line 215  END Line 227  END
         }          }
         #          #
         # Print out summary/export row          # Print out summary/export row
         $r->print('<tr><td>Summary</td><td>0</td>'.          $r->print('<tr><td>'.&mt('Summary').'</td><td>0</td>'.
                   $self->html_export_row($exportcolor)."</tr>\n");                    $self->html_export_row($exportcolor)."</tr>\n");
     }      }
     $r->print("</table>\n");      $r->print("</table>\n");
Line 225  END Line 237  END
         $tableheader =<<"END";          $tableheader =<<"END";
 </p><p>  </p><p>
 <table border="2">  <table border="2">
 <tr><th>Row</th><th>&nbsp;</th><th>Assessment</th>  <tr><th>$lt{'ro'}</th><th>&nbsp;</th><th>$lt{'as'}</th>
 END  END
     } else {      } else {
         $tableheader =<<"END";          $tableheader =<<"END";
 </p><p>  </p><p>
 <table border="2">  <table border="2">
 <tr><th>&nbsp;</th><th>Assessment</th>  <tr><th>&nbsp;</th><th>$lt{'as'}</th>
 END  END
     }      }
     foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){      foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
Line 278  END Line 290  END
             }              }
             if ($self->blackout() && $self->{'blackout_rows'}->{$rownum}>0) {              if ($self->blackout() && $self->{'blackout_rows'}->{$rownum}>0) {
                 $row_output .=                   $row_output .= 
                     '<td colspan="52">Unavailable at this time</td></tr>'."\n";                      '<td colspan="52">'.&mt('Unavailable at this time').'</td></tr>'."\n";
             } else {              } else {
                 $row_output .= $self->html_row($num_uneditable,$rownum,                  $row_output .= $self->html_row($num_uneditable,$rownum,
                                                $exportcolor,$importcolor).                                                 $exportcolor,$importcolor).
Line 355  sub csv_rows { Line 367  sub csv_rows {
     #      #
     # Write a header row      # Write a header row
     $self->csv_output_row($filehandle,undef,      $self->csv_output_row($filehandle,undef,
                           ('Sequence or Folder','Assessment title'));                            (&mt('Sequence or Folder'),&mt('Assessment title')));
     #      #
     # Write each assessments row      # Write each assessments row
     if (scalar(@Sequences)< 1) {      if (scalar(@Sequences)< 1) {
Line 382  sub excel_rows { Line 394  sub excel_rows {
     # Write a header row      # Write a header row
     $cols_output = 0;      $cols_output = 0;
     foreach my $value ('Container','Assessment title') {      foreach my $value ('Container','Assessment title') {
         $worksheet->write($rows_output,$cols_output++,$value);          $worksheet->write($rows_output,$cols_output++,&mt($value));
     }      }
     $rows_output++;          $rows_output++;    
     #      #
Line 519  sub compute { Line 531  sub compute {
             }              }
             $f{$cell} = $resource->{'symb'}.'__&&&__'.$assess_filename;              $f{$cell} = $resource->{'symb'}.'__&&&__'.$assess_filename;
             if ($connection->aborted()) { $self->cleanup(); return; }              if ($connection->aborted()) { $self->cleanup(); return; }
             my $assessSheet = Apache::assesscalc->new($self->{'name'},              my $assessSheet;
                                                       $self->{'domain'},                  $assessSheet = Apache::assesscalc->new($self->{'name'},
                                                       $assess_filename,                                                         $self->{'domain'},
                                                       $resource->{'symb'});                                                         $assess_filename,
                                                          $resource->{'symb'});
             my @exportdata = $assessSheet->export_data($r);              my @exportdata = $assessSheet->export_data($r);
               #
               if ($assessSheet->badcalc()) {
                   $self->set_calcerror(
               &mt('Error computing row for assessment "[_1]" (row [_2]):[_3]',
                   $assessSheet->get_title(),$rownum,$assessSheet->calcerror()));
               }
               #
             if ($connection->aborted()) { $self->cleanup(); return; }              if ($connection->aborted()) { $self->cleanup(); return; }
             if ($assessSheet->blackout()) {              if ($assessSheet->blackout()) {
                 $self->blackout(1);                  $self->blackout(1);
Line 654  Writes the export data for this student Line 674  Writes the export data for this student
 #############################################  #############################################
 sub save_export_data {  sub save_export_data {
     my $self = shift;      my $self = shift;
     &Apache::assesscalc::save_cached_export_rows($self->{'name'},  
                                                  $self->{'domain'});  
     return if ($self->temporary());  
     my $student = $self->{'name'}.':'.$self->{'domain'};      my $student = $self->{'name'}.':'.$self->{'domain'};
       return if ($self->temporary());
       if ($self->badcalc()){
           # do not save data away when calculations have not been done properly.
           delete($Exportrows{$student});
           return;
       }
     return if (! exists($Exportrows{$student}));      return if (! exists($Exportrows{$student}));
       &Apache::assesscalc::save_cached_export_rows($self->{'name'},
                                                    $self->{'domain'});
     return if (! $self->is_default());      return if (! $self->is_default());
     my $key = join(':',($self->{'name'},$self->{'domain'},'studentcalc')).':';      my $key = join(':',($self->{'name'},$self->{'domain'},'studentcalc')).':';
     my $timekey = $key.'.time';      my $timekey = $key.'.time';
Line 702  sub export_data { Line 727  sub export_data {
         $self->compute($r);          $self->compute($r);
     }      }
     if ($connection->aborted()) { $self->cleanup(); return; }      if ($connection->aborted()) { $self->cleanup(); return; }
     my @Data = @{$Exportrows{$student}->{'data'}};      my @Data;
     for (my $i=0; $i<=$#Data;$i++) {      if ($self->badcalc()) {
         $Data[$i]="'".$Data[$i]."'" if ($Data[$i]=~/\D/ && defined($Data[$i]));          @Data = ();
       } else {
           @Data = @{$Exportrows{$student}->{'data'}};
           for (my $i=0; $i<=$#Data;$i++) {
               if ($Data[$i]=~/\D/ && defined($Data[$i])) {
                   $Data[$i]="'".$Data[$i]."'";
               }
           }
     }      }
     return @Data;      return @Data;
 }  }

Removed from v.1.22  
changed lines
  Added in v.1.24


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