--- loncom/interface/lonparmset.pm 2005/06/06 17:38:07 1.214
+++ loncom/interface/lonparmset.pm 2005/09/28 23:19:25 1.253
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.214 2005/06/06 17:38:07 www Exp $
+# $Id: lonparmset.pm,v 1.253 2005/09/28 23:19:25 banghart Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,6 +70,8 @@ my $parmhashid;
my %parmhash;
my $symbsid;
my %symbs;
+my $rulesid;
+my %rules;
# --- end local caches
@@ -240,6 +242,38 @@ sub symbcache {
return $symbs{$id};
}
+sub resetrulescache {
+ $rulesid='';
+}
+
+sub rulescache {
+ my $id=shift;
+ if ($rulesid ne $env{'request.course.id'}) {
+ %rules=();
+ }
+ unless (defined($rules{$id})) {
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
+ $rulesid=$env{'request.course.id'};
+ }
+ return $rules{$id};
+}
+
+sub preset_defaults {
+ my $type=shift;
+ if (&rulescache($type.'_action') eq 'default') {
+# yes, there is something
+ return (&rulescache($type.'_hours'),
+ &rulescache($type.'_min'),
+ &rulescache($type.'_sec'),
+ &rulescache($type.'_value'));
+ } else {
+# nothing there or something else
+ return ('','','','','');
+ }
+}
+
##################################################
##################################################
#
@@ -271,7 +305,57 @@ sub storeparm {
# - 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;
+ my $newvalue='';
+ 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);
+ }
+ }
+ }
+ return '';
+}
+
+sub storeparm_by_symb_inner {
# ---------------------------------------------------------- Get symb, map, etc
my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
# ---------------------------------------------------------- Construct prefixes
@@ -440,11 +524,12 @@ sub plink {
$winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]};
}
}
-
-
+ my ($parmname)=((split(/\&/,$marker))[1]=~/\_([^\_]+)$/);
+ my ($hour,$min,$sec,$val)=&preset_defaults($parmname);
+ unless (defined($winvalue)) { $winvalue=$val; }
return
''.
+ .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
&valout($value,$type).'';
}
@@ -544,7 +629,10 @@ sub print_row {
} else {
$parm=~s|\[.*\]\s||g;
}
-
+ my $automatic=&rulescache(($which=~/\_([^\_]+)$/)[0].'_triggers');
+ if ($automatic) {
+ $parm.='
'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'';
+ }
$r->print('
print("\n | '); + $r->print('>'.$$allparms{$tempkey}.''); $cnt++; if ($cnt==3) { $r->print(" | |
-Select All
-Select Standard
+Select All +Select Common Only |
-Select Dates
-Select Visibilities
-Select Part Parameters
+Add Problem Dates
+Add Content Dates +Add Discussion Settings +Add Visibilities +Add Part Parameters | -Unselect All +Unselect All | '); $r->print('