--- loncom/interface/spreadsheet/assesscalc.pm 2003/09/05 01:06:45 1.18 +++ loncom/interface/spreadsheet/assesscalc.pm 2003/09/05 01:57:54 1.19 @@ -1,5 +1,5 @@ # -# $Id: assesscalc.pm,v 1.18 2003/09/05 01:06:45 matthew Exp $ +# $Id: assesscalc.pm,v 1.19 2003/09/05 01:57:54 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -208,11 +208,17 @@ sub load_parameter_caches { ######################################################## sub ensure_current_parameter_caches { my $self = shift; + ## + ## Check for a modified parameters + ## if (! defined($current_course) || $current_course ne $ENV{'request.course.id'} ) { $current_course = $ENV{'request.course.id'}; undef(%courseopt); } + ## + ## Check for new user + ## if (! defined($current_name) || $current_name ne $self->{'name'} || ! defined($current_domain) || $current_domain ne $self->{'domain'}) { $current_domain = $self->{'domain'}; @@ -518,6 +524,9 @@ sub excel_rows { sub compute { my $self = shift; + my ($r) = @_; + my $connection = $r->connection(); + if ($connection->aborted()) { $self->cleanup(); return; } # $self->logthis('computing'); $self->initialize_safe_space(); ######################################### @@ -556,7 +565,9 @@ sub compute { } # # Get the values of the metadata fields + if ($connection->aborted()) { $self->cleanup(); return; } $self->ensure_current_parameter_caches(); + if ($connection->aborted()) { $self->cleanup(); return; } my $filename = $self->{'coursefilename'}.'_parms.db'; if (tie(%parmhash,'GDBM_File', $self->{'coursefilename'}.'_parms.db',&GDBM_READER(),0640)) { @@ -568,6 +579,7 @@ sub compute { } else { $self->logthis('unable to tie '.$filename); } + if ($connection->aborted()) { $self->cleanup(); return; } # # Clean out unnecessary parameters foreach (keys(%parameters)) { @@ -602,8 +614,10 @@ sub compute { } } } + if ($connection->aborted()) { $self->cleanup(); return; } # # Move the parameters into the spreadsheet + if ($connection->aborted()) { $self->cleanup(); return; } while (my ($parm,$value) = each(%parameters)) { my $cell = 'A'.$self->get_row_number_from_key($parm); $f{$cell} = $parm; @@ -612,6 +626,7 @@ sub compute { } $self->formulas(\%f); $self->constants(\%c); + if ($connection->aborted()) { $self->cleanup(); return; } $self->calcsheet(); # # Store export row in cache @@ -622,6 +637,7 @@ sub compute { # Save the export data $self->save_export_data(); $self->save() if ($self->need_to_save()); + if ($connection->aborted()) { $self->cleanup(); return; } return; } @@ -731,6 +747,8 @@ spreadsheet only if necessary. ############################################# sub export_data { my $self = shift; + my ($r) = @_; + my $connection = $r->connection(); my $symb = $self->{'symb'}; if (! exists($ENV{'request.role.adv'}) || ! $ENV{'request.role.adv'} || ! exists($Exportrows{$symb}) || ! defined($Exportrows{$symb}) || @@ -739,8 +757,9 @@ sub export_data { ! defined($Exportrows{$symb}->{$self->{'filename'}}) || ! ref($Exportrows{$symb}->{$self->{'filename'}}) ) { - $self->compute(); + $self->compute($r); } + if ($connection->aborted()) { $self->cleanup(); return; } my @Data = @{$Exportrows{$symb}->{$self->{'filename'}}}; if ($Data[0] =~ /^(.*)___=___/) { $self->{'sheetname'} = $1;