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

www lon-capa-cvs@mail.lon-capa.org
Fri, 17 Jun 2005 20:01:54 -0000


www		Fri Jun 17 16:01:54 2005 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm 
  Log:
  Saving my work.
  
  
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.225 loncom/interface/lonparmset.pm:1.226
--- loncom/interface/lonparmset.pm:1.225	Fri Jun 17 14:29:45 2005
+++ loncom/interface/lonparmset.pm	Fri Jun 17 16:01:50 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.225 2005/06/17 18:29:45 albertel Exp $
+# $Id: lonparmset.pm,v 1.226 2005/06/17 20:01:50 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -291,7 +291,36 @@
 # - username
 # - userdomain
 
+my %recstack;
 sub storeparm_by_symb {
+    my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag)=@_;
+    unless ($recflag) {
+# first time call
+	%recstack=();
+	$recflag=1;
+    }
+# store parameter
+    &storeparm_by_symb_inner
+	($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
+    my ($prefix,$parm)=($spnam=~/^(.*[\_\.])([^\_\.]+)$/);
+# remember that this was set
+    $recstack{$parm}=1;
+# what does this trigger?
+    foreach my $triggered (split(/\:/,&rulescache($parm.'_triggers'))) {
+# don't backfire
+       unless ((!$triggered) || ($recstack{$triggered})) {
+	   my $action=&rulescache($triggered.'_action');
+	   my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
+# set triggered parameter on same level
+	   my $newspnam=$prefix.$triggered;
+
+	   &Apache::lonnet::logthis('About to set '.$newspnam.' using action '.$whichaction.' with '.$parm.' ('.$whichparm.')');
+       }
+    }
+    return '';
+}
+
+sub storeparm_by_symb_inner {
 # ---------------------------------------------------------- Get symb, map, etc
     my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
 # ---------------------------------------------------------- Construct prefixes
@@ -2590,11 +2619,18 @@
     if ($env{'form.storerules'}) {
 	my %newrules=();
 	my @delrules=();
+	my %triggers=();
 	foreach my $key (keys(%env)) {
             if ($key=~/^form\.(\w+)\_action$/) {
 		my $tempkey=$1;
-                if ($env{$key}) {
-		    $newrules{$tempkey.'_action'}=$env{$key};
+		my $action=$env{$key};
+                if ($action) {
+		    $newrules{$tempkey.'_action'}=$action;
+		    if ($action ne 'default') {
+			my ($whichaction,$whichparm)=($action=~/^(.*\_)([^\_]+)$/);
+			$triggers{$whichparm}.=$tempkey.':';
+		    }
+		    $newrules{$tempkey.'_type'}=$defkeytype{$tempkey};
 		    if (&isdateparm($defkeytype{$tempkey})) {
 			$newrules{$tempkey.'_hours'}=$env{'form.'.$tempkey.'_hours'};
 			$newrules{$tempkey.'_min'}=$env{'form.'.$tempkey.'_min'};
@@ -2604,6 +2640,7 @@
 		    }
 		} else {
 		    push(@delrules,$tempkey.'_action');
+		    push(@delrules,$tempkey.'_type');
 		    push(@delrules,$tempkey.'_hours');
 		    push(@delrules,$tempkey.'_min');
 		    push(@delrules,$tempkey.'_sec');
@@ -2611,6 +2648,9 @@
 		}
 	    }
 	}
+	foreach my $key (keys %allparms) {
+	    $newrules{$key.'_triggers'}=$triggers{$key};
+	}
 	&Apache::lonnet::put('parmdefactions',\%newrules,$dom,$crs);
 	&Apache::lonnet::del('parmdefactions',\@delrules,$dom,$crs);
 	&resetrulescache();