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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 17 Mar 2007 04:35:05 -0000


albertel		Sat Mar 17 00:35:05 2007 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - some speedups (skip looking things up if we already have it)
  - style 
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.362 loncom/interface/lonparmset.pm:1.363
--- loncom/interface/lonparmset.pm:1.362	Fri Mar 16 22:14:26 2007
+++ loncom/interface/lonparmset.pm	Sat Mar 17 00:35:03 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.362 2007/03/17 02:14:26 albertel Exp $
+# $Id: lonparmset.pm,v 1.363 2007/03/17 04:35:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -935,57 +935,66 @@
 	$$typep{$id}=$1;
 	$$keyp{$id}='';
         $$uris{$id}=$srcf;
-	foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
-	    if ($_=~/^parameter\_(.*)/) {
-		my $key=$_;
+	foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) {
+	    next if ($key!~/^parameter_/);
+
 # Hidden parameters
-		if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') {
-		    next;
-		}
-		my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
-		my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
-		my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+	    next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm');
 #
 # allparms is a hash of parameter names
 #
+	    my $name=&Apache::lonnet::metadata($srcf,$key.'.name');
+	    if (!exists($$allparms{$name})) {
+		my $display= &Apache::lonnet::metadata($srcf,$key.'.display');
 		my $parmdis = $display;
 		$parmdis =~ s/\[Part.*$//g;
-                $$allparms{$name}=$parmdis;
-		$$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type');
+		$$allparms{$name}=$parmdis;
+		if (ref($defkeytype)) {
+		    $$defkeytype{$name}=
+			&Apache::lonnet::metadata($srcf,$key.'.type');
+		}
+	    }
+
 #
 # allparts is a hash of all parts
 #
-		$$allparts{$part} = "Part: $part";
+	    my $part= &Apache::lonnet::metadata($srcf,$key.'.part');
+	    $$allparts{$part} = "Part: $part";
 #
 # Remember all keys going with this resource
 #
-		if ($$keyp{$id}) {
-		    $$keyp{$id}.=','.$key;
-		} else {
-		    $$keyp{$id}=$key;
-		}
+	    if ($$keyp{$id}) {
+		$$keyp{$id}.=','.$key;
+	    } else {
+		$$keyp{$id}=$key;
+	    }
 #
 # Put in order
 # 
-                unless ($$keyorder{$key}) {
-                    $$keyorder{$key}=$keyordercnt;
-                    $keyordercnt++;
-		}
-
+	    unless ($$keyorder{$key}) {
+		$$keyorder{$key}=$keyordercnt;
+		$keyordercnt++;
 	    }
 	}
-	$$mapp{$id}=
-	    &Apache::lonnet::declutter($resource->enclosing_map_src());
-	$$mapp{$mapid}=$$mapp{$id};
-	$$allmaps{$mapid}=$$mapp{$id};
-	if ($mapid eq '1') {
-	    $$maptitles{$mapid}='Main Course Documents';
+
+	
+	if (!exists($$mapp{$mapid})) {
+	    $$mapp{$id}=
+		&Apache::lonnet::declutter($resource->enclosing_map_src());
+	    $$mapp{$mapid}=$$mapp{$id};
+	    $$allmaps{$mapid}=$$mapp{$id};
+	    if ($mapid eq '1') {
+		$$maptitles{$mapid}='Main Course Documents';
+	    } else {
+		$$maptitles{$mapid}=
+		    &Apache::lonnet::gettitle($$mapp{$id});    
+	    }
+	    $$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
+	    $$symbp{$mapid}=$$mapp{$id}.'___(all)';
 	} else {
-	    $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id}));
+	    $$mapp{$id} = $$mapp{$mapid};
 	}
-	$$maptitles{$$mapp{$id}}=$$maptitles{$mapid};
 	$$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf);
-	$$symbp{$mapid}=$$mapp{$id}.'___(all)';
     }
 }