version 1.64, 2006/03/05 21:35:10
|
version 1.69, 2006/05/30 12:46:26
|
Line 60 use HTML::TokeParser;
|
Line 60 use HTML::TokeParser;
|
use Spreadsheet::WriteExcel; |
use Spreadsheet::WriteExcel; |
use Time::HiRes; |
use Time::HiRes; |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
## |
## |
## Package Variables |
## Package Variables |
Line 85 sub new {
|
Line 88 sub new {
|
my $class = ref($this) || $this; |
my $class = ref($this) || $this; |
my ($stype) = ($class =~ /Apache::(.*)$/); |
my ($stype) = ($class =~ /Apache::(.*)$/); |
# |
# |
my ($name,$domain,$filename,$usymb)=@_; |
my ($name,$domain,$filename,$usymb,$section,$groups)=@_; |
if (defined($usymb) && ref($usymb)) { |
if (defined($usymb) && ref($usymb)) { |
$usymb = $usymb->symb; |
$usymb = $usymb->symb; |
} |
} |
Line 95 sub new {
|
Line 98 sub new {
|
if (! defined($domain) || $domain eq '') { |
if (! defined($domain) || $domain eq '') { |
$domain = $env{'user.domain'}; |
$domain = $env{'user.domain'}; |
} |
} |
|
if (! defined($section) || $section eq '') { |
|
$section = &Apache::lonnet::getsection($domain,$name, |
|
$env{'request.course.id'}); |
|
} |
|
if (! defined($groups)) { |
|
|
|
my @usersgroups = &Apache::lonnet::get_users_groups($domain,$name, |
|
$env{'request.course.id'}); |
|
$groups = \@usersgroups; |
|
} |
# |
# |
my $self = { |
my $self = { |
name => $name, |
name => $name, |
domain => $domain, |
domain => $domain, |
|
section => $section, |
|
groups => $groups, |
type => $stype, |
type => $stype, |
symb => $usymb, |
symb => $usymb, |
errorlog => '', |
errorlog => '', |
Line 722 sub calc {
|
Line 737 sub calc {
|
$notfinished=0; |
$notfinished=0; |
while (my ($cell,$value) = each(%t)) { |
while (my ($cell,$value) = each(%t)) { |
my $old=$sheet_values{$cell}; |
my $old=$sheet_values{$cell}; |
#$sheet_values{$cell}=eval $value; |
$sheet_values{$cell}=eval $value; |
# $errorlog .= $cell.' = '.$old.'->'.$sheet_values{$cell}."\n"; |
# $errorlog .= $cell.' = '.$old.'->'.$sheet_values{$cell}."\n"; |
if ($@) { |
if ($@) { |
undef %sheet_values; |
undef %sheet_values; |
Line 1290 sub html_editable_cell {
|
Line 1305 sub html_editable_cell {
|
} |
} |
$name = '' if (! defined($name)); |
$name = '' if (! defined($name)); |
$formula = '' if (! defined($formula)); |
$formula = '' if (! defined($formula)); |
if ($showsource) |
if ($showsource) { |
{ |
|
if (!defined($formula) || $formula =~ /^\s*$/) { |
if (!defined($formula) || $formula =~ /^\s*$/) { |
$value = '<font color="'.$bgcolor.'">#</font>'; |
$value = '<font color="'.$bgcolor.'">#</font>'; |
} else { |
} else { |
$value = &HTML::Entities::encode($formula, '<>&"'); |
$value = &HTML::Entities::encode($formula, '<>&"'); |
} |
} |
} |
} elsif (! defined($value)) { |
elsif (! defined($value)) { |
|
$value = '<font color="'.$bgcolor.'">#</font>'; |
$value = '<font color="'.$bgcolor.'">#</font>'; |
if ($formula ne '') { |
if ($formula ne '') { |
$value = '<i>undefined value</i>'; |
$value = '<i>undefined value</i>'; |
Line 1805 sub save_tmp {
|
Line 1818 sub save_tmp {
|
my %f = $self->formulas(); |
my %f = $self->formulas(); |
while( my ($cell,$formula) = each(%f)) { |
while( my ($cell,$formula) = each(%f)) { |
next if ($formula eq 'import'); |
next if ($formula eq 'import'); |
print $fh &Apache::lonnet::escape($cell)."=". |
print $fh &escape($cell)."=". |
&Apache::lonnet::escape($formula)."\n"; |
&escape($formula)."\n"; |
} |
} |
$fh->close(); |
$fh->close(); |
} |
} |
Line 1824 sub load_tmp {
|
Line 1837 sub load_tmp {
|
while (<$spreadsheet_file>) { |
while (<$spreadsheet_file>) { |
chomp; |
chomp; |
my ($cell,$formula) = split(/=/); |
my ($cell,$formula) = split(/=/); |
$cell = &Apache::lonnet::unescape($cell); |
$cell = &unescape($cell); |
$formula = &Apache::lonnet::unescape($formula); |
$formula = &unescape($formula); |
$formulas{$cell} = $formula; |
$formulas{$cell} = $formula; |
} |
} |
$spreadsheet_file->close(); |
$spreadsheet_file->close(); |