[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface lonparmset.pm
raeburn
raeburn at source.lon-capa.org
Thu Jun 12 22:00:31 EDT 2014
raeburn Fri Jun 13 02:00:31 2014 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface lonparmset.pm
Log:
- For 2.11
- Backport 1.546
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.522.2.15 loncom/interface/lonparmset.pm:1.522.2.16
--- loncom/interface/lonparmset.pm:1.522.2.15 Thu Jun 12 22:35:13 2014
+++ loncom/interface/lonparmset.pm Fri Jun 13 02:00:30 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.522.2.15 2014/06/12 22:35:13 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522.2.16 2014/06/13 02:00:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2138,7 +2138,7 @@
my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
my ($got_chostname,$chostname,$cmajor,$cminor);
my $totalstored = 0;
-
+ my $now = time;
for (my $i=0;$i<=$#markers;$i++) {
my ($needsrelease,$needsnewer,$name);
@@ -2172,13 +2172,25 @@
}
}
}
- } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode)\&\d+$/) {
+ } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode|printstartdate|printenddate)\&\d+$/) {
$name = $1;
my $val = $values[$i];
if ($name eq 'examcode') {
if (&Apache::lonnet::validCODE($values[$i])) {
$val = 'valid';
}
+ } elsif ($name eq 'printstartdate') {
+ if ($val =~ /^\d+$/) {
+ if ($val > $now) {
+ $val = 'future';
+ }
+ }
+ } elsif ($name eq 'printenddate') {
+ if ($val =~ /^\d+$/) {
+ if ($val < $now) {
+ $val = 'past';
+ }
+ }
}
$needsrelease =
$Apache::lonnet::needsrelease{"parameter:$name:$val"};
@@ -2813,6 +2825,7 @@
my @deldata=();
undef @deldata;
my ($got_chostname,$chostname,$cmajor,$cminor);
+ my $now = time;
foreach my $key (keys(%env)) {
if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
my $cmd=$1;
@@ -2823,9 +2836,10 @@
$tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
}
if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
- my ($data, $typeof, $text, $name);
+ my ($data, $typeof, $text, $name, $valchk);
if ($cmd eq 'set') {
$data=$env{$key};
+ $valchk = $data;
$typeof=$env{'form.typeof_'.$thiskey};
$text = &mt('Saved modified parameter for');
if ($typeof eq 'string_questiontype') {
@@ -2836,23 +2850,49 @@
$name = 'discussvote';
} elsif ($typeof eq 'string_examcode') {
$name = 'examcode';
+ if (&Apache::lonnet::validCODE($data)) {
+ $valchk = 'valid';
+ }
} elsif ($typeof eq 'string_yesno') {
if ($thiskey =~ /\.retrypartial$/) {
$name = 'retrypartial';
}
}
- if ($name ne '') {
- my ($needsrelease,$needsnewer);
- $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$data"};
- if ($needsrelease) {
- unless ($got_chostname) {
- ($chostname,$cmajor,$cminor)=¶meter_release_vars();
- $got_chostname = 1;
+ } elsif ($cmd eq 'datepointer') {
+ $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
+ if ($typeof eq 'date_start') {
+ if ($thiskey =~ /\.printstartdate$/) {
+ $name = 'printstartdate';
+ if (($data) && ($data > $now)) {
+ $valchk = 'future';
}
- $needsnewer = ¶meter_releasecheck($name,$data,
- $needsrelease,
- $cmajor,$cminor);
}
+ } elsif ($typeof eq 'date_end') {
+ if ($thiskey =~ /\.printenddate$/) {
+ $name = 'printenddate';
+ if (($data) && ($data < $now)) {
+ $valchk = 'past';
+ }
+ }
+ }
+ } elsif ($cmd eq 'dateinterval') {
+ $data=&get_date_interval_from_form($thiskey);
+ $typeof=$env{'form.typeof_'.$thiskey};
+ $text = &mt('Saved modified date for');
+ }
+ if ($name ne '') {
+ my ($needsrelease,$needsnewer);
+ $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
+ if ($needsrelease) {
+ unless ($got_chostname) {
+ ($chostname,$cmajor,$cminor)=¶meter_release_vars();
+ $got_chostname = 1;
+ }
+ $needsnewer = ¶meter_releasecheck($name,$valchk,
+ $needsrelease,
+ $cmajor,$cminor);
if ($needsnewer) {
$r->print('<br />'.&oldversion_warning($name,$data,
$chostname,$cmajor,
@@ -2860,14 +2900,6 @@
next;
}
}
- } elsif ($cmd eq 'datepointer') {
- $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
- $typeof=$env{'form.typeof_'.$thiskey};
- $text = &mt('Saved modified date for');
- } elsif ($cmd eq 'dateinterval') {
- $data=&get_date_interval_from_form($thiskey);
- $typeof=$env{'form.typeof_'.$thiskey};
- $text = &mt('Saved modified date for');
}
if (defined($data) and $$olddata{$thiskey} ne $data) {
if ($tuname) {
@@ -4679,6 +4711,19 @@
}
}
}
+ } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
+ my $now = time;
+ if ($value =~ /^\d+$/) {
+ if ($name eq 'printstartdate') {
+ if ($value > $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ } elsif ($name eq 'printenddate') {
+ if ($value < $now) {
+ $desc = &Apache::lonlocal::locallocaltime($value);
+ }
+ }
+ }
}
my $standard_name = &standard_parameter_names($name);
return '<p class="LC_warning">'.
More information about the LON-CAPA-cvs
mailing list