--- loncom/interface/spreadsheet/Spreadsheet.pm 2006/02/27 00:56:47 1.62
+++ loncom/interface/spreadsheet/Spreadsheet.pm 2006/05/30 12:46:26 1.69
@@ -1,5 +1,5 @@
#
-# $Id: Spreadsheet.pm,v 1.62 2006/02/27 00:56:47 bowersj2 Exp $
+# $Id: Spreadsheet.pm,v 1.69 2006/05/30 12:46:26 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,6 +60,9 @@ use HTML::TokeParser;
use Spreadsheet::WriteExcel;
use Time::HiRes;
use Apache::lonlocal;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
+
##
## Package Variables
@@ -85,7 +88,7 @@ sub new {
my $class = ref($this) || $this;
my ($stype) = ($class =~ /Apache::(.*)$/);
#
- my ($name,$domain,$filename,$usymb)=@_;
+ my ($name,$domain,$filename,$usymb,$section,$groups)=@_;
if (defined($usymb) && ref($usymb)) {
$usymb = $usymb->symb;
}
@@ -95,10 +98,22 @@ sub new {
if (! defined($domain) || $domain eq '') {
$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 = {
name => $name,
domain => $domain,
+ section => $section,
+ groups => $groups,
type => $stype,
symb => $usymb,
errorlog => '',
@@ -808,7 +823,7 @@ sub expandnamed {
$result.=$thissum.'+';
}
$result=~s/\+$//;
- return $result;
+ return '('.$result.')';
} else {
return 0;
}
@@ -1290,15 +1305,13 @@ sub html_editable_cell {
}
$name = '' if (! defined($name));
$formula = '' if (! defined($formula));
- if ($showsource)
- {
+ if ($showsource) {
if (!defined($formula) || $formula =~ /^\s*$/) {
$value = '#';
} else {
$value = &HTML::Entities::encode($formula, '<>&"');
}
- }
- elsif (! defined($value)) {
+ } elsif (! defined($value)) {
$value = '#';
if ($formula ne '') {
$value = 'undefined value';
@@ -1805,8 +1818,8 @@ sub save_tmp {
my %f = $self->formulas();
while( my ($cell,$formula) = each(%f)) {
next if ($formula eq 'import');
- print $fh &Apache::lonnet::escape($cell)."=".
- &Apache::lonnet::escape($formula)."\n";
+ print $fh &escape($cell)."=".
+ &escape($formula)."\n";
}
$fh->close();
}
@@ -1824,8 +1837,8 @@ sub load_tmp {
while (<$spreadsheet_file>) {
chomp;
my ($cell,$formula) = split(/=/);
- $cell = &Apache::lonnet::unescape($cell);
- $formula = &Apache::lonnet::unescape($formula);
+ $cell = &unescape($cell);
+ $formula = &unescape($formula);
$formulas{$cell} = $formula;
}
$spreadsheet_file->close();