[LON-CAPA-cvs] cvs: loncom /interface lonspreadsheet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 07 Mar 2003 04:20:20 -0000


albertel		Thu Mar  6 23:20:20 2003 EDT

  Modified files:              
    /loncom/interface	lonspreadsheet.pm 
  Log:
  - cascading up the part list now works
  - accepts parts with : and - in them
  
  
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.173 loncom/interface/lonspreadsheet.pm:1.174
--- loncom/interface/lonspreadsheet.pm:1.173	Mon Mar  3 17:00:03 2003
+++ loncom/interface/lonspreadsheet.pm	Thu Mar  6 23:20:20 2003
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.173 2003/03/03 22:00:03 albertel Exp $
+# $Id: lonspreadsheet.pm,v 1.174 2003/03/07 04:20:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -722,8 +722,27 @@
     # second, check map parms
     my $thisparm = $parmhash{$symbparm};
     return $thisparm if (defined($thisparm));
+
     # first, check default
-    return &Apache::lonnet::metadata($fn,$rwhat.'.default');
+    $thisparm = &Apache::lonnet::metadata($fn,$rwhat.'.default');
+    return $thisparm if (defined($thisparm));
+
+    #Cascade Up
+    my $space=$what;
+    $space=~s/\.\w+$//;
+    if ($space ne '0') {
+	my @parts=split(/_/,$space);
+	my $id=pop(@parts);
+	my $part=join('_',@parts);
+	if ($part eq '') { $part='0'; }
+	my $newwhat=$rwhat;
+	$newwhat=~s/\Q$space\E/$part/;
+	my $partgeneral=&parmval($newwhat,$symb,$uname,$udom,$csec);
+	if (defined($partgeneral)) { return $partgeneral; }
+    }
+
+    #nothing defined
+    return '';
 }
 
 #
@@ -1507,7 +1526,7 @@
 	foreach my $varname ( @vars ) {
             if ($varname=~/\D/) {
                $formula=~s/$varname/'$c{\''.$varname.'\'}'/ge;
-               $varname=~s/$var/\(\\w\+\)/g;
+               $varname=~s/$var/\([\\w:-]\+\)/g;
 	       foreach (keys(%{$self->{'constants'}})) {
 		  if ($_=~/$varname/) {
 		      $values{$1}=1;