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

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 23 May 2003 14:52:51 -0000


matthew		Fri May 23 10:52:51 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	Spreadsheet.pm assesscalc.pm 
                                 	studentcalc.pm 
  Log:
  No longer save the results of computation of temporary spreadsheets.
  Added Spreadsheet->temporary() to handle the getting and setting of the flag
  which indicates a spreadsheet is temporary.  studentcalc.pm and assesscalc.pm
  check this flag before saving their export rows.
  
  
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.3 loncom/interface/spreadsheet/Spreadsheet.pm:1.4
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.3	Thu May 22 17:16:35 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Fri May 23 10:52:51 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.3 2003/05/22 21:16:35 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.4 2003/05/23 14:52:51 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -97,6 +97,7 @@
         chome    => $ENV{'course.'.$ENV{'request.course.id'}.'.home'},
         coursedesc => $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
         coursefilename => $ENV{'request.course.fn'},
+        temporary => '',
         #
         # blackout is used to determine if any data needs to be hidden from the
         # student.
@@ -1400,6 +1401,8 @@
     my $self = shift;
     my ($makedef)=@_;
     my $cid=$self->{'cid'};
+    # If we are saving it, it must not be temporary
+    $self->temporary(0);
     if (&Apache::lonnet::allowed('opa',$cid)) {
         my %f=$self->formulas();
         my $stype = $self->{'type'};
@@ -1442,6 +1445,7 @@
            $self->{'filename'};
     $fn=~s/\W/\_/g;
     $fn=$Apache::lonnet::tmpdir.$fn.'.tmp';
+    $self->temporary(1);
     my $fh;
     if ($fh=Apache::File->new('>'.$fn)) {
         my %f = $self->formulas();
@@ -1472,10 +1476,21 @@
         }
         $spreadsheet_file->close();
     }
+    # flag the sheet as temporary
+    $self->temporary(1);
     $self->formulas(\%formulas);
     $self->set_row_sources();
     $self->set_row_numbers();
     return;
+}
+
+sub temporary {
+    my $self=shift;
+    if (@_) {
+        ($self->{'temporary'})= @_;
+    }
+    $self->logthis('temporary = '.$self->{'temporary'});
+    return $self->{'temporary'};
 }
 
 sub modify_cell {
Index: loncom/interface/spreadsheet/assesscalc.pm
diff -u loncom/interface/spreadsheet/assesscalc.pm:1.6 loncom/interface/spreadsheet/assesscalc.pm:1.7
--- loncom/interface/spreadsheet/assesscalc.pm:1.6	Fri May 23 10:08:40 2003
+++ loncom/interface/spreadsheet/assesscalc.pm	Fri May 23 10:52:51 2003
@@ -1,5 +1,5 @@
 #
-# $Id: assesscalc.pm,v 1.6 2003/05/23 14:08:40 matthew Exp $
+# $Id: assesscalc.pm,v 1.7 2003/05/23 14:52:51 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -697,6 +697,7 @@
 #############################################
 sub save_export_data {
     my $self = shift;
+    return if ($self->temporary());
     my $student = $self->{'name'}.':'.$self->{'domain'};
     my $symb    = $self->{'symb'};
     if (! exists($Exportrows{$symb}) || 
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.4 loncom/interface/spreadsheet/studentcalc.pm:1.5
--- loncom/interface/spreadsheet/studentcalc.pm:1.4	Thu May 22 17:16:35 2003
+++ loncom/interface/spreadsheet/studentcalc.pm	Fri May 23 10:52:51 2003
@@ -1,5 +1,5 @@
 #
-# $Id: studentcalc.pm,v 1.4 2003/05/22 21:16:35 matthew Exp $
+# $Id: studentcalc.pm,v 1.5 2003/05/23 14:52:51 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -490,6 +490,7 @@
 #############################################
 sub save_export_data {
     my $self = shift;
+    return if ($self->temporary());
     my $student = $self->{'name'}.':'.$self->{'domain'};
     return if (! exists($Exportrows{$student}));
     return if (! $self->is_default());