version 1.46, 2001/03/17 20:43:57
|
version 1.48, 2001/03/20 21:34:34
|
Line 4
|
Line 4
|
# 11/11,11/15,11/27,12/04,12/05,12/06,12/07, |
# 11/11,11/15,11/27,12/04,12/05,12/06,12/07, |
# 12/08,12/09,12/11,12/12,12/15,12/16,12/18,12/19,12/30, |
# 12/08,12/09,12/11,12/12,12/15,12/16,12/18,12/19,12/30, |
# 01/01/01,02/01,03/01,19/01,20/01,22/01, |
# 01/01/01,02/01,03/01,19/01,20/01,22/01, |
# 03/05,03/08,03/10,03/12,03/13,03/15,03/17 Gerd Kortemeyer |
# 03/05,03/08,03/10,03/12,03/13,03/15,03/17, |
|
# 03/19,03/20 Gerd Kortemeyer |
|
|
package Apache::lonspreadsheet; |
package Apache::lonspreadsheet; |
|
|
Line 23 use HTML::TokeParser;
|
Line 24 use HTML::TokeParser;
|
|
|
my %oldsheets; |
my %oldsheets; |
my %loadedcaches; |
my %loadedcaches; |
|
my %expiredates; |
|
|
# |
# |
# Cache for stores of an individual user |
# Cache for stores of an individual user |
Line 1486 sub loadrows {
|
Line 1488 sub loadrows {
|
} |
} |
} |
} |
|
|
|
# ======================================================= Forced recalculation? |
|
|
|
sub checkthis { |
|
my ($keyname,$time)=@_; |
|
return ($time<$expiredates{$keyname}); |
|
} |
|
sub forcedrecalc { |
|
my ($uname,$udom,$stype,$usymb)=@_; |
|
my $key=$uname.':'.$udom.':'.$stype.':'.$usymb; |
|
my $time=$oldsheets{$key.'.time'}; |
|
unless ($time) { return 1; } |
|
if ($stype eq 'assesscalc') { |
|
my $map=(split(/\_\_\_/,$usymb))[0]; |
|
if (&checkthis('::assesscalc:',$time) || |
|
&checkthis('::assesscalc:'.$map,$time) || |
|
&checkthis('::assesscalc:'.$usymb,$time) || |
|
&checkthis($uname.':'.$udom.':assesscalc:',$time)) { |
|
return 1; |
|
} |
|
} else { |
|
if (&checkthis('::studentcalc:',$time) || |
|
&checkthis($uname.':'.$udom.':studencalc:',$time)) { |
|
return 1; |
|
} |
|
} |
|
return 0; |
|
} |
|
|
# ============================================================== Export handler |
# ============================================================== Export handler |
# |
# |
# Non-interactive call from with program |
# Non-interactive call from with program |
Line 1521 sub exportsheet {
|
Line 1551 sub exportsheet {
|
} split(/\_\_\_\&\_\_\_/,$oldsheets{$key}); |
} split(/\_\_\_\&\_\_\_/,$oldsheets{$key}); |
} |
} |
} |
} |
|
# |
|
# Check if still valid |
|
# |
|
if ($found) { |
|
if (&forcedrecalc($uname,$udom,$stype,$usymb)) { |
|
$found=''; |
|
} |
|
} |
|
|
if ($found) { |
if ($found) { |
# |
# |
# Return what was cached |
# Return what was cached |
Line 1543 sub exportsheet {
|
Line 1581 sub exportsheet {
|
# Store now |
# Store now |
# |
# |
my $cid=$ENV{'request.course.id'}; |
my $cid=$ENV{'request.course.id'}; |
my $current=(); |
my $current=''; |
if ($stype eq 'studentcalc') { |
if ($stype eq 'studentcalc') { |
$current=&Apache::lonnet::reply('get:'. |
$current=&Apache::lonnet::reply('get:'. |
$ENV{'course.'.$cid.'.domain'}.':'. |
$ENV{'course.'.$cid.'.domain'}.':'. |
Line 1575 sub exportsheet {
|
Line 1613 sub exportsheet {
|
if ($newstore) { $newstore.='___&___'; } |
if ($newstore) { $newstore.='___&___'; } |
$newstore.=$_.'___=___'.$currentlystored{$_}; |
$newstore.=$_.'___=___'.$currentlystored{$_}; |
} keys %currentlystored; |
} keys %currentlystored; |
|
my $now=time; |
if ($stype eq 'studentcalc') { |
if ($stype eq 'studentcalc') { |
&Apache::lonnet::reply('put:'. |
&Apache::lonnet::reply('put:'. |
$ENV{'course.'.$cid.'.domain'}.':'. |
$ENV{'course.'.$cid.'.domain'}.':'. |
$ENV{'course.'.$cid.'.num'}. |
$ENV{'course.'.$cid.'.num'}. |
':nohist_calculatedsheets:'. |
':nohist_calculatedsheets:'. |
&Apache::lonnet::escape($key).'='. |
&Apache::lonnet::escape($key).'='. |
&Apache::lonnet::escape($newstore), |
&Apache::lonnet::escape($newstore).'&'. |
|
&Apache::lonnet::escape($key).'.time='.$now, |
$ENV{'course.'.$cid.'.home'}); |
$ENV{'course.'.$cid.'.home'}); |
} else { |
} else { |
&Apache::lonnet::reply('put:'. |
&Apache::lonnet::reply('put:'. |
Line 1590 sub exportsheet {
|
Line 1630 sub exportsheet {
|
':nohist_calculatedsheets_'. |
':nohist_calculatedsheets_'. |
$ENV{'request.course.id'}.':'. |
$ENV{'request.course.id'}.':'. |
&Apache::lonnet::escape($key).'='. |
&Apache::lonnet::escape($key).'='. |
&Apache::lonnet::escape($newstore), |
&Apache::lonnet::escape($newstore).'&'. |
|
&Apache::lonnet::escape($key).'.time='.$now, |
&getuhome($thissheet)); |
&getuhome($thissheet)); |
} |
} |
} |
} |
return @exportarr; |
return @exportarr; |
} |
} |
|
# ============================================================ Expiration Dates |
|
# |
|
# Load previously cached student spreadsheets for this course |
|
# |
|
|
|
sub expirationdates { |
|
undef %expiredates; |
|
my $cid=$ENV{'request.course.id'}; |
|
my $reply=&Apache::lonnet::reply('dump:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_expirationdates', |
|
$ENV{'course.'.$cid.'.home'}); |
|
unless ($reply=~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$expiredates{&Apache::lonnet::unescape($name)} |
|
=&Apache::lonnet::unescape($value); |
|
} split(/\&/,$reply); |
|
} |
|
} |
|
|
# ===================================================== Calculated sheets cache |
# ===================================================== Calculated sheets cache |
# |
# |
Line 1817 ENDSCRIPT
|
Line 1879 ENDSCRIPT
|
|
|
# --------------------------------------------------------------- Cached sheets |
# --------------------------------------------------------------- Cached sheets |
|
|
|
&expirationdates(); |
|
|
undef %oldsheets; |
undef %oldsheets; |
undef %loadedcaches; |
undef %loadedcaches; |
|
|