--- loncom/interface/Attic/lonspreadsheet.pm 2003/01/30 18:37:49 1.166 +++ loncom/interface/Attic/lonspreadsheet.pm 2003/02/17 16:29:51 1.172 @@ -1,5 +1,5 @@ # -# $Id: lonspreadsheet.pm,v 1.166 2003/01/30 18:37:49 matthew Exp $ +# $Id: lonspreadsheet.pm,v 1.172 2003/02/17 16:29:51 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -262,7 +262,6 @@ ENDSCRIPT # Global directory configs # $sheet->includedir($r->dir_config('lonIncludes')); - $sheet->tmpdir($r->dir_config('lonDaemons').'/tmp/'); # # Check user permissions if (($sheet->{'type'} eq 'classcalc' ) || @@ -524,25 +523,19 @@ my %numbertimes; # Directories # my $includedir; -my $tmpdir; sub includedir { my $self = shift; $includedir = shift; } -sub tmpdir { - my $self = shift; - $tmpdir = shift; -} - 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 +602,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'}, @@ -1744,6 +1737,7 @@ sub calcsheet { $self->sett(); my $result = $self->{'safe'}->reval('&calc();'); %{$self->{'values'}} = %{$self->{'safe'}->varglob('sheet_values')}; +# $self->logthis($self->get_errorlog()); return $result; } @@ -1892,6 +1886,22 @@ sub dump_values_to_log { } $self->logthis("--------------------------------------------------------");} +## +## Yet another debugging function +## +sub dump_hash_to_log { + my $self= shift(); + my %tmp = @_; + if (@_<2) { + %tmp = %{$_[0]}; + } + $self->logthis('---------------------------- (entries end with ":"'); + while (my ($key,$val) = each (%tmp)) { + $self->logthis($key.' = '.$val.':'); + } + $self->logthis('---------------------------- (entries end with ":"'); +} + ################################ ## Helper functions ## ################################ @@ -1950,7 +1960,7 @@ sub rowlabels { $self->{'rowlabel'}=$rowlabel; return; } else { - return %{$self->{'rowlabel'}} if (defined($self->{'rowlabels'})); + return %{$self->{'rowlabel'}} if (defined($self->{'rowlabel'})); } } @@ -2540,6 +2550,7 @@ sub export_sheet_as_excel { } next if ($row_is_empty); } + $worksheet->write($rows_output,$cols_output++,$rownum); $worksheet->write($rows_output,$cols_output++,$label); if (ref($label)) { $cols_output = (scalar(@$label)); @@ -2664,9 +2675,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 @@ -2775,7 +2787,7 @@ sub tmpwrite { $ENV{'user.domain'}.'_spreadsheet_'.$self->{'usymb'}.'_'. $self->{'filename'}; $fn=~s/\W/\_/g; - $fn=$tmpdir.$fn.'.tmp'; + $fn=$Apache::lonnet::tmpdir.$fn.'.tmp'; my $fh; if ($fh=Apache::File->new('>'.$fn)) { my %f = $self->formulas(); @@ -2794,7 +2806,7 @@ sub tmpread { $ENV{'user.domain'}.'_spreadsheet_'.$self->{'usymb'}.'_'. $self->{'filename'}; $fn=~s/\W/\_/g; - $fn=$tmpdir.$fn.'.tmp'; + $fn=$Apache::lonnet::tmpdir.$fn.'.tmp'; my $fh; my %fo=(); my $countrows=0; @@ -2978,8 +2990,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 @@ -3031,8 +3044,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 @@ -3076,9 +3090,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 { @@ -3129,14 +3142,17 @@ sub loadstudent{ my %formulas = $self->formulas(); $cachedassess = $self->{'uname'}.':'.$self->{'udom'}; # Get ALL the student preformance data - my @tmp = &Apache::lonnet::currentdump($self->{'cid'}, - $self->{'udom'}, - $self->{'uname'}); + my @tmp = &Apache::loncoursedata::get_current_state($self->{'uname'}, + $self->{'udom'}, + undef, + $self->{'cid'}); if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) { %cachedstores = @tmp; } undef @tmp; - # + # debugging code + # $self->dump_hash_to_log(\%cachedstores); + # my @assessdata=(); foreach my $row ($self->rows()) { my $cell = 'A'.$row; @@ -3169,7 +3185,7 @@ sub loadstudent{ $self->constants(\%constants); } -# --------------------------------------------------- Load data for one student +# --------------------------------------------------- Load Course Sheet # sub loadcourse { my $self = shift; @@ -3190,12 +3206,14 @@ sub loadcourse { popwin.document.writeln(''+ '

Spreadsheet Calculation Progress

'+ '
'+ - '
'+ + ''+ ''); popwin.document.close(); 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; @@ -3210,7 +3228,8 @@ ENDPOP $now++; $r->print(''); + ' secs remaining '.(time-$started).' last student";'. + ''); $r->rflush(); # my $index=0;