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

www lon-capa-cvs@mail.lon-capa.org
Thu, 17 Mar 2005 22:12:52 -0000


www		Thu Mar 17 17:12:52 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Trying to clean up globals, one by one.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.186 loncom/interface/lonparmset.pm:1.187
--- loncom/interface/lonparmset.pm:1.186	Thu Mar 17 16:08:43 2005
+++ loncom/interface/lonparmset.pm	Thu Mar 17 17:12:52 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.186 2005/03/17 21:08:43 www Exp $
+# $Id: lonparmset.pm,v 1.187 2005/03/17 22:12:52 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -75,12 +75,6 @@
 
 my %maptitles;
 
-my $uname;
-my $udom;
-my $uhome;
-my $csec;
-my $coursename;
-
 ##################################################
 ##################################################
 
@@ -113,7 +107,7 @@
 ##################################################
 ##################################################
 sub parmval {
-    my ($what,$id,$def)=@_;
+    my ($what,$id,$def,$uname,$udom,$csec)=@_;
     my $result='';
     my @outpar=();
 # ----------------------------------------------------- Cascading lookup scheme
@@ -207,8 +201,11 @@
 # - level
 # - new value
 # - new type
+# - username
+# - userdomain
+
 sub storeparm {
-    my ($sresid,$spnam,$snum,$nval,$ntype)=@_;
+    my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
     $spnam=~s/\_([^\_]+)$/\.$1/;
 # ---------------------------------------------------------- Construct prefixes
     
@@ -507,16 +504,16 @@
 
 sub print_row {
     my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,
-	$defbgtwo,$parmlev)=@_;
+	$defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
 # get the values for the parameter in cascading order
 # empty levels will remain empty
     my ($result,@outpar)=&parmval($$part{$which}.'.'.$$name{$which},
-				  $rid,$$default{$which});
+				  $rid,$$default{$which},$uname,$udom,$csec);
 # get the type for the parameters
 # problem: these may not be set for all levels
     my ($typeresult,@typeoutpar)=&parmval($$part{$which}.'.'.
                                           $$name{$which}.'.type',
-				  $rid,$$defaulttype{$which});
+				  $rid,$$defaulttype{$which},$uname,$udom,$csec);
 # cascade down manually
     my $cascadetype=$$defaulttype{$which};
     for (my $i=11;$i>0;$i--) {
@@ -774,8 +771,14 @@
     my %allmaps=();
     my %alllevs=();
 
+    my $uname;
+    my $udom;
+    my $uhome;
+    my $csec;
+ 
+    my $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
+
     $alllevs{'Resource Level'}='full';
-#    $alllevs{'Resource Level [BRIEF]'}='brief';
     $alllevs{'Map Level'}='map';
     $alllevs{'Course Level'}='general';
 
@@ -811,10 +814,6 @@
     my $parmlev='';
     my $trimheader='';
     my $prevvisit=$ENV{'form.prevvisit'};
-
-#    unless ($parmlev==$ENV{'form.parmlev'}) {
-#        $parmlev = 'full';
-#    }
  
     unless ($ENV{'form.parmlev'}) {
         $parmlev = 'map';
@@ -912,7 +911,8 @@
     if ($ENV{'form.pres_marker'}) {
 	$message.=&storeparm(split(/\&/,$ENV{'form.pres_marker'}),
 			     $ENV{'form.pres_value'},
-			     $ENV{'form.pres_type'});
+			     $ENV{'form.pres_type'},
+                             $uname,$udom,$csec);
 # ---------------------------------------------------------------- Done storing
 	$message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
     }
@@ -937,9 +937,9 @@
 	if ($fcat eq '') {
 	    $a<=>$b;
 	} else {
-	    my ($result,@outpar)=&parmval($fcat,$a,$defp{$a});
+	    my ($result,@outpar)=&parmval($fcat,$a,$defp{$a},$uname,$udom,$csec);
 	    my $aparm=$outpar[$result];
-	    ($result,@outpar)=&parmval($fcat,$b,$defp{$b});
+	    ($result,@outpar)=&parmval($fcat,$b,$defp{$b},$uname,$udom,$csec);
 	    my $bparm=$outpar[$result];
 	    1*$aparm<=>1*$bparm;
 	}
@@ -1276,7 +1276,7 @@
 
                             &print_row($r,$_,\%part,\%name,$rid,\%default,
                                        \%type,\%display,$defbgone,$defbgtwo,
-                                       $parmlev);
+                                       $parmlev,$uname,$udom,$csec);
                         }
                     }
                 }
@@ -1384,7 +1384,7 @@
                     $r->print('<tr>');
                     &print_row($r,$_,\%part,\%name,$mapid,\%default,
                            \%type,\%display,$defbgone,$defbgtwo,
-                           $parmlev);
+                           $parmlev,$uname,$udom,$csec);
 #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
                 }
                 $r->print("</table></center>");
@@ -1461,7 +1461,7 @@
 	    foreach (sort keys %name) {
                 $r->print('<tr>');
                 &print_row($r,$_,\%part,\%name,$mapid,\%default,
-                       \%type,\%display,$defbgone,$defbgtwo,$parmlev);
+                       \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
 #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
             }
             $r->print("</table></center>");
@@ -2081,8 +2081,6 @@
 
         &Apache::loncommon::content_type($r,'text/html');
         $r->send_http_header;
- 
-        $coursename=$ENV{'course.'.$ENV{'request.course.id'}.'.description'};
 
 	if (($ENV{'form.crsenv'}) || (!$ENV{'request.course.fn'})) {
 # ---------------------------------------------- This is for course environment