Diff for /loncom/interface/Attic/lonspreadsheet.pm between versions 1.172 and 1.179

version 1.172, 2003/02/17 16:29:51 version 1.179, 2003/05/27 15:50:30
Line 57  use strict; Line 57  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::lonhtmlcommon;  use Apache::lonhtmlcommon;
   use Apache::lonmenu;
 use HTML::Entities();  use HTML::Entities();
   
 # --------------------------------------------------------- Various form fields  # --------------------------------------------------------- Various form fields
Line 152  sub handler { Line 153  sub handler {
                                              $ENV{'form.ufn'} eq 'default')) {                                               $ENV{'form.ufn'} eq 'default')) {
         $ENV{'form.ufn'}='default_'.$1;          $ENV{'form.ufn'}='default_'.$1;
     }      }
     if (!$ENV{'form.ufn'} || $ENV{'form.ufn'} eq 'default') {  #    if (!$ENV{'form.ufn'} || $ENV{'form.ufn'} eq 'default') {
         $ENV{'form.ufn'}='course_default_'.$sheettype;  #        $ENV{'form.ufn'}='course_default_'.$sheettype;
     }  #    }
     #      #
     # Interactive loading of specific sheet?      # Interactive loading of specific sheet?
     #      #
Line 183  sub handler { Line 184  sub handler {
     # Header....      # Header....
     #      #
     $r->print('<html><head><title>LON-CAPA Spreadsheet</title>');      $r->print('<html><head><title>LON-CAPA Spreadsheet</title>');
     my $nothing = "''";      my $nothing = &Apache::lonhtmlcommon::javascript_nothing();
     if ($ENV{'browser.type'} eq 'explorer') {  
         $nothing = "'javascript:void(0);'";  
     }  
   
     if ($ENV{'request.role'} !~ /^st\./) {      if ($ENV{'request.role'} !~ /^st\./) {
         $r->print(<<ENDSCRIPT);          $r->print(<<ENDSCRIPT);
Line 247  ENDSCRIPT Line 245  ENDSCRIPT
               &hiddenfield('udom',$ENV{'form.udom'}).                &hiddenfield('udom',$ENV{'form.udom'}).
               &hiddenfield('usymb',$ENV{'form.usymb'}).                &hiddenfield('usymb',$ENV{'form.usymb'}).
               &hiddenfield('unewfield','').                &hiddenfield('unewfield','').
               &hiddenfield('unewformula',''));                &hiddenfield('unewformula','').
                 &Apache::lonmenu::regflush());
     $r->rflush();      $r->rflush();
     #      #
     # Full recalc?      # Full recalc?
Line 355  ENDSCRIPT Line 354  ENDSCRIPT
         $oldsheets{'course'} ne $sheet->{'cid'}) {          $oldsheets{'course'} ne $sheet->{'cid'}) {
         undef %oldsheets;          undef %oldsheets;
         undef %loadedcaches;          undef %loadedcaches;
           &Apache::lonspreadsheet::Spreadsheet::clear_package_variables();
     }      }
     $oldsheets{'course'} = $sheet->{'cid'};      $oldsheets{'course'} = $sheet->{'cid'};
     #      #
