Diff for /loncom/interface/Attic/lonspreadsheet.pm between versions 1.45 and 1.46

version 1.45, 2001/03/17 16:52:30 version 1.46, 2001/03/17 20:43:57
Line 22  use HTML::TokeParser; Line 22  use HTML::TokeParser;
 #  #
   
 my %oldsheets;  my %oldsheets;
   my %loadedcaches;
   
 #  #
 # Cache for stores of an individual user  # Cache for stores of an individual user
Line 1496  sub exportsheet { Line 1497  sub exportsheet {
 #  #
 # Check if cached  # Check if cached
 #  #
   
  my $key=$uname.':'.$udom.':'.$stype.':'.$usymb;   my $key=$uname.':'.$udom.':'.$stype.':'.$usymb;
  my $found='';   my $found='';
   
Line 1508  sub exportsheet { Line 1510  sub exportsheet {
      } split(/\_\_\_\&\_\_\_/,$oldsheets{$key});       } split(/\_\_\_\&\_\_\_/,$oldsheets{$key});
  }   }
   
    unless ($found) {
        &cachedssheets($uname,$udom,&Apache::lonnet::homeserver($uname,$udom));
        if ($oldsheets{$key}) {
           map {
               my ($name,$value)=split(/\_\_\_\=\_\_\_/,$_);
               if ($name eq $fn) {
           $found=$value;
               }
           } split(/\_\_\_\&\_\_\_/,$oldsheets{$key});
        }
    }
   
  if ($found) {   if ($found) {
 #  #
 # Return what was cached  # Return what was cached
Line 1517  sub exportsheet { Line 1531  sub exportsheet {
  } else {   } else {
 #  #
 # Not cached  # Not cached
 #   #        
   
     my $thissheet=&makenewsheet($uname,$udom,$stype,$usymb);      my $thissheet=&makenewsheet($uname,$udom,$stype,$usymb);
     &readsheet($thissheet,$fn);      &readsheet($thissheet,$fn);
     &updatesheet($thissheet);      &updatesheet($thissheet);
Line 1528  sub exportsheet { Line 1543  sub exportsheet {
 # Store now  # Store now
 #  #
     my $cid=$ENV{'request.course.id'};       my $cid=$ENV{'request.course.id'}; 
     my $current=&Apache::lonnet::reply('get:'.      my $current=();
       if ($stype eq 'studentcalc') {
          $current=&Apache::lonnet::reply('get:'.
                                      $ENV{'course.'.$cid.'.domain'}.':'.                                       $ENV{'course.'.$cid.'.domain'}.':'.
                                      $ENV{'course.'.$cid.'.num'}.                                       $ENV{'course.'.$cid.'.num'}.
      ':nohist_calculatedsheets:'.       ':nohist_calculatedsheets:'.
                                      &Apache::lonnet::escape($key),                                       &Apache::lonnet::escape($key),
                                      $ENV{'course.'.$cid.'.home'});                                       $ENV{'course.'.$cid.'.home'});
       } else {
          $current=&Apache::lonnet::reply('get:'.
                                        &getudom($thissheet).':'.
                                        &getuname($thissheet).
        ':nohist_calculatedsheets_'.
                                        $ENV{'request.course.id'}.':'.
                                        &Apache::lonnet::escape($key),
                                        &getuhome($thissheet));
   
       }
     my %currentlystored=();      my %currentlystored=();
     unless ($current=~/^error\:/) {      unless ($current=~/^error\:/) {
        map {         map {
Line 1548  sub exportsheet { Line 1575  sub exportsheet {
         if ($newstore) { $newstore.='___&___'; }          if ($newstore) { $newstore.='___&___'; }
         $newstore.=$_.'___=___'.$currentlystored{$_};          $newstore.=$_.'___=___'.$currentlystored{$_};
     } keys %currentlystored;      } keys %currentlystored;
     &Apache::lonnet::reply('put:'.      if ($stype eq 'studentcalc') {
          &Apache::lonnet::reply('put:'.
                          $ENV{'course.'.$cid.'.domain'}.':'.                           $ENV{'course.'.$cid.'.domain'}.':'.
                          $ENV{'course.'.$cid.'.num'}.                           $ENV{'course.'.$cid.'.num'}.
  ':nohist_calculatedsheets:'.   ':nohist_calculatedsheets:'.
                          &Apache::lonnet::escape($key).'='.                           &Apache::lonnet::escape($key).'='.
  &Apache::lonnet::escape($newstore),   &Apache::lonnet::escape($newstore),
                          $ENV{'course.'.$cid.'.home'});                           $ENV{'course.'.$cid.'.home'});
      } else {
          &Apache::lonnet::reply('put:'.
                            &getudom($thissheet).':'.
                            &getuname($thissheet).
    ':nohist_calculatedsheets_'.
                            $ENV{'request.course.id'}.':'.
                            &Apache::lonnet::escape($key).'='.
    &Apache::lonnet::escape($newstore),
                            &getuhome($thissheet));
      }
  }   }
  return @exportarr;   return @exportarr;
 }  }
   
 # ===================================================== Calculated sheets cache  # ===================================================== Calculated sheets cache
 #  #
 # Load all previously cached spreadsheets for this course  # Load previously cached student spreadsheets for this course
 #  #
   
 sub cachedsheets {  sub cachedcsheets {
     my $cid=$ENV{'request.course.id'};      my $cid=$ENV{'request.course.id'};
     my $reply=&Apache::lonnet::reply('dump:'.      my $reply=&Apache::lonnet::reply('dump:'.
      $ENV{'course.'.$cid.'.domain'}.':'.       $ENV{'course.'.$cid.'.domain'}.':'.
                                      $ENV{'course.'.$cid.'.num'}.                                       $ENV{'course.'.$cid.'.num'}.
      ':nohist_calculatedsheets',       ':nohist_calculatedsheets',
                                      $ENV{'course.'.$cid.'.home'});                                       $ENV{'course.'.$cid.'.home'});
     undef %oldsheets;  
     unless ($reply=~/^error\:/) {      unless ($reply=~/^error\:/) {
  map {   map {
             my ($name,$value)=split(/\=/,$_);              my ($name,$value)=split(/\=/,$_);
Line 1581  sub cachedsheets { Line 1618  sub cachedsheets {
     }      }
 }  }
   
   # ===================================================== Calculated sheets cache
   #
   # Load previously cached assessment spreadsheets for this student
   #
   
   sub cachedssheets {
     my ($sname,$sdom,$shome)=@_;
     unless (($loadedcaches{$sname.'_'.$sdom}) || ($shome eq 'no_host')) {
       my $cid=$ENV{'request.course.id'};
       my $reply=&Apache::lonnet::reply('dump:'.$sdom.':'.$sname.
                ':nohist_calculatedsheets_'.
                                         $ENV{'request.course.id'},
                                        $shome);
       unless ($reply=~/^error\:/) {
    map {
               my ($name,$value)=split(/\=/,$_);
               $oldsheets{&Apache::lonnet::unescape($name)}
                         =&Apache::lonnet::unescape($value);
           } split(/\&/,$reply);
       }
       $loadedcaches{$sname.'_'.$sdom}=1;
     }
   }
   
   # ===================================================== Calculated sheets cache
   #
   # Load previously cached assessment spreadsheets for this student
   #
   
 # ================================================================ Main handler  # ================================================================ Main handler
 #  #
 # Interactive call to screen  # Interactive call to screen
Line 1749  ENDSCRIPT Line 1815  ENDSCRIPT
   
     $r->print(&hiddenfield('ufn',&getfilename($asheet)));      $r->print(&hiddenfield('ufn',&getfilename($asheet)));
   
 # ----------------------------------------------------------- Get cached sheets  # --------------------------------------------------------------- Cached sheets
   
       undef %oldsheets;
       undef %loadedcaches;
   
     &cachedsheets();      if (&gettype($asheet) eq 'classcalc') {
           $r->print("Loading previously calculated student sheets ...<br>\n");
           $r->rflush();
           &cachedcsheets();
       } elsif (&gettype($asheet) eq 'studentcalc') {
           $r->print("Loading previously calculated assessment sheets ...<br>\n");
           $r->rflush();
           &cachedssheets(&getuname($asheet),&getudom($asheet),
                          &getuhome($asheet));
       }
   
 # ----------------------------------------------------- Update sheet, load rows  # ----------------------------------------------------- Update sheet, load rows
   

Removed from v.1.45  
changed lines
  Added in v.1.46


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