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

www lon-capa-cvs@mail.lon-capa.org
Sat, 18 Jun 2005 14:39:26 -0000


www		Sat Jun 18 10:39:26 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Supporting the setting of a parameter when another one is set.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.227 loncom/interface/lonparmset.pm:1.228
--- loncom/interface/lonparmset.pm:1.227	Fri Jun 17 16:56:06 2005
+++ loncom/interface/lonparmset.pm	Sat Jun 18 10:39:24 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.227 2005/06/17 20:56:06 www Exp $
+# $Id: lonparmset.pm,v 1.228 2005/06/18 14:39:24 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -314,11 +314,28 @@
 # set triggered parameter on same level
 	   my $newspnam=$prefix.$triggered;
 	   my $newvalue='';
-	   if ($action eq 'when_setting_') {
+	   my $active=1;
+	   if ($action=~/^when\_setting/) {
+# are there restrictions?
+	       if (&rulescache($triggered.'_triggervalue')=~/\w/) {
+		   $active=0;
+		   foreach my $possiblevalue (split(/\s*\,\s*/,&rulescache($triggered.'_triggervalue'))) {
+		       if (lc($possiblevalue) eq lc($nval)) { $active=1; }
+		   }
+	       }
+	       $newvalue=&rulescache($triggered.'_value');
 	   } else {
 	       my $totalsecs=((&rulescache($triggered.'_days')*24+&rulescache($triggered.'_hours'))*60+&rulescache($triggered.'_min'))*60+&rulescache($triggered.'_sec');
+	       if ($action=~/^later\_than/) {
+		   $newvalue=$nval+$totalsecs;
+	       } else {
+		   $newvalue=$nval-$totalsecs;
+	       }
+	   }
+	   if ($active) {
+	       &storeparm_by_symb($symb,$newspnam,$snum,$newvalue,&rulescache($triggered.'_type'),
+				   $uname,$udom,$csec,$recflag);
 	   }
-	   &Apache::lonnet::logthis('About to set '.$newspnam.' using action '.$whichaction.' with '.$parm.' ('.$whichparm.')');
        }
     }
     return '';