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

www lon-capa-cvs@mail.lon-capa.org
Mon, 26 Apr 2004 16:56:26 -0000


www		Mon Apr 26 12:56:26 2004 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
    /rat	lonratedt.pm 
  Log:
  Saving my work on DOCS parameter setting. Currently only works for first
  resource.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.120 loncom/interface/londocs.pm:1.121
--- loncom/interface/londocs.pm:1.120	Sun Apr 25 21:20:17 2004
+++ loncom/interface/londocs.pm	Mon Apr 26 12:56:26 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.120 2004/04/26 01:20:17 www Exp $
+# $Id: londocs.pm,v 1.121 2004/04/26 16:56:26 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -298,8 +298,34 @@
 	   $r->print('<p><font color="red">'.$errtext.'</font></p>');
     } else {
 # ------------------------------------------------------------ Process commands
+
 # ---------------- if they are for this folder and user allowed to make changes
 	if (($allowed) && ($ENV{'form.folder'} eq $folder)) {
+# set parameters
+	    if (defined($ENV{'form.setparms'})) {
+		my $idx=$ENV{'form.setparms'};
+		if ($ENV{'form.randpick_'.$idx}) {
+		    &Apache::lonratedt::storeparameter($idx,'randompick',$ENV{'form.randpick_'.$idx},'int_pos');
+		} else {
+		    &Apache::lonratedt::delparameter($idx,'randompick');
+		}
+		if ($ENV{'form.hidprs_'.$idx}) {
+		    &Apache::lonratedt::storeparameter($idx,'hiddenresource','yes','string_yesno');
+		} else {
+		    &Apache::lonratedt::delparameter($idx,'hiddenresource');
+		}
+		if ($ENV{'form.encprs_'.$idx}) {
+		    &Apache::lonratedt::storeparameter($idx,'encrypturl','yes','string_yesno');
+		} else {
+		    &Apache::lonratedt::delparameter($idx,'encrypturl');
+		}
+
+		($errtext,$fatal)=&storemap($coursenum,$coursedom,$folder.'.sequence');
+		if ($fatal) {
+		    $r->print('<p><font color="red">'.$errtext.'</font></p>');
+		    return;
+		}
+	    }
 # upload a file, if present
            if (($ENV{'form.uploaddoc.filename'}) &&
                ($ENV{'form.cmd'}=~/^upload_(\w+)/)) {
@@ -459,8 +485,9 @@
 		'rm' => 'Remove',
 		'rn' => 'Rename');
 	$line.=(<<END);
-<form name="entry_$index" action="/adm/coursedocs">
-<input type="hidden" name="folderpath" value="$folderpath" />
+<form name="entry_$index" action="/adm/coursedocs" method="post">
+<input type="hidden" name="folderpath" value="$ENV{'form.folderpath'}" />
+<input type="hidden" name="setparms" value="$index" />
 <td><table border='0' cellspacing='2' cellpadding='0'>
 <tr><td bgcolor="#DDDDDD">
 <a href='/adm/coursedocs?cmd=up_$index&folderpath=$folderpath'>
@@ -511,7 +538,8 @@
 	$folderpath.=$folderarg.'&'.$foldername;
 	$url.='folderpath='.&Apache::lonnet::escape($folderpath);
 	$parameterset=&mt('Randomly Pick: ').
-	    '<input type="text" size="4" name="randpick_$index" />';
+	    '<input type="text" size="4" name="randpick_'.$index.'" value="'.
+	    &Apache::lonratedt::getparameter($index,'randompick').'" />';
     }
     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'"><img src="'.$icon.
 	'" border="0"></a></td>'.
@@ -528,7 +556,7 @@
 <input type="checkbox" name="encprs_$index" /> $lt{'ec'}</td>
 <td bgcolor="#BBBBFF"><font size="-2">$parameterset</font></td>
 <td bgcolor="#BBBBFF"><font size='-2'>
-<a href='javascript:alert("Would be storing $index")'>$lt{'sp'}</a>
+<input type="submit" value="$lt{'sp'}" />
 </font></td>
 ENDPARMS
     }
@@ -1105,6 +1133,7 @@
         this.document.forms.renameform.submit();
     }
 }
+
 </script>
 
 ENDNEWSCRIPT
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.56 rat/lonratedt.pm:1.57
--- rat/lonratedt.pm:1.56	Sat Apr 24 11:37:30 2004
+++ rat/lonratedt.pm	Mon Apr 26 12:56:26 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.56 2004/04/24 15:37:30 www Exp $
+# $Id: lonratedt.pm,v 1.57 2004/04/26 16:56:26 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -555,6 +555,21 @@
     unless ($ptype) { $ptype=$nametype; }
     unless ($ptype) { $ptype='string'; }
     $newentry.=$ptype.'___'.$name.'___'.$value;
+    $resparms[$to]=$newentry;
+}
+
+sub delparameter {
+    my ($to,$name)=@_;
+    my $newentry='';
+    my $nametype='';
+    foreach (split('&&&',$resparms[$to])) {
+	my ($thistype,$thisname,$thisvalue)=split('___',$_);
+	if ($thisname) {
+	    unless ($thisname eq $name) {
+		$newentry.=$_.'&&&';
+	    }
+	}
+    }
     $resparms[$to]=$newentry;
 }