Line 537  my %defaultsheets; Line 537  my %defaultsheets;
 my %rowlabel_cache;  my %rowlabel_cache;
 #my %oldsheets;  #my %oldsheets;
   
   sub clear_package_variables {
       undef %courseopt;
       undef %useropt;
       undef %parmhash;
       undef %Section;
       undef %expiredates;
       undef $cachedassess;
       undef %cachedstores;
       undef %starttimes;
       undef %usedtimes;
       undef %numbertimes;
       undef $includedir;
       undef %spreadsheets;
       undef %courserdatas;
       undef %userrdatas;
       undef %defaultsheets;
       undef %rowlabel_cache;
   }
   
 sub complete_recalc {  sub complete_recalc {
     my $self = shift;      my $self = shift;
     undef %spreadsheets;      undef %spreadsheets;
Line 722  sub parmval { Line 741  sub parmval {
     # second, check map parms      # second, check map parms
     my $thisparm = $parmhash{$symbparm};      my $thisparm = $parmhash{$symbparm};
     return $thisparm if (defined($thisparm));      return $thisparm if (defined($thisparm));
   
     # first, check default      # first, check default
     return &Apache::lonnet::metadata($fn,$rwhat.'.default');      $thisparm = &Apache::lonnet::metadata($fn,$rwhat.'.default');
       return $thisparm if (defined($thisparm));
   
       #Cascade Up
       my $space=$what;
       $space=~s/\.\w+$//;
       if ($space ne '0') {
    my @parts=split(/_/,$space);
    my $id=pop(@parts);
    my $part=join('_',@parts);
    if ($part eq '') { $part='0'; }
    my $newwhat=$rwhat;
    $newwhat=~s/\Q$space\E/$part/;
    my $partgeneral=&parmval($newwhat,$symb,$uname,$udom,$csec);
    if (defined($partgeneral)) { return $partgeneral; }
       }
   
       #nothing defined
       return '';
 }  }
   
 #  #
Line 735  sub new { Line 773  sub new {
     #      #
     my ($uname,$udom,$stype,$usymb)=@_;      my ($uname,$udom,$stype,$usymb)=@_;
     #      #
       if (! exists($Section{$uname.':'.$udom})) {
           my $classlist = &Apache::loncoursedata::get_classlist();
           #
           foreach my $student (keys(%$classlist)) {
               my ($studentDomain,$studentName,undef,undef,undef,$studentSection,
                   undef,undef) = @{$classlist->{$student}};
               $Section{$studentName.':'.$studentDomain} = $studentSection;
           }
       }
     my $self = {      my $self = {
         uname => $uname,          uname => $uname,
         udom  => $udom,          udom  => $udom,
Line 1507  sub expandnamed { Line 1554  sub expandnamed {
  foreach my $varname ( @vars ) {   foreach my $varname ( @vars ) {
             if ($varname=~/\D/) {              if ($varname=~/\D/) {
                $formula=~s/$varname/'$c{\''.$varname.'\'}'/ge;                 $formula=~s/$varname/'$c{\''.$varname.'\'}'/ge;
                $varname=~s/$var/\(\\w\+\)/g;                 $varname=~s/$var/\([\\w:\\- ]\+\)/g;
        foreach (keys(%{$self->{'constants'}})) {         foreach (keys(%{$self->{'constants'}})) {
   if ($_=~/$varname/) {    if ($_=~/$varname/) {
       $values{$1}=1;        $values{$1}=1;
Line 3198  sub loadcourse { Line 3245  sub loadcourse {
     foreach ($self->rows()) {      foreach ($self->rows()) {
         $total++ if ($formulas{'A'.$_} !~ /^[!~-]/);          $total++ if ($formulas{'A'.$_} !~ /^[!~-]/);
     }      }
     my $now=0;  
     my $since=time;      my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,
     $r->print(<<ENDPOP);        'Spreadsheet Status','Spreadsheet Calculation Progress', $total);
 <script>      &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
     popwin=open('','popwin','width=400,height=100');    'Processing Course Assessment Data');
     popwin.document.writeln('<html><body bgcolor="#FFFFFF">'+  
       '<h3>Spreadsheet Calculation Progress</h3>'+  
       '<form name=popremain>'+  
       '<input type=text size=45 name=remaining value="Processing Course Assessment Data"></form>'+  
       '</body></html>');  
     popwin.document.close();  
 </script>  
 ENDPOP  
     $r->rflush();  
     # It would be nice to load in the classlist and assessment info at this       # It would be nice to load in the classlist and assessment info at this 
     # point, before attacking the student spreadsheets.      # point, before attacking the student spreadsheets.
     foreach my $row ($self->rows()) {      foreach my $row ($self->rows()) {
Line 3225  ENDPOP Line 3264  ENDPOP
         my @studentdata=$self->exportsheet($sname,$sdom,'studentcalc',          my @studentdata=$self->exportsheet($sname,$sdom,'studentcalc',
                                      undef,undef,$r);                                       undef,undef,$r);
         undef %userrdatas;          undef %userrdatas;
         $now++;   &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
         $r->print('<script>popwin.document.popremain.remaining.value="'.   'last student');
                   $now.'/'.$total.': '.int((time-$since)/$now*($total-$now)).  
                   ' secs remaining '.(time-$started).' last student";'.  
                   '</script>');  
         $r->rflush();   
         #  
         my $index=0;          my $index=0;
         foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',          foreach ('A','B','C','D','E','F','G','H','I','J','K','L','M',
                  'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') {                   'N','O','P','Q','R','S','T','U','V','W','X','Y','Z') {
Line 3251  ENDPOP Line 3285  ENDPOP
     }      }
     $self->formulas(\%formulas);      $self->formulas(\%formulas);
     $self->constants(\%constants);      $self->constants(\%constants);
     $r->print('<script>popwin.close()</script>');      &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
     $r->rflush();   
 }  }
   
 # ------------------------------------------------ Load data for one assessment  # ------------------------------------------------ Load data for one assessment

Removed from v.1.172  
changed lines
  Added in v.1.179


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