version 1.130, 2002/10/29 16:04:13
|
version 1.131, 2002/10/30 15:07:20
|
Line 1077 sub calcsheet {
|
Line 1077 sub calcsheet {
|
} |
} |
|
|
# ---------------------------------------------------------------- Get formulas |
# ---------------------------------------------------------------- Get formulas |
|
# Return a copy of the formulas |
sub getformulas { |
sub getformulas { |
my $sheet = shift; |
my $sheet = shift; |
return %{$sheet->{'safe'}->varglob('f')}; |
return %{$sheet->{'safe'}->varglob('f')}; |
Line 1454 sub writesheet {
|
Line 1455 sub writesheet {
|
# Cache new sheet |
# Cache new sheet |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
$spreadsheets{$cnum.'_'.$cdom.'_'.$stype.'_'.$fn}=join('___;___',%f); |
# Write sheet |
# Write sheet |
my $sheetdata=''; |
|
foreach (keys(%f)) { |
foreach (keys(%f)) { |
unless ($f{$_} eq 'import') { |
delete($f{$_}) if ($f{$_} eq 'import'); |
$sheetdata.=&Apache::lonnet::escape($_).'='. |
|
&Apache::lonnet::escape($f{$_}).'&'; |
|
} |
|
} |
} |
$sheetdata=~s/\&$//; |
my $reply = &Apache::lonnet::put($fn,\%f,$cdom,$cnum); |
my $reply=&Apache::lonnet::reply('put:'.$cdom.':'.$cnum.':'.$fn.':'. |
|
$sheetdata,$chome); |
|
if ($reply eq 'ok') { |
if ($reply eq 'ok') { |
$reply=&Apache::lonnet::reply('put:'.$cdom.':'.$cnum.':'. |
$reply = &Apache::lonnet::put($stype.'_spreadsheets', |
$stype.'_spreadsheets:'. |
{$fn => $ENV{'user.name'}.'@'.$ENV{'user.domain'}}, |
&Apache::lonnet::escape($fn). |
$cdom,$cnum); |
'='.$ENV{'user.name'}.'@'. |
|
$ENV{'user.domain'}, |
|
$chome); |
|
if ($reply eq 'ok') { |
if ($reply eq 'ok') { |
if ($makedef) { |
if ($makedef) { |
return &Apache::lonnet::reply('put:'.$cdom.':'.$cnum. |
return &Apache::lonnet::put('environment', |
':environment:'. |
{'spreadsheet_default_'.$stype => $fn }, |
'spreadsheet_default_'. |
$cdom,$cnum); |
$stype.'='. |
|
&Apache::lonnet::escape($fn), |
|
$chome); |
|
} |
} |
return $reply; |
return $reply; |
} |
} |
Line 2234 sub exportsheet {
|
Line 2223 sub exportsheet {
|
&loadrows($newsheet); |
&loadrows($newsheet); |
&calcsheet($newsheet); |
&calcsheet($newsheet); |
@exportarr=&exportdata($newsheet); |
@exportarr=&exportdata($newsheet); |
|
## |
|
## Store now |
|
## |
# |
# |
# Store now |
# load in the old value |
# |
# |
my $cid=$newsheet->{'cid'}; |
my %currentlystored=(); |
my $current=''; |
|
if ($stype eq 'studentcalc') { |
if ($stype eq 'studentcalc') { |
$current=&Apache::lonnet::reply('get:'.$sheet->{'cdom'}.':'. |
my @tmp = &Apache::lonnet::get('nohist_calculatedsheets', |
$sheet->{'cnum'}. |
[$key], |
':nohist_calculatedsheets:'. |
$sheet->{'cdom'},$sheet->{'cnum'}); |
&Apache::lonnet::escape($key), |
if ($tmp[0]!~/^error/) { |
$sheet->{'chome'}); |
%currentlystored = @tmp; |
|
} |
} else { |
} else { |
$current=&Apache::lonnet::reply('get:'.$sheet->{'udom'}.':'. |
my @tmp = &Apache::lonnet::get('nohist_calculatedsheets_'. |
$sheet->{'uname'}. |
$sheet->{'cid'},[$key], |
':nohist_calculatedsheets_'. |
$sheet->{'udom'},$sheet->{'uname'}); |
$sheet->{'cid'}.':'. |
if ($tmp[0]!~/^error/) { |
&Apache::lonnet::escape($key), |
%currentlystored = @tmp; |
$sheet->{'uhome'}); |
|
} |
|
my %currentlystored=(); |
|
unless ($current=~/^error\:/) { |
|
foreach (split(/___&\___/,&Apache::lonnet::unescape($current))) { |
|
my ($name,$value)=split(/___=___/,$_); |
|
$currentlystored{$name}=$value; |
|
} |
} |
} |
} |
|
# |
|
# Add the new line |
|
# |
$currentlystored{$fn}=join('___;___',@exportarr); |
$currentlystored{$fn}=join('___;___',@exportarr); |
# |
# |
|
# Stick everything back together |
|
# |
my $newstore=''; |
my $newstore=''; |
foreach (keys(%currentlystored)) { |
foreach (keys(%currentlystored)) { |
if ($newstore) { $newstore.='___&___'; } |
if ($newstore) { $newstore.='___&___'; } |
$newstore.=$_.'___=___'.$currentlystored{$_}; |
$newstore.=$_.'___=___'.$currentlystored{$_}; |
} |
} |
my $now=time; |
my $now=time; |
|
# |
|
# Store away the new value |
|
# |
if ($stype eq 'studentcalc') { |
if ($stype eq 'studentcalc') { |
&Apache::lonnet::put('nohist_calculatedsheets', |
&Apache::lonnet::put('nohist_calculatedsheets', |
{ $key => $newstore, |
{ $key => $newstore, |
$key.time => $now }, |
$key.time => $now }, |
$sheet->{'cid'},$sheet->{'cnum'}); |
$sheet->{'cdom'},$sheet->{'cnum'}); |
} else { |
} else { |
&Apache::lonnet::put('nohist_calculatedsheets_'.$sheet->{'cid'}, |
&Apache::lonnet::put('nohist_calculatedsheets_'.$sheet->{'cid'}, |
{ $key => $newstore, |
{ $key => $newstore, |