[LON-CAPA-cvs] cvs: rat /client parameter.html loncom/interface lonhtmlcommon.pm lonparmset.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 14 Jun 2005 02:33:20 -0000
www Mon Jun 13 22:33:20 2005 EDT
Modified files:
/loncom/interface lonhtmlcommon.pm lonparmset.pm
/rat/client parameter.html
Log:
Saving my work: default parameter setting actions
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.107 loncom/interface/lonhtmlcommon.pm:1.108
--- loncom/interface/lonhtmlcommon.pm:1.107 Mon Jun 6 11:54:28 2005
+++ loncom/interface/lonhtmlcommon.pm Mon Jun 13 22:33:18 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common html routines
#
-# $Id: lonhtmlcommon.pm,v 1.107 2005/06/06 15:54:28 www Exp $
+# $Id: lonhtmlcommon.pm,v 1.108 2005/06/14 02:33:18 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -258,7 +258,7 @@
##############################################
sub date_setter {
my ($formname,$dname,$currentvalue,$special,$includeempty,$state,
- $no_hh_mm_ss) = @_;
+ $no_hh_mm_ss,$defhour,$defmin,$defsec) = @_;
my $wasdefined=1;
if (! defined($state) || $state ne 'disabled') {
$state = '';
@@ -282,8 +282,9 @@
$year += 1900;
}
unless ($wasdefined) {
- $sec=0;
- $min=0;
+ $sec=($defsec?$defsec:0);
+ $min=($defmin?$defmin:0);
+ $hour=($defhour?$defhour:0);
}
my $result = "\n<!-- $dname date setting form -->\n";
$result .= <<ENDJS;
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.220 loncom/interface/lonparmset.pm:1.221
--- loncom/interface/lonparmset.pm:1.220 Mon Jun 13 11:35:37 2005
+++ loncom/interface/lonparmset.pm Mon Jun 13 22:33:18 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.220 2005/06/13 15:35:37 www Exp $
+# $Id: lonparmset.pm,v 1.221 2005/06/14 02:33:18 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,6 +70,8 @@
my %parmhash;
my $symbsid;
my %symbs;
+my $rulesid;
+my %rules;
# --- end local caches
@@ -240,6 +242,24 @@
return $symbs{$id};
}
+sub resetrulescache {
+ $rulesid='';
+}
+
+sub rulescache {
+ my $id=shift;
+ if ($rulesid ne $env{'request.course.id'}) {
+ %rules=();
+ }
+ unless ($rules{$id}) {
+ my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
+ $rulesid=$env{'request.course.id'};
+ }
+ return $rules{$id};
+}
+
##################################################
##################################################
#
@@ -2551,12 +2571,52 @@
$breadcrumbs
<form method="post" action="/adm/parmset?action=setdefaults" name="defaultform">
ENDDEFHEAD
- my %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
if ($env{'form.storerules'}) {
- %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs);
+ &resetrulescache();
}
-
-
+ my @ids=();
+ my %typep=();
+ my %keyp=();
+ my %allparms=();
+ my %allparts=();
+ my %allmaps=();
+ my %mapp=();
+ my %symbp=();
+ my %maptitles=();
+ my %uris=();
+ my %keyorder=&standardkeyorder();
+ my %defkeytype=();
+
+ &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allmaps,
+ \%mapp, \%symbp,\%maptitles,\%uris,
+ \%keyorder,\%defkeytype);
+ my %lt=&Apache::lonlocal::texthash('hours' => 'Hours',
+ 'min' => 'Minutes',
+ 'sec' => 'Seconds',
+ 'yes' => 'Yes',
+ 'no' => 'No');
+ $r->print("\n<table border='1'><tr><th>".&mt('Rule for parameter').'</th><th>'.
+ &mt('Automatically set to ...').'</th><th>'.&mt('if ...').'</th></tr>');
+ foreach my $tempkey (&keysindisplayorder(\%allparms,\%keyorder)) {
+ $r->print("\n<tr><td>".$allparms{$tempkey}."\n<br />(".$tempkey.')</td><td>');
+ if (&isdateparm($defkeytype{$tempkey})) {
+ $r->print(<<ENDINPUTDATE);
+<input name="$tempkey\_hours" type="text" size="4" />$lt{'hours'}<br />
+<input name="$tempkey\_min" type="text" size="4" />$lt{'min'}<br />
+<input name="$tempkey\_sec" type="text" size="4" />$lt{'sec'}
+ENDINPUTDATE
+ } elsif ($defkeytype{$tempkey} eq 'string_yesno') {
+ $r->print(<<ENDYESNO);
+<label><input type="radio" name="$tempkey" value="yes" /> $lt{'yes'}</label><br />
+<label><input type="radio" name="$tempkey" value="no" /> $lt{'no'}</label>
+ENDYESNO
+ } else {
+ $r->print('<input type="text" size="20" name="'.$tempkey.'" />');
+ }
+ $r->print('</td></tr>');
+
+ }
+ $r->print("</table></form></body></html>");
return;
}
Index: rat/client/parameter.html
diff -u rat/client/parameter.html:1.30 rat/client/parameter.html:1.31
--- rat/client/parameter.html:1.30 Mon Jun 6 12:06:25 2005
+++ rat/client/parameter.html Mon Jun 13 22:33:18 2005
@@ -3,7 +3,7 @@
The LearningOnline Network with CAPA
Parameter Input Window
//
-// $Id: parameter.html,v 1.30 2005/06/06 16:06:25 www Exp $
+// $Id: parameter.html,v 1.31 2005/06/14 02:33:18 www Exp $
//
// Copyright Michigan State University Board of Trustees
//
@@ -42,6 +42,10 @@
var pmarker='';
var pname='';
+var defhour=0;
+var defmin=0;
+var defsec=0;
+
var svalue;
var stype;
var smarker;
@@ -726,6 +730,9 @@
if (pair[0]=='call') { pcode=pair[1]; }
if (pair[0]=='marker') { pmarker=pair[1]; }
if (pair[0]=='name') { pname=pair[1]; }
+ if (pair[0]=='defhour') { defhour=pair[1]; }
+ if (pair[0]=='defmin') { defmin=pair[1]; }
+ if (pair[0]=='defsec') { defsec=pair[1]; }
}
svalue=pvalue;
@@ -771,8 +778,9 @@
if ((pvalue!='') && (typeof(pvalue)!="undefined")) {
cdate.setTime(pvalue*1000);
} else {
- cdate.setSeconds(0);
- cdate.setMinutes(0);
+ cdate.setSeconds(defsec);
+ cdate.setMinutes(defmin);
+ cdate.setHours(defhour);
}
months[0]='January';