version 1.71, 2006/09/03 00:45:51
|
version 1.80, 2008/09/12 14:35:46
|
Line 210 sub make_default {
|
Line 210 sub make_default {
|
{'spreadsheet_default_'.$self->{'type'} => $self->filename()}, |
{'spreadsheet_default_'.$self->{'type'} => $self->filename()}, |
$self->{'cdom'},$self->{'cnum'}); |
$self->{'cdom'},$self->{'cnum'}); |
return $result if ($result ne 'ok'); |
return $result if ($result ne 'ok'); |
&Apache::lonnet::appenv('course.'.$self->{'cid'}.'.spreadsheet_default_'. |
&Apache::lonnet::appenv({'course.'.$self->{'cid'}.'.spreadsheet_default_'. |
$self->{'type'} => $self->filename()); |
$self->{'type'} => $self->filename()}); |
my $symb = $self->{'symb'}; |
my $symb = $self->{'symb'}; |
$symb = '' if (! defined($symb)); |
$symb = '' if (! defined($symb)); |
&Apache::lonnet::expirespread('','',$self->{'type'},$symb); |
&Apache::lonnet::expirespread('','',$self->{'type'},$symb); |
Line 675 sub MAXPARM {
|
Line 675 sub MAXPARM {
|
return $max; |
return $max; |
} |
} |
|
|
|
|
|
=pod |
|
|
|
=item PARM(parametername) |
|
|
|
Returns the value of the parameter matching the input parameter name. |
|
parametername should be a string such as 'parameter_1_opendate'. |
|
|
|
=cut |
|
|
|
#------------------------------------------------------- |
|
sub PARM { |
|
return $c{$_[0]}; |
|
} |
|
|
#------------------------------------------------------- |
#------------------------------------------------------- |
|
|
=pod |
=pod |
Line 805 sub expandnamed {
|
Line 820 sub expandnamed {
|
my $self = shift; |
my $self = shift; |
my $expression=shift; |
my $expression=shift; |
if ($expression=~/^\&/) { |
if ($expression=~/^\&/) { |
my ($func,$var,$formula)=($expression=~/^\&(\w+)\(([^\;]+)\;(.*)\)/); |
my ($func,$var,$formula)=($expression=~/^\&(\w+)\(([^\;]+)\;(.*)\)/s); |
my @vars=split(/\W+/,$formula); |
my @vars=split(/\W+/,$formula); |
|
# make the list uniq |
|
@vars = keys(%{{ map { $_ => 1 } @vars }}); |
my %values=(); |
my %values=(); |
foreach my $varname ( @vars ) { |
foreach my $varname ( @vars ) { |
if ($varname=~/^(parameter|stores|timestamp)/) { |
if ($varname=~/^(parameter|stores|timestamp)/) { |
$formula=~s/$varname/'$c{\''.$varname.'\'}'/ge; |
$formula=~s/$varname/'$c{\''.$varname.'\'}'/ge; |
$varname=~s/$var/\([\\w:\\- ]\+\)/g; |
$varname=~s/$var/\([\\w:\\- ]\+\)/g; |
foreach (keys(%{$self->{'constants'}})) { |
foreach (keys(%{$self->{'constants'}})) { |
if ($_=~/$varname/) { |
if ($_=~/$varname/) { |
$values{$1}=1; |
$values{$1}=1; |
} |
} |
} |
} |
} |
} |
} |
} |
if ($func eq 'EXPANDSUM') { |
if ($func eq 'EXPANDSUM') { |
Line 890 sub sett {
|
Line 907 sub sett {
|
# Replace 'A0' with the value from 'A0' |
# Replace 'A0' with the value from 'A0' |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
# Replace parameters |
# Replace parameters |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge; |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/sge; |
} |
} |
} |
} |
# |
# |
Line 902 sub sett {
|
Line 919 sub sett {
|
$t{$cell}=$formula; |
$t{$cell}=$formula; |
$t{$cell}=~s/\.\.+/\,/g; |
$t{$cell}=~s/\.\.+/\,/g; |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge; |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/sge; |
} elsif ( $col =~ /^[A-Z]$/ ) { |
} elsif ( $col =~ /^[A-Z]$/ ) { |
if ($formula !~ /^\!/ && exists($self->{'constants'}->{$cell}) |
if ($formula !~ /^\!/ && exists($self->{'constants'}->{$cell}) |
&& $self->{'constants'}->{$cell} ne '') { |
&& $self->{'constants'}->{$cell} ne '') { |
Line 913 sub sett {
|
Line 930 sub sett {
|
$t{$cell}=$formula; |
$t{$cell}=$formula; |
$t{$cell}=~s/\.\.+/\,/g; |
$t{$cell}=~s/\.\.+/\,/g; |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
$t{$cell}=~s/(^|[^\"\'])([A-Za-z]\d+)/$1\$sheet_values\{\'$2\'\}/g; |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/ge; |
$t{$cell}=~s/(^|[^\"\'])\[([^\]]+)\]/$1.$self->expandnamed($2)/sge; |
} |
} |
} |
} |
%{$self->{'safe'}->varglob('t')}=%t; |
%{$self->{'safe'}->varglob('t')}=%t; |
Line 1508 sub outsheet_csv {
|
Line 1525 sub outsheet_csv {
|
my $csvdata = ''; |
my $csvdata = ''; |
my @Values; |
my @Values; |
# |
# |
# Open the csv file |
# Open the CSV file |
my $filename = '/prtspool/'. |
my $filename = '/prtspool/'. |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
time.'_'.rand(1000000000).'.csv'; |
time.'_'.rand(1000000000).'.csv'; |
my $file; |
my $file; |
unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) { |
unless ($file = Apache::File->new('>'.'/home/httpd'.$filename)) { |
$r->log_error("Couldn't open $filename for output $!"); |
$r->log_error("Couldn't open $filename for output $!"); |
$r->print(&mt("Problems occured in writing the csv file. ". |
$r->print(&mt('Problems occurred in writing the CSV file. ' |
"This error has been logged. ". |
.'This error has been logged. ' |
"Please alert your LON-CAPA administrator.")); |
.'Please alert your LON-CAPA administrator.')); |
$r->print("<pre>\n".$csvdata."</pre>\n"); |
$r->print("<pre>\n".$csvdata."</pre>\n"); |
return 0; |
return 0; |
} |
} |
Line 1530 sub outsheet_csv {
|
Line 1547 sub outsheet_csv {
|
# Output the body of the spreadsheet |
# Output the body of the spreadsheet |
$self->csv_rows($connection,$file); |
$self->csv_rows($connection,$file); |
# |
# |
# Close the csv file |
# Close the CSV file |
close($file); |
close($file); |
$r->print('<br /><br />'. |
$r->print('<br /><br />'. |
'<a href="'.$filename.'">'.&mt('Your CSV spreadsheet.').'</a>'."\n"); |
'<a href="'.$filename.'">'.&mt('Your CSV spreadsheet.').'</a>'."\n"); |
Line 1792 sub save {
|
Line 1809 sub save {
|
{'spreadsheet_default_'.$stype => $filename }, |
{'spreadsheet_default_'.$stype => $filename }, |
$cdom,$cnum); |
$cdom,$cnum); |
return $reply if ($reply ne 'ok'); |
return $reply if ($reply ne 'ok'); |
&Apache::lonnet::appenv('course.'.$self->{'cid'}.'.spreadsheet_default_'. |
&Apache::lonnet::appenv({'course.'.$self->{'cid'}.'.spreadsheet_default_'. |
$self->{'type'} => $self->filename()); |
$self->{'type'} => $self->filename()}); |
} |
} |
if ($self->is_default()) { |
if ($self->{'type'} eq 'studentcalc') { |
if ($self->{'type'} eq 'studentcalc') { |
&Apache::lonnet::expirespread('','','studentcalc',''); |
&Apache::lonnet::expirespread('','','studentcalc',''); |
} elsif ($self->{'type'} eq 'assesscalc') { |
} elsif ($self->{'type'} eq 'assesscalc') { |
&Apache::lonnet::expirespread('','','assesscalc',''); |
&Apache::lonnet::expirespread('','','assesscalc',''); |
&Apache::lonnet::expirespread('','','studentcalc',''); |
&Apache::lonnet::expirespread('','','studentcalc',''); |
|
} |
|
} |
} |
return $reply; |
return $reply; |
} |
} |
Line 1891 sub othersheets {
|
Line 1906 sub othersheets {
|
$self->{'cdom'}, $self->{'cnum'}); |
$self->{'cdom'}, $self->{'cnum'}); |
my ($tmp) = keys(%results); |
my ($tmp) = keys(%results); |
if (%results |
if (%results |
&& $tmp =~ /^(con_lost|error|no_such_host)/i ) { |
&& $tmp !~ /^(con_lost|error|no_such_host)/i ) { |
push(@alternatives, sort(keys(%results))); |
push(@alternatives, sort(keys(%results))); |
} |
} |
return @alternatives; |
return @alternatives; |