[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 30 Jan 2003 21:35:13 -0000
matthew Thu Jan 30 16:35:13 2003 EDT
Modified files:
/loncom/interface lonspreadsheet.pm
Log:
Debugging caching mechanisms.
%loadedcaches and %oldsheets in lonspreadsheet::Spreadsheet were not used,
so they are commented out for now.
Fixed a bug in Spreadsheet::rowlabels which caused it to NEVER return the
rowlabels for the current spreadsheet. Frankly I am amazed it worked at all
with this bug.
Fixed cache calls in get_student_rowlabels and get_assess_rowlabels so they
actually work (I think is a new bug, not an old one, but I am not sure).
This has a noticable effect on the computation time of the spreadsheet.
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.166 loncom/interface/lonspreadsheet.pm:1.167
--- loncom/interface/lonspreadsheet.pm:1.166 Thu Jan 30 13:37:49 2003
+++ loncom/interface/lonspreadsheet.pm Thu Jan 30 16:35:13 2003
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.166 2003/01/30 18:37:49 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 @@
}
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 @@
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'},
@@ -1950,7 +1950,7 @@
$self->{'rowlabel'}=$rowlabel;
return;
} else {
- return %{$self->{'rowlabel'}} if (defined($self->{'rowlabels'}));
+ return %{$self->{'rowlabel'}} if (defined($self->{'rowlabel'}));
}
}
@@ -2664,9 +2664,10 @@
# $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
@@ -2978,8 +2979,9 @@
$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
@@ -3031,8 +3033,9 @@
$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
@@ -3076,9 +3079,8 @@
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 {
@@ -3196,6 +3198,8 @@
</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;