[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 15 May 2005 04:49:42 -0000


albertel		Sun May 15 00:49:42 2005 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm 
  Log:
  - only load the sprs once we actually need it (since if we have it cached no need to load it)
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.48 loncom/interface/spreadsheet/Spreadsheet.pm:1.49
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.48	Sun May 15 00:02:17 2005
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Sun May 15 00:49:42 2005
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.48 2005/05/15 04:02:17 albertel Exp $
+# $Id: Spreadsheet.pm,v 1.49 2005/05/15 04:49:42 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -111,7 +111,8 @@
         #
         # Flags
         temporary => 0,  # true if this sheet has been modified but not saved
-        new_rows  => 0, # true if this sheet has new rows
+        new_rows  => 0,  # true if this sheet has new rows
+	loaded    => 0,  # true if the formulas have been loaded
         #
         # blackout is used to determine if any data needs to be hidden from the
         # student.
@@ -127,14 +128,6 @@
     #
     bless($self,$class);
     #
-    # Load in the spreadsheet definition
-    $self->filename($filename);
-    if (exists($env{'form.workcopy'}) && 
-        $self->{'type'} eq $env{'form.workcopy'}) {
-        $self->load_tmp();
-    } else {
-        $self->load();
-    }
     return $self;
 }
 
@@ -976,6 +969,17 @@
         $self->{'template_cells'} = [];
         return;
     } else {
+	if (!$self->{'loaded'}) {
+	    $self->{'loaded'}=1;
+	    # Load in the spreadsheet definition
+	    $self->filename($filename);
+	    if (exists($env{'form.workcopy'}) && 
+		$self->{'type'} eq $env{'form.workcopy'}) {
+		$self->load_tmp();
+	    } else {
+		$self->load();
+	    }
+	}
         return %{$self->{'formulas'}};
     }
 }