version 1.45, 2005/05/13 15:59:07
|
version 1.48, 2005/05/15 04:02:17
|
Line 106 sub new {
|
Line 106 sub new {
|
cid => $env{'request.course.id'}, |
cid => $env{'request.course.id'}, |
cnum => $env{'course.'.$env{'request.course.id'}.'.num'}, |
cnum => $env{'course.'.$env{'request.course.id'}.'.num'}, |
cdom => $env{'course.'.$env{'request.course.id'}.'.domain'}, |
cdom => $env{'course.'.$env{'request.course.id'}.'.domain'}, |
chome => $env{'course.'.$env{'request.course.id'}.'.home'}, |
|
coursedesc => $env{'course.'.$env{'request.course.id'}.'.description'}, |
coursedesc => $env{'course.'.$env{'request.course.id'}.'.description'}, |
coursefilename => $env{'request.course.fn'}, |
coursefilename => $env{'request.course.fn'}, |
# |
# |
Line 126 sub new {
|
Line 125 sub new {
|
othersheets => [], |
othersheets => [], |
}; |
}; |
# |
# |
$self->{'uhome'} = &Apache::lonnet::homeserver($name,$domain); |
|
# |
|
bless($self,$class); |
bless($self,$class); |
# |
# |
# Load in the spreadsheet definition |
# Load in the spreadsheet definition |
Line 330 sub initialize_safe_space {
|
Line 327 sub initialize_safe_space {
|
$safehole->wrap(\&mask,$safeeval,'&mask'); |
$safehole->wrap(\&mask,$safeeval,'&mask'); |
$safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&logthis'); |
$safehole->wrap(\&Apache::lonnet::logthis,$safeeval,'&logthis'); |
$safeeval->share('$@'); |
$safeeval->share('$@'); |
|
# Holds the (computed, final) values for the sheet |
|
# This is only written to by &calc, the spreadsheet computation routine. |
|
# It is read by many functions |
|
$safeeval->share('%sheet_values'); |
my $code=<<'ENDDEFS'; |
my $code=<<'ENDDEFS'; |
# ---------------------------------------------------- Inside of the safe space |
# ---------------------------------------------------- Inside of the safe space |
# |
# |
Line 339 sub initialize_safe_space {
|
Line 340 sub initialize_safe_space {
|
# c: preloaded constants (A-column) |
# c: preloaded constants (A-column) |
# rl: row label |
# rl: row label |
# os: other spreadsheets (for student spreadsheet only) |
# os: other spreadsheets (for student spreadsheet only) |
undef %sheet_values; # Holds the (computed, final) values for the sheet |
undef %t; # Holds the forumlas of the spreadsheet to be computed. Set in |
# This is only written to by &calc, the spreadsheet computation routine. |
# &sett, which does the translation of strings like C5 into the value |
# It is read by many functions |
# in C5. Used in &calc - %t holds the values that are actually eval'd. |
undef %t; # Holds the values of the spreadsheet temporarily. Set in &sett, |
|
# which does the translation of strings like C5 into the value in C5. |
|
# Used in &calc - %t holds the values that are actually eval'd. |
|
undef %f; # Holds the formulas for each cell. This is the users |
undef %f; # Holds the formulas for each cell. This is the users |
# (spreadsheet authors) data for each cell. |
# (spreadsheet authors) data for each cell. |
undef %c; # Holds the constants for a sheet. In the assessment |
undef %c; # Holds the constants for a sheet. In the assessment |
Line 365 $filename = '';
|
Line 363 $filename = '';
|
# |
# |
# user data |
# user data |
$name = ''; |
$name = ''; |
$uhome = ''; |
|
$domain = ''; |
$domain = ''; |
# |
# |
# course data |
# course data |
$csec = ''; |
$csec = ''; |
$chome= ''; |
|
$cnum = ''; |
$cnum = ''; |
$cdom = ''; |
$cdom = ''; |
$cid = ''; |
$cid = ''; |
Line 729 sub get_values {
|
Line 725 sub get_values {
|
} |
} |
|
|
sub calc { |
sub calc { |
%sheet_values = %t; |
|
my $notfinished = 1; |
my $notfinished = 1; |
my $lastcalc = ''; |
my $lastcalc = ''; |
my $depth = 0; |
my $depth = 0; |
Line 770 ENDDEFS
|
Line 765 ENDDEFS
|
# itself |
# itself |
my $initstring = ''; |
my $initstring = ''; |
foreach (qw/name domain type symb cid csec coursefilename |
foreach (qw/name domain type symb cid csec coursefilename |
cnum cdom chome uhome/) { |
cnum cdom/) { |
$initstring.= qq{\$$_="$self->{$_}";}; |
$initstring.= qq{\$$_="$self->{$_}";}; |
} |
} |
$initstring.=qq{\$usection="$usection";}; |
$initstring.=qq{\$usection="$usection";}; |
Line 869 sub expandnamed {
|
Line 864 sub expandnamed {
|
sub sett { |
sub sett { |
my $self = shift; |
my $self = shift; |
my %t=(); |
my %t=(); |
|
undef(%Apache::Spreadsheet::sheet_values); |
# |
# |
# Deal with the template row |
# Deal with the template row |
foreach my $col ($self->template_cells()) { |
foreach my $col ($self->template_cells()) { |
Line 901 sub sett {
|
Line 897 sub sett {
|
} 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 '') { |
my $data = $self->{'constants'}->{$cell}; |
$Apache::Spreadsheet::sheet_values{$cell}= |
$t{$cell} = $data; |
eval($self->{'constants'}->{$cell}); |
} |
} |
} else { # $row > 1 and $col =~ /[a-z] |
} else { # $row > 1 and $col =~ /[a-z] |
$t{$cell}=$formula; |
$t{$cell}=$formula; |
Line 921 sub sett {
|
Line 917 sub sett {
|
sub sync_safe_space { |
sub sync_safe_space { |
my $self = shift; |
my $self = shift; |
# Inside the safe space 'formulas' has a diabolical alter-ego named 'f'. |
# Inside the safe space 'formulas' has a diabolical alter-ego named 'f'. |
%{$self->{'safe'}->varglob('f')}=%{$self->{'formulas'}}; |
#%{$self->{'safe'}->varglob('f')}=%{$self->{'formulas'}}; |
# 'constants' leads a peaceful hidden life of 'c'. |
# 'constants' leads a peaceful hidden life of 'c'. |
%{$self->{'safe'}->varglob('c')}=%{$self->{'constants'}}; |
%{$self->{'safe'}->varglob('c')}=%{$self->{'constants'}}; |
# 'othersheets' hides as 'os', a disguise few can penetrate. |
# 'othersheets' hides as 'os', a disguise few can penetrate. |
@{$self->{'safe'}->varglob('os')}=@{$self->{'othersheets'}}; |
#@{$self->{'safe'}->varglob('os')}=@{$self->{'othersheets'}}; |
} |
} |
|
|
## |
## |
Line 1607 sub load {
|
Line 1603 sub load {
|
my $stype = $self->{'type'}; |
my $stype = $self->{'type'}; |
my $cnum = $self->{'cnum'}; |
my $cnum = $self->{'cnum'}; |
my $cdom = $self->{'cdom'}; |
my $cdom = $self->{'cdom'}; |
my $chome = $self->{'chome'}; |
|
# |
# |
my $filename = $self->filename(); |
my $filename = $self->filename(); |
my $cachekey = join('_',($cnum,$cdom,$stype,$filename)); |
my $cachekey = join('_',($cnum,$cdom,$stype,$filename)); |
Line 1704 sub save {
|
Line 1699 sub save {
|
my $stype = $self->{'type'}; |
my $stype = $self->{'type'}; |
my $cnum = $self->{'cnum'}; |
my $cnum = $self->{'cnum'}; |
my $cdom = $self->{'cdom'}; |
my $cdom = $self->{'cdom'}; |
my $chome = $self->{'chome'}; |
|
my $filename = $self->{'filename'}; |
my $filename = $self->{'filename'}; |
my $cachekey = join('_',($cnum,$cdom,$stype,$filename)); |
my $cachekey = join('_',($cnum,$cdom,$stype,$filename)); |
# Cache new sheet |
# Cache new sheet |