--- loncom/interface/lonparmset.pm 2013/12/19 19:31:53 1.522.2.12
+++ loncom/interface/lonparmset.pm 2015/03/12 02:44:51 1.522.2.17
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.522.2.12 2013/12/19 19:31:53 raeburn Exp $
+# $Id: lonparmset.pm,v 1.522.2.17 2015/03/12 02:44:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1382,8 +1382,8 @@ sub lookUpTableParameter {
'contentopen' => 'time_settings',
'contentclose' => 'time_settings',
'discussend' => 'time_settings',
- 'printopendate' => 'time_settings',
- 'printclosedate' => 'time_settings',
+ 'printstartdate' => 'time_settings',
+ 'printenddate' => 'time_settings',
'weight' => 'grading',
'handgrade' => 'grading',
'maxtries' => 'tries',
@@ -1970,8 +1970,8 @@ sub standardkeyorder {
'parameter_0_discussend' => 19,
'parameter_0_discusshide' => 20,
'parameter_0_discussvote' => 21,
- 'parameter_0_printopendate' => 22,
- 'parameter_0_printclosedate' => 23);
+ 'parameter_0_printstartdate' => 22,
+ 'parameter_0_printenddate' => 23);
}
@@ -2138,7 +2138,7 @@ sub assessparms {
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 @@ sub assessparms {
}
}
}
- } 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';
- }
+ 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"};
@@ -2189,7 +2201,6 @@ sub assessparms {
}
$needsnewer = ¶meter_releasecheck($name,$val,
$needsrelease,
- $chostname,
$cmajor,$cminor);
}
}
@@ -2814,6 +2825,7 @@ sub storedata {
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;
@@ -2824,9 +2836,10 @@ sub storedata {
$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') {
@@ -2837,24 +2850,49 @@ sub storedata {
$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,
- $chostname,$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('
'.&oldversion_warning($name,$data,
$chostname,$cmajor,
@@ -2862,14 +2900,6 @@ sub storedata {
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) {
@@ -2913,7 +2943,7 @@ sub storedata {
if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') {
my %loghash=map { $_ => '' } @deldata;
&log_parmset(\%loghash,1);
- $r->print('
'.&mt('Shifting all dates such that [_1] becomes [_2]', &Apache::lonlocal::locallocaltime($env{'form.timebase'}), - &Apache::lonlocal::locallocaltime($timeshifted))); + &Apache::lonlocal::locallocaltime($timeshifted)).'
'); my $delta=$timeshifted-$env{'form.timebase'}; &dateshift($delta); + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Done')). + ''.