--- loncom/interface/lonparmset.pm 2014/06/12 22:29:42 1.545 +++ loncom/interface/lonparmset.pm 2014/06/13 01:48:26 1.546 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.545 2014/06/12 22:29:42 raeburn Exp $ +# $Id: lonparmset.pm,v 1.546 2014/06/13 01:48:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2167,7 +2167,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); @@ -2201,13 +2201,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'; } + } 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"}; @@ -2215,7 +2227,7 @@ sub assessparms { unless ($got_chostname) { ($chostname,$cmajor,$cminor) = ¶meter_release_vars(); $got_chostname = 1; - } + } $needsnewer = ¶meter_releasecheck($name,$val, $needsrelease, $cmajor,$cminor); @@ -2836,6 +2848,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; @@ -2846,9 +2859,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') { @@ -2858,24 +2872,50 @@ sub storedata { } elsif ($typeof eq 'string_discussvote') { $name = 'discussvote'; } elsif ($typeof eq 'string_examcode') { - $name = '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('
'.&oldversion_warning($name,$data, $chostname,$cmajor, @@ -2883,14 +2923,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) { @@ -4731,6 +4763,19 @@ sub oldversion_warning { } } } + } 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 '

'.