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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 21 Nov 2002 22:32:53 -0000


albertel		Thu Nov 21 17:32:53 2002 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  - was unable to delete a previously set parameter
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.78 loncom/interface/lonparmset.pm:1.79
--- loncom/interface/lonparmset.pm:1.78	Tue Nov 19 14:26:35 2002
+++ loncom/interface/lonparmset.pm	Thu Nov 21 17:32:53 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.78 2002/11/19 19:26:35 matthew Exp $
+# $Id: lonparmset.pm,v 1.79 2002/11/21 22:32:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -780,6 +780,8 @@
 	if ($snum==5) { $storeunder=$seclevelm; }
 	if ($snum==4) { $storeunder=$seclevelr; }
 	
+	my $delete;
+	if ($ENV{'form.pres_value'} eq '') { $delete=1;}
         my %storecontent = ($storeunder         => $ENV{'form.pres_value'},
                             $storeunder.'.type' => $ENV{'form.pres_type'});
 	my $reply='';
@@ -796,10 +798,17 @@
 		&Apache::lonnet::expirespread('','','assesscalc');
 	    }
 # Store parameter
-            $reply=&Apache::lonnet::cput
-                ('resourcedata',\%storecontent,
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
-                 $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	    if ($delete) {
+		$reply=&Apache::lonnet::del
+		    ('resourcedata',[keys(%storecontent)],
+		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	    } else {
+		$reply=&Apache::lonnet::cput
+		    ('resourcedata',\%storecontent,
+		     $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+		     $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+	    }
 	} else {
 # ------------------------------------------------------------------ Store User
 #
@@ -815,8 +824,13 @@
 		&Apache::lonnet::expirespread($uname,$udom,'assesscalc');
 	    }
 # Store parameter
-	    $reply=&Apache::lonnet::cput
-                ('resourcedata',\%storecontent,$udom,$uname);
+	    if ($delete) {
+		$reply=&Apache::lonnet::del
+		    ('resourcedata',[keys(%storecontent)],$udom,$uname);
+	    } else {
+		$reply=&Apache::lonnet::cput
+		    ('resourcedata',\%storecontent,$udom,$uname);
+	    }
 	}
 
 	if ($reply=~/^error\:(.*)/) {