version 1.43, 2001/03/12 18:27:46
|
version 1.44, 2001/03/13 15:50:47
|
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 Gerd Kortemeyer |
# 03/05,03/08,03/10,03/12,03/13 Gerd Kortemeyer |
|
|
package Apache::lonspreadsheet; |
package Apache::lonspreadsheet; |
|
|
Line 18 use GDBM_File;
|
Line 18 use GDBM_File;
|
use HTML::TokeParser; |
use HTML::TokeParser; |
|
|
# |
# |
|
# Caches for previously calculated spreadsheets |
|
# |
|
|
|
my %oldsheets; |
|
|
|
# |
# Cache for stores of an individual user |
# Cache for stores of an individual user |
# |
# |
|
|
Line 1482 sub loadrows {
|
Line 1488 sub loadrows {
|
# |
# |
|
|
sub exportsheet { |
sub exportsheet { |
|
my ($uname,$udom,$stype,$usymb,$fn)=@_; |
my ($uname,$udom,$stype,$usymb,$fn)=@_; |
my @exportarr=(); |
|
# |
|
# Check if cached |
|
# |
|
my $key=$uname.':'.$udom.':'.$stype.':'.$usymb; |
|
my $found=''; |
|
|
|
if ($oldsheets{$key}) { |
|
map { |
|
my ($name,$value)=split(/\_\_\_\=\_\_\_/,$_); |
|
if ($name eq $fn) { |
|
$found=$value; |
|
} |
|
} split(/\_\_\_\&\_\_\_/,$oldsheets{$key}); |
|
} |
|
|
|
if ($found) { |
|
# |
|
# Return what was cached |
|
# |
|
@exportarr=split(/\_\_\_\;\_\_\_/,$found); |
|
|
|
} else { |
|
# |
|
# Not cached |
|
# |
my $thissheet=&makenewsheet($uname,$udom,$stype,$usymb); |
my $thissheet=&makenewsheet($uname,$udom,$stype,$usymb); |
&readsheet($thissheet,$fn); |
&readsheet($thissheet,$fn); |
&updatesheet($thissheet); |
&updatesheet($thissheet); |
&loadrows($thissheet); |
&loadrows($thissheet); |
&calcsheet($thissheet); |
&calcsheet($thissheet); |
return &exportdata($thissheet); |
@exportarr=&exportdata($thissheet); |
|
# |
|
# Store now |
|
# |
|
my $cid=$ENV{'request.course.id'}; |
|
my $current=&Apache::lonnet::reply('get:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
|
&Apache::lonnet::escape($key), |
|
$ENV{'course.'.$cid.'.home'}); |
|
my %currentlystored=(); |
|
unless ($current=~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\_\_\_\=\_\_\_/,$_); |
|
$currentlystored{$name}=$value; |
|
} split(/\_\_\_\&\_\_\_/,&Apache::lonnet::unescape($current)); |
|
} |
|
$currentlystored{$fn}=join('___;___',@exportarr); |
|
|
|
my $newstore=''; |
|
map { |
|
if ($newstore) { $newstore.='___&___'; } |
|
$newstore.=$_.'___=___'.$currentlystored{$_}; |
|
} keys %currentlystored; |
|
&Apache::lonnet::reply('put:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets:'. |
|
&Apache::lonnet::escape($key).'='. |
|
&Apache::lonnet::escape($newstore), |
|
$ENV{'course.'.$cid.'.home'}); |
|
} |
|
return @exportarr; |
|
} |
|
|
|
# ===================================================== Calculated sheets cache |
|
# |
|
# Load all previously cached spreadsheets for this course |
|
# |
|
|
|
sub cachedsheets { |
|
my $cid=$ENV{'request.course.id'}; |
|
my $reply=&Apache::lonnet::reply('dump:'. |
|
$ENV{'course.'.$cid.'.domain'}.':'. |
|
$ENV{'course.'.$cid.'.num'}. |
|
':nohist_calculatedsheets', |
|
$ENV{'course.'.$cid.'.home'}); |
|
undef %oldsheets; |
|
unless ($reply=~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$oldsheets{&Apache::lonnet::unescape($name)} |
|
=&Apache::lonnet::unescape($value); |
|
} split(/\&/,$reply); |
|
} |
} |
} |
|
|
# ================================================================ Main handler |
# ================================================================ Main handler |
Line 1660 ENDSCRIPT
|
Line 1746 ENDSCRIPT
|
|
|
$r->print(&hiddenfield('ufn',&getfilename($asheet))); |
$r->print(&hiddenfield('ufn',&getfilename($asheet))); |
|
|
|
# ----------------------------------------------------------- Get cached sheets |
|
|
|
&cachedsheets(); |
|
|
# ----------------------------------------------------- Update sheet, load rows |
# ----------------------------------------------------- Update sheet, load rows |
|
|
$r->print("Loaded sheet, updating rows ...<br>\n"); |
$r->print("Loaded sheet(s), updating rows ...<br>\n"); |
$r->rflush(); |
$r->rflush(); |
|
|
&updatesheet($asheet); |
&updatesheet($asheet); |
Line 1695 ENDSCRIPT
|
Line 1784 ENDSCRIPT
|
|
|
1; |
1; |
__END__ |
__END__ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|