Diff for /loncom/interface/spreadsheet/assesscalc.pm between versions 1.55 and 1.60

version 1.55, 2006/05/15 23:40:47 version 1.60, 2014/02/11 19:11:30
Line 156  sub initialize { Line 156  sub initialize {
     if (! defined($navmap)) {      if (! defined($navmap)) {
         $navmap = Apache::lonnavmaps::navmap->new();          $navmap = Apache::lonnavmaps::navmap->new();
     }      }
     if (!defined($navmap)) {      if ((!defined($navmap)) || (!ref($navmap))) {
         &Apache::lonnet::logthis('assesscalc:Can not open Coursemap');          &Apache::lonnet::logthis('assesscalc:Can not open Coursemap');
     }      }
     &Apache::loncoursedata::clear_internal_caches();      &Apache::loncoursedata::clear_internal_caches();
Line 174  sub initialize { Line 174  sub initialize {
 ########################################################  ########################################################
 ########################################################  ########################################################
 sub initialize_package {  sub initialize_package {
     my ($sname,$sdomain,$in_navmap) = @_;      my ($sname,$sdomain,$in_navmap,$calling_sheet) = @_;
     $current_name   = $sname;      $current_name   = $sname;
     $current_domain = $sdomain;      $current_domain = $sdomain;
     $navmap = $in_navmap;      $navmap = $in_navmap;
Line 185  sub initialize_package { Line 185  sub initialize_package {
         undef(%courseopt);          undef(%courseopt);
     }      }
     &load_cached_export_rows();      &load_cached_export_rows();
     &load_parameter_caches();      &load_parameter_caches($calling_sheet);
     &Apache::loncoursedata::clear_internal_caches();      &Apache::loncoursedata::clear_internal_caches();
 }  }
   
Line 202  sub initialize_package { Line 202  sub initialize_package {
 ########################################################  ########################################################
 ########################################################  ########################################################
 sub load_parameter_caches {  sub load_parameter_caches {
       my ($calling_sheet) = @_;
     my $userprefix = $current_name.':'.$current_domain.'_';      my $userprefix = $current_name.':'.$current_domain.'_';
     $userprefix =~ s/:/_/g;      $userprefix =~ s/:/_/g;
     #      #
Line 234  sub load_parameter_caches { Line 235  sub load_parameter_caches {
     if (! %userdata) {      if (! %userdata) {
         %userdata = &Apache::loncoursedata::get_current_state($current_name,          %userdata = &Apache::loncoursedata::get_current_state($current_name,
                                                               $current_domain);                                                                $current_domain);
    my ($tmp) = %userdata;
    if ($tmp =~ /^error:(.*)/) {
       $calling_sheet->set_calcerror($1);
    }
         $userdata{'loadtime'} = time;          $userdata{'loadtime'} = time;
     }      }
     return;      return;
Line 272  sub ensure_current_caches { Line 277  sub ensure_current_caches {
         undef(%useropt);          undef(%useropt);
         undef(%userdata);          undef(%userdata);
     }      }
     &load_parameter_caches();      &load_parameter_caches($self);
 }  }
   
 ##################################################  ##################################################
Line 483  END Line 488  END
     $r->print($tableheader);      $r->print($tableheader);
     #      #
     # Print out template row      # Print out template row
     $r->print('<tr><td>Template</td><td>&nbsp;</td>'.      $r->print('<tr><td>'.&mt('Template').'</td><td>&nbsp;</td>'.
       $self->html_template_row($num_uneditable,$importcolor).        $self->html_template_row($num_uneditable,$importcolor).
               "</tr>\n");                "</tr>\n");
     #      #
     # Print out summary/export row      # Print out summary/export row
     $r->print('<tr><td>Export</td><td>0</td>'.      $r->print('<tr><td>'.&mt('Export').'</td><td>0</td>'.
       $self->html_export_row($exportcolor)."</tr>\n");        $self->html_export_row($exportcolor)."</tr>\n");
     #      #
     # Prepare to output rows      # Prepare to output rows
     $tableheader =<<"END";      $tableheader =
 <table border="2">          '<table border="2">'.
 <tr><th>row</th><th>Item</th>          '<tr><th>'.&mt('Row').'</th>'.
 END          '<th>'.&mt('Item').'</th>';
     foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){      foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
  if ($label_num<$num_uneditable) {    if ($label_num<$num_uneditable) { 
             $tableheader.='<th bgcolor="'.$importcolor.'">';              $tableheader.='<th bgcolor="'.$importcolor.'">';
Line 542  sub assess_html_row { Line 547  sub assess_html_row {
             $row_html .= &Apache::Spreadsheet::html_uneditable_cell($cell,              $row_html .= &Apache::Spreadsheet::html_uneditable_cell($cell,
                                                                     '#FFDDDD');                                                                      '#FFDDDD');
         } else {          } else {
             $row_html .= '<td bgcolor="#EOFFDD">';              $row_html .= '<td bgcolor="#E0FFDD">';
             $row_html .= &Apache::Spreadsheet::html_editable_cell($cell,              $row_html .= &Apache::Spreadsheet::html_editable_cell($cell,
                                                                   '#E0FFDD',1);                                                                    '#E0FFDD',1);
         }          }
Line 847  sub sett { Line 852  sub sett {
             # Replace 'A0' with the value from 'A0'              # Replace 'A0' with the value from 'A0'
             $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;              $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;
             # Replace parameters              # Replace parameters
             $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge;              $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/sge;
         }          }
     }      }
     #      #
Line 866  sub sett { Line 871  sub sett {
             $t{$cell}=$formula;              $t{$cell}=$formula;
             $t{$cell}=~s/\.\.+/\,/g;              $t{$cell}=~s/\.\.+/\,/g;
             $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;              $t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g;
             $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge;              $t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/sge;
         }          }
     }      }
     # Put %t into the safe space      # Put %t into the safe space

Removed from v.1.55  
changed lines
  Added in v.1.60


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