[LON-CAPA-cvs] cvs: rat / lonratedt.pm

www lon-capa-cvs@mail.lon-capa.org
Sat, 24 Apr 2004 15:37:30 -0000


www		Sat Apr 24 11:37:30 2004 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  Routines to selectively get and set certain parameters
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.55 rat/lonratedt.pm:1.56
--- rat/lonratedt.pm:1.55	Sat Apr 24 11:05:16 2004
+++ rat/lonratedt.pm	Sat Apr 24 11:37:30 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.55 2004/04/24 15:05:16 www Exp $
+# $Id: lonratedt.pm,v 1.56 2004/04/24 15:37:30 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -536,6 +536,43 @@
      &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
 }
 
+# ------------------------------------------ Store and get parameters in global
+
+sub storeparameter {
+    my ($to,$name,$value,$ptype)=@_;
+    my $newentry='';
+    my $nametype='';
+    foreach (split('&&&',$resparms[$to])) {
+	my ($thistype,$thisname,$thisvalue)=split('___',$_);
+	if ($thisname) {
+	    unless ($thisname eq $name) {
+		$newentry.=$_.'&&&';
+	    } else {
+		$nametype=$thistype;
+	    }
+	}
+    }
+    unless ($ptype) { $ptype=$nametype; }
+    unless ($ptype) { $ptype='string'; }
+    $newentry.=$ptype.'___'.$name.'___'.$value;
+    $resparms[$to]=$newentry;
+}
+
+sub getparameter {
+    my ($to,$name);
+    my $value=undef;
+    my $ptype=undef;
+    foreach (split('&&&',$resparms[$to])) {
+	my ($thistype,$thisname,$thisvalue)=split('___',$_);
+	if ($thisname eq $name) {
+	    $value=$thisvalue;
+	    $ptype=$thistype;
+	}
+    }
+    return ($value,$ptype);
+}
+
+# ----------------------------------------------------------------- Edit script
 sub editscript {
     my $mode=shift;
     my $resurl=&Apache::loncommon::lastresurl();