[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonparmset.pm lonrelrequtils.pm /misc releaseslist.xml
raeburn
raeburn at source.lon-capa.org
Thu Jun 12 21:48:31 EDT 2014
raeburn Fri Jun 13 01:48:31 2014 EDT
Modified files:
/loncom/interface lonparmset.pm courseprefs.pm lonrelrequtils.pm
/loncom/misc releaseslist.xml
Log:
- Setting the printstartdate parameter to a date/time in the future, or
setting the printstartdate parameter to a date/time in the past
(used to prevent printout generation by students) require the course's
homeserver to have LON-CAPA 2.11 installed.
-------------- next part --------------
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.545 loncom/interface/lonparmset.pm:1.546
--- loncom/interface/lonparmset.pm:1.545 Thu Jun 12 22:29:42 2014
+++ loncom/interface/lonparmset.pm Fri Jun 13 01:48:26 2014
@@ -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 @@
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 @@
}
}
}
- } 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 @@
unless ($got_chostname) {
($chostname,$cmajor,$cminor) = ¶meter_release_vars();
$got_chostname = 1;
- }
+ }
$needsnewer = ¶meter_releasecheck($name,$val,
$needsrelease,
$cmajor,$cminor);
@@ -2836,6 +2848,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;
@@ -2846,9 +2859,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') {
@@ -2858,24 +2872,50 @@
} 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('<br />'.&oldversion_warning($name,$data,
$chostname,$cmajor,
@@ -2883,14 +2923,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) {
@@ -4731,6 +4763,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">'.
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.66 loncom/interface/courseprefs.pm:1.67
--- loncom/interface/courseprefs.pm:1.66 Sat Jun 7 19:13:41 2014
+++ loncom/interface/courseprefs.pm Fri Jun 13 01:48:26 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.66 2014/06/07 19:13:41 raeburn Exp $
+# $Id: courseprefs.pm,v 1.67 2014/06/13 01:48:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2319,6 +2319,7 @@
my (%fromparam,%rowspan,%bymap,%byresource, at scopeorder,%toshow,%allmaps,
%byresponsetype,%bysubmission,%fromblocks);
@scopeorder = ('all','section/group','user');
+ my $now = time;
my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
if (ref($resourcedata) eq 'HASH') {
foreach my $key (keys(%{$resourcedata})) {
@@ -2332,6 +2333,18 @@
} else {
$value = '';
}
+ } elsif ($item eq 'printstartdate') {
+ if ($value =~ /^\d+$/) {
+ if ($value > $now) {
+ $value = 'future';
+ }
+ }
+ } elsif ($item eq 'printenddate') {
+ if ($value =~ /^\d+$/) {
+ if ($value < $now) {
+ $value = 'past';
+ }
+ }
}
my ($middle,$scope,$which,$level,$map,$resource);
if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
Index: loncom/interface/lonrelrequtils.pm
diff -u loncom/interface/lonrelrequtils.pm:1.1 loncom/interface/lonrelrequtils.pm:1.2
--- loncom/interface/lonrelrequtils.pm:1.1 Sat Jun 7 19:13:42 2014
+++ loncom/interface/lonrelrequtils.pm Fri Jun 13 01:48:26 2014
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# The LearningOnline Network
#
-# $Id: lonrelrequtils.pm,v 1.1 2014/06/07 19:13:42 raeburn Exp $
+# $Id: lonrelrequtils.pm,v 1.2 2014/06/13 01:48:26 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -323,6 +323,7 @@
my ($cnum,$cdom) = @_;
my ($reqdmajor,$reqdminor);
my $resourcedata=&read_paramdata($cnum,$cdom);
+ my $now = time;
if (ref($resourcedata) eq 'HASH') {
foreach my $key (keys(%{$resourcedata})) {
foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
@@ -335,6 +336,18 @@
} else {
$value = '';
}
+ } elsif ($item eq 'printstartdate') {
+ if ($value =~ /^\d+$/) {
+ if ($value > $now) {
+ $value = 'future';
+ }
+ }
+ } elsif ($item eq 'printenddate') {
+ if ($value =~ /^\d+$/) {
+ if ($value < $now) {
+ $value = 'past';
+ }
+ }
}
if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
my ($major,$minor) = split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value});
Index: loncom/misc/releaseslist.xml
diff -u loncom/misc/releaseslist.xml:1.9 loncom/misc/releaseslist.xml:1.10
--- loncom/misc/releaseslist.xml:1.9 Wed Jun 26 21:22:42 2013
+++ loncom/misc/releaseslist.xml Fri Jun 13 01:48:31 2014
@@ -13,6 +13,8 @@
<parameter name="discussvote" value="yes">2.11</parameter>
<parameter name="discussvote" value="notended">2.11</parameter>
<parameter name="examcode" value="valid">2.11</parameter>
+<parameter name="printstartdate" value="future">2.11</parameter>
+<parameter name="printenddate" value="past">2.11</parameter>
<resourcetag name="responsetype" value="custom">2.1</resourcetag>
<resourcetag name="responsetype" value="math">2.2</resourcetag>
<resourcetag name="responsetype" value="functionplot">2.10</resourcetag>
More information about the LON-CAPA-cvs
mailing list