[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm /interface/spreadsheet assesscalc.pm /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 29 Jul 2003 05:22:56 -0000


albertel		Tue Jul 29 01:22:56 2003 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
    /loncom/interface	lonnavmaps.pm 
    /loncom/interface/spreadsheet	assesscalc.pm 
  Log:
  - Fixes for BUG#1991, (maybe packages.tab will finally be handled correctly? One can only hope)
  - Made thes changes I said I was going to in the bugreport (copied below for conviene and commit padding)
  1) stop metadata from parsing packages.tab values and sticking them in the
  metadata of the problem
  2) add new function get pacakages_tab_default() to lonnet, takeas a full parm
  signifier (resource.partid_responseid.name) (just like EXT takes) figures out
  what kind of response/part the things is and returns the proper default value
  from packages.tab
  3) add to EXT to check this new function for the packages.tab default for
  anythings it can't find a value for
  4) check that all other parmval funtions also do this
  
  4) turned out to be assesscalc.pm and lonnavmaps.pm, and executive decision was made to leave lonparmset.pm out of the fix, as there is nothing the user can do about these values, adn they see the defaults appear in the 'Current session value' column.
  
  (as it is it would be difficult to add these values to the parmset screen, one would need a colun at the very end that said "if ther are no other values set anywhere else, we'll use this one.)
  
  Anyhoo.
  
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.394 loncom/lonnet/perl/lonnet.pm:1.395
--- loncom/lonnet/perl/lonnet.pm:1.394	Thu Jul 24 21:18:04 2003
+++ loncom/lonnet/perl/lonnet.pm	Tue Jul 29 01:22:56 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.394 2003/07/25 01:18:04 bowersj2 Exp $
+# $Id: lonnet.pm,v 1.395 2003/07/29 05:22:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3222,7 +3222,7 @@
 
 # --------------------------------------------------------- Value of a Variable
 sub EXT {
-    my ($varname,$symbparm,$udom,$uname,$usection)=@_;
+    my ($varname,$symbparm,$udom,$uname,$usection,$recurse)=@_;
 
     unless ($varname) { return ''; }
     #get real user name/domain, courseid and symb
@@ -3323,6 +3323,7 @@
         return $ENV{'course.'.$courseid.'.'.$spacequalifierrest};
     } elsif ($realm eq 'resource') {
 
+	my $section;
 	if (defined($courseid) && $courseid eq $ENV{'request.course.id'}) {
 
 	    #print '<br>'.$space.' - '.$qualifier.' - '.$spacequalifierrest;
@@ -3335,7 +3336,6 @@
 	    my $symbparm=$symbp.'.'.$spacequalifierrest;
 	    my $mapparm=$mapp.'___(all).'.$spacequalifierrest;
 
-	    my $section;
 	    if (($ENV{'user.name'} eq $uname) &&
 		($ENV{'user.domain'} eq $udom)) {
 		$section=$ENV{'request.course.sec'};
@@ -3426,9 +3426,12 @@
 	    my $part=join('_',@parts);
 	    if ($part eq '') { $part='0'; }
 	    my $partgeneral=&EXT('resource.'.$part.'.'.$qualifierrest,
-				 $symbparm,$udom,$uname);
+				 $symbparm,$udom,$uname,$section,1);
 	    if (defined($partgeneral)) { return $partgeneral; }
 	}
+	if ($recurse) { return undef; }
+	my $pack_def=&packages_tab_default($filename,$varname);
+	if (defined($pack_def)) { return $pack_def; }
 
 # ---------------------------------------------------- Any other user namespace
     } elsif ($realm eq 'environment') {
@@ -3449,6 +3452,20 @@
     return '';
 }
 
+sub packages_tab_default {
+    my ($uri,$varname)=@_;
+    &logthis(" $varname");
+    my (undef,$part,$name)=split(/\./,$varname);
+    my $packages=&metadata($uri,'packages');
+    foreach my $package (split(/,/,$packages)) {
+	my ($pack_type,$pack_part)=split(/_/,$package,2);
+	if ($pack_part eq $part) {
+	    return $packagetab{"$pack_type&$name&default"};
+	}
+    }
+    return undef;
+}
+
 sub add_prefix_and_part {
     my ($prefix,$part)=@_;
     my $keyroot;
@@ -3517,6 +3534,9 @@
 		    foreach (keys %packagetab) {
 			if ($_=~/^$package\&/) {
 			    my ($pack,$name,$subp)=split(/\&/,$_);
+			    # ignore package.tab specified default values
+                            # here &package_tab_default() will fetch those
+			    if ($subp eq 'default') { next; }
 			    my $value=$packagetab{$_};
 			    my $part=$keyroot;
 			    $part=~s/^\_//;
@@ -3524,13 +3544,8 @@
 				$value.=' [Part: '.$part.']';
 			    }
 			    my $unikey='parameter'.$keyroot.'_'.$name;
-			    if ($subp eq 'default') {
-				$unikey='parameter_0_'.$name;
-				$metacache{$uri.':'.$unikey.'.part'}='0';
-			    } else {
-				$metacache{$uri.':'.$unikey.'.part'}=$part;
-				$metathesekeys{$unikey}=1;
-			    }
+			    $metacache{$uri.':'.$unikey.'.part'}=$part;
+			    $metathesekeys{$unikey}=1;
 			    unless (defined($metacache{$uri.':'.$unikey.'.'.$subp})) {
 				$metacache{$uri.':'.$unikey.'.'.$subp}=$value;
 			    }
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.218 loncom/interface/lonnavmaps.pm:1.219
--- loncom/interface/lonnavmaps.pm:1.218	Thu Jul 24 21:18:04 2003
+++ loncom/interface/lonnavmaps.pm	Tue Jul 29 01:22:56 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.218 2003/07/25 01:18:04 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.219 2003/07/29 05:22:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2027,7 +2027,7 @@
 
 sub parmval_real {
     my $self = shift;
-    my ($what,$symb) = @_;
+    my ($what,$symb,$recurse) = @_;
 
     my $cid=$ENV{'request.course.id'};
     my $csec=$ENV{'request.course.sec'};
@@ -2099,9 +2099,12 @@
 	my $id=pop(@parts);
 	my $part=join('_',@parts);
 	if ($part eq '') { $part='0'; }
-	my $partgeneral=$self->parmval($part.".$qualifier",$symb);
+	my $partgeneral=$self->parmval($part.".$qualifier",$symb,1);
 	if (defined($partgeneral)) { return $partgeneral; }
     }
+    if ($recurse) { return undef; }
+    my $pack_def=&Apache::lonnet::packages_tab_default($fn,'resource.'.$what);
+    if (defined($pack_def)) { return $pack_def; }
     return '';
 }
 
Index: loncom/interface/spreadsheet/assesscalc.pm
diff -u loncom/interface/spreadsheet/assesscalc.pm:1.16 loncom/interface/spreadsheet/assesscalc.pm:1.17
--- loncom/interface/spreadsheet/assesscalc.pm:1.16	Wed Jul 16 12:35:45 2003
+++ loncom/interface/spreadsheet/assesscalc.pm	Tue Jul 29 01:22:56 2003
@@ -1,5 +1,5 @@
 #
-# $Id: assesscalc.pm,v 1.16 2003/07/16 16:35:45 matthew Exp $
+# $Id: assesscalc.pm,v 1.17 2003/07/29 05:22:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -247,7 +247,7 @@
 ##################################################
 sub parmval {
     my $self = shift;
-    my ($what,$symb,$uname,$udom,$csec)=@_;
+    my ($what,$symb,$uname,$udom,$csec,$recurse)=@_;
     $uname = $self->{'name'}    if (! defined($uname));
     $udom  = $self->{'domain'}  if (! defined($udom));
     $csec  = $self->{'section'} if (! defined($csec));
@@ -312,9 +312,12 @@
 	if ($part eq '') { $part='0'; }
 	my $newwhat=$rwhat;
 	$newwhat=~s/\Q$space\E/$part/;
-	my $partgeneral=$self->parmval($newwhat,$symb,$uname,$udom,$csec);
+	my $partgeneral=$self->parmval($newwhat,$symb,$uname,$udom,$csec,1);
 	if (defined($partgeneral)) { return $partgeneral; }
     }
+    if ($recurse) { return undef; }
+    my $pack_def=&Apache::lonnet::packages_tab_default($fn,'resource.'.$what);
+    if (defined($pack_def)) { return $pack_def; }
     #nothing defined
     return '';
 }