version 1.38, 2001/01/22 22:54:16
|
version 1.39, 2001/03/05 21:26:29
|
Line 3
|
Line 3
|
# |
# |
# 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 Gerd Kortemeyer |
# 01/01/01,02/01,03/01,19/01,20/01,22/01, |
|
# 03/05 Gerd Kortemeyer |
|
|
package Apache::lonspreadsheet; |
package Apache::lonspreadsheet; |
|
|
Line 17 use GDBM_File;
|
Line 18 use GDBM_File;
|
use HTML::TokeParser; |
use HTML::TokeParser; |
|
|
# |
# |
|
# Cache for stores of an individual user |
|
# |
|
|
|
my $cachedassess; |
|
my %cachedstores; |
|
|
|
# |
# These cache hashes need to be independent of user, resource and course |
# These cache hashes need to be independent of user, resource and course |
# (user and course can/should be in the keys) |
# (user and course can/should be in the keys) |
# |
# |
Line 1191 sub loadstudent {
|
Line 1199 sub loadstudent {
|
my $safeeval=shift; |
my $safeeval=shift; |
my %c=(); |
my %c=(); |
my %f=&getformulas($safeeval); |
my %f=&getformulas($safeeval); |
|
$cachedassess=&getuname($safeeval).':'.&getudom($safeeval); |
|
%cachedstores=(); |
|
{ |
|
my $reply=&Apache::lonnet::reply('dump:'.&getudom($safeeval).':'. |
|
&getuname($safeeval).':'. |
|
&getcid($safeeval), |
|
&getuhome($safeeval)); |
|
unless ($reply=~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$cachedstores{&Apache::lonnet::unescape($name)}= |
|
&Apache::lonnet::unescape($value); |
|
} split(/\&/,$reply); |
|
} |
|
} |
my @assessdata=(); |
my @assessdata=(); |
map { |
map { |
if ($_=~/^A(\d+)/) { |
if ($_=~/^A(\d+)/) { |
Line 1213 sub loadstudent {
|
Line 1236 sub loadstudent {
|
} |
} |
} |
} |
} keys %f; |
} keys %f; |
|
$cachedassess=''; |
|
undef %cachedstores; |
&setformulas($safeeval,%f); |
&setformulas($safeeval,%f); |
&setconstants($safeeval,%c); |
&setconstants($safeeval,%c); |
} |
} |
Line 1231 sub loadcourse {
|
Line 1256 sub loadcourse {
|
} keys %f; |
} keys %f; |
my $now=0; |
my $now=0; |
my $since=time; |
my $since=time; |
$r->print('<br><input type=text size=35 name=remaining value=Starting>'. |
$r->print(<<ENDPOP); |
"<br><font size=0>\n"); |
<script> |
|
popwin=open('','popwin','width=400,height=100'); |
|
popwin.document.writeln('<html><body bgcolor="#FFFFFF">'+ |
|
'<h1>Spreadsheet Calculation Progress</h1>'+ |
|
'<form name=popremain>'+ |
|
'<input type=text size=35 name=remaining value=Starting></form>'+ |
|
'</body></html>'); |
|
popwin.document.close; |
|
</script> |
|
ENDPOP |
$r->rflush(); |
$r->rflush(); |
map { |
map { |
if ($_=~/^A(\d+)/) { |
if ($_=~/^A(\d+)/) { |
Line 1242 sub loadcourse {
|
Line 1276 sub loadcourse {
|
'studentcalc'); |
'studentcalc'); |
undef %userrdatas; |
undef %userrdatas; |
$now++; |
$now++; |
$r->print('<script>document.sheet.remaining.value="'. |
$r->print('<script>popwin.document.popremain.remaining.value="'. |
$now.'/'.$total.': '.int((time-$since)/$now*($total-$now)). |
$now.'/'.$total.': '.int((time-$since)/$now*($total-$now)). |
' secs remaining";</script>'."<br>\n"); |
' secs remaining";</script>'); |
$r->rflush(); |
$r->rflush(); |
|
|
my $index=0; |
my $index=0; |
Line 1263 sub loadcourse {
|
Line 1297 sub loadcourse {
|
} keys %f; |
} keys %f; |
&setformulas($safeeval,%f); |
&setformulas($safeeval,%f); |
&setconstants($safeeval,%c); |
&setconstants($safeeval,%c); |
$r->print('<script>document.sheet.remaining.value="Done";</script>'. |
$r->print('<script>popwin.close</script>'); |
"<br>\n</font>"); |
|
$r->rflush(); |
$r->rflush(); |
} |
} |
|
|
Line 1286 sub loadassessment {
|
Line 1319 sub loadassessment {
|
unless ($namespace=$cid) { return ''; } |
unless ($namespace=$cid) { return ''; } |
|
|
# ----------------------------------------------------------- Get stored values |
# ----------------------------------------------------------- Get stored values |
|
|
|
my %returnhash=(); |
|
|
|
if ($cachedassess eq $uname.':'.$udom) { |
|
# |
|
# get data out of the dumped stores |
|
# |
|
|
|
my $version=$cachedstores{'version:'.$symb}; |
|
my $scope; |
|
for ($scope=1;$scope<=$version;$scope++) { |
|
map { |
|
$returnhash{$_}=$cachedstores{$scope.':'.$symb.':'.$_}; |
|
} split(/\:/,$cachedstores{$scope.':keys:'.$symb}); |
|
} |
|
|
|
} else { |
|
# |
|
# restore individual |
|
# |
|
|
my $answer=&Apache::lonnet::reply( |
my $answer=&Apache::lonnet::reply( |
"restore:$udom:$uname:". |
"restore:$udom:$uname:". |
&Apache::lonnet::escape($namespace).":". |
&Apache::lonnet::escape($namespace).":". |
&Apache::lonnet::escape($symb),$uhome); |
&Apache::lonnet::escape($symb),$uhome); |
|
|
my %returnhash=(); |
|
map { |
map { |
my ($name,$value)=split(/\=/,$_); |
my ($name,$value)=split(/\=/,$_); |
$returnhash{&Apache::lonnet::unescape($name)}= |
$returnhash{&Apache::lonnet::unescape($name)}= |
Line 1303 sub loadassessment {
|
Line 1355 sub loadassessment {
|
$returnhash{$_}=$returnhash{$version.':'.$_}; |
$returnhash{$_}=$returnhash{$version.':'.$_}; |
} split(/\:/,$returnhash{$version.':keys'}); |
} split(/\:/,$returnhash{$version.':keys'}); |
} |
} |
|
} |
# ----------------------------- returnhash now has all stores for this resource |
# ----------------------------- returnhash now has all stores for this resource |
|
|
# ---------------------------- initialize coursedata and userdata for this user |
# ---------------------------- initialize coursedata and userdata for this user |
Line 1634 ENDSCRIPT
|
Line 1686 ENDSCRIPT
|
&outsheet($r,$asheet); |
&outsheet($r,$asheet); |
$r->print('</form></body></html>'); |
$r->print('</form></body></html>'); |
|
|
# --------------------------------- We know this leaks, so terminate this child |
|
|
|
$r->child_terminate(); |
|
|
|
# ------------------------------------------------------------------------ Done |
# ------------------------------------------------------------------------ Done |
} else { |
} else { |
# ----------------------------- Not in a course, or not allowed to modify parms |
# ----------------------------- Not in a course, or not allowed to modify parms |