[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm lonparmset.pm lonspreadsheet.pm /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 01 Oct 2002 07:09:05 -0000


This is a MIME encoded message

--albertel1033456145
Content-Type: text/plain

albertel		Tue Oct  1 03:09:05 2002 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm lonparmset.pm lonspreadsheet.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - YEAH!!!!! Can have values of 0 for weight, I think I got every location 
    that a had a version of parmval and modified it to used defined
  - additionally I updated some docs in parmset
  - Fixes BUG#796 and BUG#199
  
  
--albertel1033456145
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20021001030905.txt"

Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.56 loncom/interface/lonnavmaps.pm:1.57
--- loncom/interface/lonnavmaps.pm:1.56	Mon Sep 30 12:45:01 2002
+++ loncom/interface/lonnavmaps.pm	Tue Oct  1 03:09:05 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.56 2002/09/30 16:45:01 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.57 2002/10/01 07:09:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -124,32 +124,32 @@
     my $courselevelm=$usercourseprefix.'.'.$mapparm;
 
 # ---------------------------------------------------------- first, check user
-    if ($uname) {
-        if ($useropt{$courselevelr}) { return $useropt{$courselevelr}; }
-        if ($useropt{$courselevelm}) { return $useropt{$courselevelm}; }
-        if ($useropt{$courselevel}) { return $useropt{$courselevel}; }
+    if (defined($uname)) {
+        if (defined($useropt{$courselevelr})) { return $useropt{$courselevelr}; }
+        if (defined($useropt{$courselevelm})) { return $useropt{$courselevelm}; }
+        if (defined($useropt{$courselevel})) { return $useropt{$courselevel}; }
     }
 
 # ------------------------------------------------------- second, check course
-    if ($csec) {
-        if ($courseopt{$seclevelr}) { return $courseopt{$seclevelr}; }
-        if ($courseopt{$seclevelm}) { return $courseopt{$seclevelm}; }
-        if ($courseopt{$seclevel}) { return $courseopt{$seclevel}; }
+    if (defined($csec)) {
+        if (defined($courseopt{$seclevelr})) { return $courseopt{$seclevelr}; }
+        if (defined($courseopt{$seclevelm})) { return $courseopt{$seclevelm}; }
+        if (defined($courseopt{$seclevel})) { return $courseopt{$seclevel}; }
     }
 
-    if ($courseopt{$courselevelr}) { return $courseopt{$courselevelr}; }
-    if ($courseopt{$courselevelm}) { return $courseopt{$courselevelm}; }
-    if ($courseopt{$courselevel}) { return $courseopt{$courselevel}; }
+    if (defined($courseopt{$courselevelr})) { return $courseopt{$courselevelr}; }
+    if (defined($courseopt{$courselevelm})) { return $courseopt{$courselevelm}; }
+    if (defined($courseopt{$courselevel})) { return $courseopt{$courselevel}; }
 
 # ----------------------------------------------------- third, check map parms
 
     my $thisparm=$parmhash{$symbparm};
-    if ($thisparm) { return $thisparm; }
+    if (defined($thisparm)) { return $thisparm; }
 
 # ----------------------------------------------------- fourth , check default
 
     my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default');
-    if ($default) { return $default}
+    if (defined($default)) { return $default}
 
 # --------------------------------------------------- fifth , cascade up parts
 
@@ -159,10 +159,10 @@
         my ($part,$id)=split(/\_/,$space);
         if ($id) {
             my $partgeneral=&parmval($part.".$qualifier",$symb);
-            if ($partgeneral) { return $partgeneral; }
+            if (defined($partgeneral)) { return $partgeneral; }
         } else {
             my $resourcegeneral=&parmval("0.$qualifier",$symb);
-            if ($resourcegeneral) { return $resourcegeneral; }
+            if (defined($resourcegeneral)) { return $resourcegeneral; }
         }
     }
     return '';
@@ -1376,33 +1376,33 @@
 
 # ---------------------------------------------------------- first, check user
     if ($uname and defined($useropt)) {
-        if ($$useropt{$courselevelr}) { return $$useropt{$courselevelr}; }
-        if ($$useropt{$courselevelm}) { return $$useropt{$courselevelm}; }
-        if ($$useropt{$courselevel}) { return $$useropt{$courselevel}; }
+        if (defined($$useropt{$courselevelr})) { return $$useropt{$courselevelr}; }
+        if (defined($$useropt{$courselevelm})) { return $$useropt{$courselevelm}; }
+        if (defined($$useropt{$courselevel})) { return $$useropt{$courselevel}; }
     }
 
 # ------------------------------------------------------- second, check course
     if ($csec and defined($courseopt)) {
-        if ($$courseopt{$seclevelr}) { return $$courseopt{$seclevelr}; }
-        if ($$courseopt{$seclevelm}) { return $$courseopt{$seclevelm}; }
-        if ($$courseopt{$seclevel}) { return $$courseopt{$seclevel}; }
+        if (defined($$courseopt{$seclevelr})) { return $$courseopt{$seclevelr}; }
+        if (defined($$courseopt{$seclevelm})) { return $$courseopt{$seclevelm}; }
+        if (defined($$courseopt{$seclevel})) { return $$courseopt{$seclevel}; }
     }
 
     if (defined($courseopt)) {
-        if ($$courseopt{$courselevelr}) { return $$courseopt{$courselevelr}; }
-        if ($$courseopt{$courselevelm}) { return $$courseopt{$courselevelm}; }
-        if ($$courseopt{$courselevel}) { return $$courseopt{$courselevel}; }
+        if (defined($$courseopt{$courselevelr})) { return $$courseopt{$courselevelr}; }
+        if (defined($$courseopt{$courselevelm})) { return $$courseopt{$courselevelm}; }
+        if (defined($$courseopt{$courselevel})) { return $$courseopt{$courselevel}; }
     }
 
 # ----------------------------------------------------- third, check map parms
 
     my $thisparm=$$parmhash{$symbparm};
-    if ($thisparm) { return $thisparm; }
+    if (defined($thisparm)) { return $thisparm; }
 
 # ----------------------------------------------------- fourth , check default
 
     my $default=&Apache::lonnet::metadata($fn,$rwhat.'.default');
-    if ($default) { return $default}
+    if (defined($default)) { return $default}
 
 # --------------------------------------------------- fifth , cascade up parts
 
@@ -1412,10 +1412,10 @@
         my ($part,$id)=split(/\_/,$space);
         if ($id) {
             my $partgeneral=$self->parmval($part.".$qualifier",$symb);
-            if ($partgeneral) { return $partgeneral; }
+            if (defined($partgeneral)) { return $partgeneral; }
         } else {
             my $resourcegeneral=$self->parmval("0.$qualifier",$symb);
-            if ($resourcegeneral) { return $resourcegeneral; }
+            if (defined($resourcegeneral)) { return $resourcegeneral; }
         }
     }
     return '';
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.70 loncom/interface/lonparmset.pm:1.71
--- loncom/interface/lonparmset.pm:1.70	Tue Oct  1 02:21:23 2002
+++ loncom/interface/lonparmset.pm	Tue Oct  1 03:09:05 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.70 2002/10/01 06:21:23 albertel Exp $
+# $Id: lonparmset.pm,v 1.71 2002/10/01 07:09:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -87,9 +87,23 @@
 
 Figure out a cascading parameter.
 
-Inputs:  $what $id $def
-
-Returns: I am not entirely sure.
+Inputs:  $what - a parameter spec (incluse part info and name I.E. 0.weight)
+         $id   - a bighash Id number
+         $def  - the resource's default value   'stupid emacs
+
+Returns:  A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 11 possible levels
+
+11- resource default
+10- map default
+9 - General Course
+8 - Map level in course
+7 - resource level in course
+6 - General for section
+5 - Map level for section
+4 - resource level in section
+3 - General for specific student
+2 - Map level for specific student
+1 - resource level for specific student
 
 =cut
 
@@ -123,32 +137,32 @@
 
 # --------------------------------------------------------- third, check course
 
-    if ($courseopt{$courselevel}) {
+    if (defined($courseopt{$courselevel})) {
 	$outpar[9]=$courseopt{$courselevel};
 	$result=9;
     }
 
-    if ($courseopt{$courselevelm}) {
+    if (defined($courseopt{$courselevelm})) {
 	$outpar[8]=$courseopt{$courselevelm};
 	$result=8;
     }
 
-    if ($courseopt{$courselevelr}) {
+    if (defined($courseopt{$courselevelr})) {
 	$outpar[7]=$courseopt{$courselevelr};
 	$result=7;
     }
 
-    if ($csec) {
-        if ($courseopt{$seclevel}) {
+    if (defined($csec)) {
+        if (defined($courseopt{$seclevel})) {
 	    $outpar[6]=$courseopt{$seclevel};
 	    $result=6;
 	}
-        if ($courseopt{$seclevelm}) {
+        if (defined($courseopt{$seclevelm})) {
 	    $outpar[5]=$courseopt{$seclevelm};
 	    $result=5;
 	}
 
-        if ($courseopt{$seclevelr}) {
+        if (defined($courseopt{$seclevelr})) {
 	    $outpar[4]=$courseopt{$seclevelr};
 	    $result=4;
 	}
@@ -156,23 +170,22 @@
 
 # ---------------------------------------------------------- fourth, check user
 
-    if ($uname) {
-	if ($useropt{$courselevel}) {
+    if (defined($uname)) {
+	if (defined($useropt{$courselevel})) {
 	    $outpar[3]=$useropt{$courselevel};
 	    $result=3;
 	}
 
-	if ($useropt{$courselevelm}) {
+	if (defined($useropt{$courselevelm})) {
 	    $outpar[2]=$useropt{$courselevelm};
 	    $result=2;
 	}
 
-	if ($useropt{$courselevelr}) {
+	if (defined($useropt{$courselevelr})) {
 	    $outpar[1]=$useropt{$courselevelr};
 	    $result=1;
 	}
     }
-
     return ($result,@outpar);
 }
 
@@ -199,7 +212,7 @@
     my $result = '';
     # Values of zero are valid.
     if (! $value && $value ne '0') {
-        $result = '  ';
+	$result = '  ';
     } else {
         if ($type eq 'date_interval') {
             my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value);
Index: loncom/interface/lonspreadsheet.pm
diff -u loncom/interface/lonspreadsheet.pm:1.114 loncom/interface/lonspreadsheet.pm:1.115
--- loncom/interface/lonspreadsheet.pm:1.114	Mon Sep 30 14:47:43 2002
+++ loncom/interface/lonspreadsheet.pm	Tue Oct  1 03:09:05 2002
@@ -1,5 +1,5 @@
 #
-# $Id: lonspreadsheet.pm,v 1.114 2002/09/30 18:47:43 matthew Exp $
+# $Id: lonspreadsheet.pm,v 1.115 2002/10/01 07:09:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1650,24 +1650,24 @@
     my $courselevelr = $usercourseprefix.'.'.$symbparm;
     my $courselevelm = $usercourseprefix.'.'.$mapparm;
     # fourth, check user
-    if ($uname) { 
-        return $useropt{$courselevelr} if ($useropt{$courselevelr});
-        return $useropt{$courselevelm} if ($useropt{$courselevelm});
-        return $useropt{$courselevel}  if ($useropt{$courselevel});
+    if (defined($uname)) {
+        return $useropt{$courselevelr} if (defined($useropt{$courselevelr}));
+        return $useropt{$courselevelm} if (defined($useropt{$courselevelm}));
+        return $useropt{$courselevel}  if (defined($useropt{$courselevel}));
     }
     # third, check course
-    if ($csec) {
-        return $courseopt{$seclevelr} if ($courseopt{$seclevelr});
-        return $courseopt{$seclevelm} if ($courseopt{$seclevelm});
-        return $courseopt{$seclevel}  if ($courseopt{$seclevel});
+    if (defined($csec)) {
+        return $courseopt{$seclevelr} if (defined($courseopt{$seclevelr}));
+        return $courseopt{$seclevelm} if (defined($courseopt{$seclevelm}));
+        return $courseopt{$seclevel}  if (defined($courseopt{$seclevel}));
     }
     #
-    return $courseopt{$courselevelr} if ($courseopt{$courselevelr});
-    return $courseopt{$courselevelm} if ($courseopt{$courselevelm});
-    return $courseopt{$courselevel}  if ($courseopt{$courselevel});
+    return $courseopt{$courselevelr} if (defined($courseopt{$courselevelr}));
+    return $courseopt{$courselevelm} if (defined($courseopt{$courselevelm}));
+    return $courseopt{$courselevel}  if (defined($courseopt{$courselevel}));
     # second, check map parms
     my $thisparm = $parmhash{$symbparm};
-    return $thisparm if ($thisparm);
+    return $thisparm if (defined($thisparm));
     # first, check default
     return &Apache::lonnet::metadata($fn,$rwhat.'.default');
 }
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.286 loncom/lonnet/perl/lonnet.pm:1.287
--- loncom/lonnet/perl/lonnet.pm:1.286	Tue Sep 24 14:25:45 2002
+++ loncom/lonnet/perl/lonnet.pm	Tue Oct  1 03:09:05 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.286 2002/09/24 18:25:45 matthew Exp $
+# $Id: lonnet.pm,v 1.287 2002/10/01 07:09:05 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2588,7 +2588,7 @@
 	}
     }
     foreach my $item (@which) {
-	if ($courseresdatacache{$hashid}->{$item}) {
+	if (defined($courseresdatacache{$hashid}->{$item})) {
 	    return $courseresdatacache{$hashid}->{$item};
 	}
     }
@@ -2739,7 +2739,7 @@
 					  ($seclevelr,$seclevelm,$seclevel,
 					   $courselevelr,$courselevelm,
 					   $courselevel));
-	    if ($coursereply) { return $coursereply; }
+	    if (defined($coursereply)) { return $coursereply; }
 
 # ------------------------------------------------------ third, check map parms
 	    my %parmhash=();

--albertel1033456145--