[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 03 Dec 2002 10:04:21 -0000
matthew Tue Dec 3 05:04:21 2002 EDT
Modified files:
/loncom/interface lonspreadsheet.pm
Log:
Fix bug in storage of multi-line cells in temporary spreadsheets.
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.152 loncom/interface/lonspreadsheet.pm:1.153
--- loncom/interface/lonspreadsheet.pm:1.152 Mon Dec 2 16:22:39 2002
+++ loncom/interface/lonspreadsheet.pm Tue Dec 3 05:04:21 2002
@@ -1,5 +1,5 @@
#
-# $Id: lonspreadsheet.pm,v 1.152 2002/12/02 21:22:39 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.153 2002/12/03 10:04:21 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1927,7 +1927,10 @@
$fn=$tmpdir.$fn.'.tmp';
my $fh;
if ($fh=Apache::File->new('>'.$fn)) {
- print $fh join("\n",&getformulas($sheet));
+ my %f = &getformulas($sheet);
+ while( my ($cell,$formula) = each(%f)) {
+ print $fh &Apache::lonnet::escape($cell)."=".&Apache::lonnet::escape($formula)."\n";
+ }
}
}
@@ -1943,32 +1946,36 @@
my %fo=();
my $countrows=0;
if ($fh=Apache::File->new($fn)) {
- my $name;
- while ($name=<$fh>) {
- chomp($name);
- my $value=<$fh>;
- chomp($value);
- $fo{$name}=$value;
- if ($name=~/^A(\d+)$/) {
- if ($1>$countrows) {
- $countrows=$1;
- }
- }
- }
- }
+ while (<$fh>) {
+ chomp;
+ my ($cell,$formula) = split(/=/);
+ $cell = &Apache::lonnet::unescape($cell);
+ $formula = &Apache::lonnet::unescape($formula);
+ $fo{$cell} = $formula;
+ }
+ }
+# chomp($value);
+# $fo{$name}=$value;
+# if ($name=~/^A(\d+)$/) {
+# if ($1>$countrows) {
+# $countrows=$1;
+# }
+# }
+# }
+# }
if ($nform eq 'changesheet') {
$fo{'A'.$nfield}=(split(/__&&&\__/,$fo{'A'.$nfield}))[0];
unless ($ENV{'form.sel_'.$nfield} eq 'Default') {
$fo{'A'.$nfield}.='__&&&__'.$ENV{'form.sel_'.$nfield};
}
- } elsif ($nfield eq 'insertrow') {
- $countrows++;
- my $newrow=substr('000000'.$countrows,-7);
- if ($nform eq 'top') {
- $fo{'A'.$countrows}='--- '.$newrow;
- } else {
- $fo{'A'.$countrows}='~~~ '.$newrow;
- }
+# } elsif ($nfield eq 'insertrow') {
+# $countrows++;
+# my $newrow=substr('000000'.$countrows,-7);
+# if ($nform eq 'top') {
+# $fo{'A'.$countrows}='--- '.$newrow;
+# } else {
+# $fo{'A'.$countrows}='~~~ '.$newrow;
+# }
} else {
if ($nfield) { $fo{$nfield}=$nform; }
}