--- loncom/interface/Attic/lonspreadsheet.pm	2003/01/30 16:20:08	1.165
+++ loncom/interface/Attic/lonspreadsheet.pm	2003/01/30 21:35:13	1.167
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.165 2003/01/30 16:20:08 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.167 2003/01/30 21:35:13 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -537,12 +537,12 @@ sub tmpdir {
 }
 
 my %spreadsheets;
-my %loadedcaches;
+#my %loadedcaches;
 my %courserdatas;
 my %userrdatas;
 my %defaultsheets;
 my %rowlabel_cache;
-my %oldsheets;
+#my %oldsheets;
 
 sub complete_recalc {
     my $self = shift;
@@ -609,7 +609,7 @@ sub cachedssheets {
     my ($uname,$udom) = @_;
     $uname = $uname || $self->{'uname'};
     $udom  = $udom  || $self->{'udom'};
-    if (! $Apache::lonspreadsheet::loadedcaches{$uname.'_'.$udom}) {
+    if (! exists($Apache::lonspreadsheet::loadedcaches{$uname.'_'.$udom})) {
         my @tmp = &Apache::lonnet::dump('nohist_calculatedsheets_'.
                                         $ENV{'request.course.id'},
                                         $self->{'udom'},
@@ -1588,7 +1588,6 @@ sub sett {
     foreach my $col ($self->template_cells()) {
         next if ($col=~/^$pattern/);
         foreach my $trow ($self->rows()) {
-            next if ($trow eq '0');
             # Get the name of this cell
             my $lb=$col.$trow;
             # Grab the template declaration
@@ -1904,7 +1903,7 @@ sub rebuild_stats {
     $self->{'rows'}=[];
     $self->{'template_cells'}=[];
     foreach my $cell($self->formulas_keys()) {
-        push(@{$self->{'rows'}},$1) if ($cell =~ /^A(\d+)/);
+        push(@{$self->{'rows'}},$1) if ($cell =~ /^A(\d+)/ && $1 != 0);
         push(@{$self->{'template_cells'}},$1) if ($cell =~ /^template_(\w+)/);
     }
     return;
@@ -1951,7 +1950,7 @@ sub rowlabels {
         $self->{'rowlabel'}=$rowlabel;
         return;
     } else {
-        return %{$self->{'rowlabel'}} if (defined($self->{'rowlabels'}));
+        return %{$self->{'rowlabel'}} if (defined($self->{'rowlabel'}));
     }
 }
 
@@ -2665,9 +2664,10 @@ sub readsheet {
     # $fn now has a value
     $self->{'filename'} = $fn;
     # see if sheet is cached
-    my $fstring='';
-    if ($fstring=$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}) {
-        my %tmp = split(/___;___/,$fstring);
+    if (exists($spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn})) {
+        
+        my %tmp = split(/___;___/,
+                        $spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn});
         $self->formulas(\%tmp);
     } else {
         # Not cached, need to read
@@ -2948,8 +2948,7 @@ sub updateclasssheet {
             $self->{'maxrow'}= $rownum;
         }
         $existing{$f{$cell}}=1;
-        unless ((defined($currentlist{$f{$cell}})) || ($rownum ne '0') ||
-                ($f{$cell}=~/^(~~~|---)/)) {
+        if (! defined($currentlist{$f{$cell}}) && ($f{$cell}=~/^(~~~|---)/)) {
             $f{$cell}='!!! Obsolete';
             $changed=1;
         }
@@ -2980,8 +2979,9 @@ sub get_student_rowlabels {
     $self->{'rowlabel'} = {};
     #
     my $identifier =$self->{'coursefilename'}.'_'.$stype;
-    if  ($rowlabel_cache{$identifier}) {
-        %{$self->{'rowlabel'}}=split(/___;___/,$rowlabel_cache{$identifier});
+    if  (exists($rowlabel_cache{$identifier})) {
+        my %tmp = split(/___;___/,$rowlabel_cache{$identifier});
+        $self->rowlabels(\%tmp);
     } else {
         # Get the data and store it in the cache
         # Tie hash
@@ -3033,8 +3033,9 @@ sub get_assess_rowlabels {
     $self->rowlabels({});
     my $identifier =$self->{'coursefilename'}.'_'.$stype.'_'.$usymb;
     #
-    if  ($rowlabel_cache{$identifier}) {
-        $self->rowlabels(split(/___;___/,$rowlabel_cache{$identifier}));
+    if (exists($rowlabel_cache{$identifier})) {
+        my %tmp = split('___;___',$rowlabel_cache{$identifier});
+        $self->rowlabels(\%tmp);
     } else {
         # Get the data and store it in the cache
         # Tie hash
@@ -3078,9 +3079,8 @@ sub get_assess_rowlabels {
         untie(%course_db);
         # Store away the results
         $self->rowlabels(\%parameter_labels);
-        $rowlabel_cache{$identifier}=join('___;___',$self->rowlabels());
+        $rowlabel_cache{$identifier}=join('___;___',%parameter_labels);
     }
-        
 }
 
 sub updatestudentassesssheet {
@@ -3099,7 +3099,6 @@ sub updatestudentassesssheet {
     foreach my $rownum ($self->rows()) {
         my $cell = 'A'.$rownum;
         my $formula = $f{$cell};
-        next if ($rownum eq '0');
         $self->{'maxrow'} = $rownum if ($rownum > $self->{'maxrow'});
         my ($usy,$ufn)=split(/__&&&\__/,$formula);
         $existing{$usy}=1;
@@ -3147,7 +3146,7 @@ sub loadstudent{
         if(defined($c) && ($c->aborted())) {
             last;
         }
-        next if (($value =~ /^[!~-]/) || ($row==0));
+        next if ($value =~ /^[!~-]/);
         my ($usy,$ufn)=split(/__&&&\__/,$value);
         @assessdata=$self->exportsheet($self->{'uname'},
                                         $self->{'udom'},
@@ -3199,12 +3198,14 @@ sub loadcourse {
 </script>
 ENDPOP
     $r->rflush();
+    # It would be nice to load in the classlist and assessment info at this 
+    # point, before attacking the student spreadsheets.
     foreach my $row ($self->rows()) {
         if(defined($c) && ($c->aborted())) {
             last;
         }
         my $cell = 'A'.$row;
-        next if (($formulas{$cell}=~/^[\!\~\-]/)  || ($row==0));
+        next if ($formulas{$cell}=~/^[\!\~\-]/);
         my ($sname,$sdom) = split(':',$formulas{$cell});
         my $started = time;
         my @studentdata=$self->exportsheet($sname,$sdom,'studentcalc',