[LON-CAPA-cvs] cvs: loncom /interface courseprefs.pm lonrelrequtils.pm /misc releaseslist.xml
raeburn
raeburn at source.lon-capa.org
Tue Apr 28 09:20:48 EDT 2015
raeburn Tue Apr 28 13:20:48 2015 EDT
Modified files:
/loncom/interface courseprefs.pm lonrelrequtils.pm
/loncom/misc releaseslist.xml
Log:
- LON-CAPA version requirement checking for IP/Name Access control ("deny
from" type) and relative weights in lenient grading.
- Version checking accommodate parameter values which match a regexp
(for acc and lenient parameters) as well as designated values.
-------------- next part --------------
Index: loncom/interface/courseprefs.pm
diff -u loncom/interface/courseprefs.pm:1.69 loncom/interface/courseprefs.pm:1.70
--- loncom/interface/courseprefs.pm:1.69 Sat Mar 7 23:17:15 2015
+++ loncom/interface/courseprefs.pm Tue Apr 28 13:20:41 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.69 2015/03/07 23:17:15 raeburn Exp $
+# $Id: courseprefs.pm,v 1.70 2015/04/28 13:20:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2325,109 +2325,128 @@
my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
if (ref($resourcedata) eq 'HASH') {
foreach my $key (keys(%{$resourcedata})) {
+ my %found;
foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
if ($key =~ /(\Q$item\E)$/) {
- if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
- my $value = $resourcedata->{$key};
- if ($item eq 'examcode') {
- if (&Apache::lonnet::validCODE($value)) {
- $value = 'valid';
- } else {
- $value = '';
- }
- } elsif ($item eq 'printstartdate') {
+ if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ if ($item eq 'examcode') {
+ if (&Apache::lonnet::validCODE($value)) {
+ $value = 'valid';
+ } 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}})) {
- my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
- my $stdname = &Apache::lonparmset::standard_parameter_names($item);
- my $valname = &get_param_description($stdtype,$value);
- my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
- my $start = $cid.'.';
- if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
- $middle = $1;
- $which = $2;
- $scope = 'user';
- } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
- $middle = $1;
- $which = $2;
- $scope = 'section/group';
- } else {
- $scope = 'all';
- }
- my $what="$stdname=$valname";
- if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
- $level = 'general';
- if ($scope eq 'all') {
- if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
- push(@{$fromparam{$rev}{$scope}},$what);
- }
- } else {
- push(@{$fromparam{$rev}{$scope}},$what);
- }
- } else {
- if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
- push(@{$fromparam{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$fromparam{$rev}{$scope}{$which}},$what);
- }
- }
- $rowspan{$rev} ++;
- } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
- $level = 'folder';
- $map = $1;
- if ($scope eq 'all') {
- if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
- push(@{$bymap{$map}{$rev}{$scope}},$what);
- }
- } else {
- push(@{$bymap{$map}{$rev}{$scope}},$what);
- }
- } else {
- if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
- push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
- }
- }
- } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
- $level = 'resource';
- $resource = $1;
- if ($scope eq 'all') {
- if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
- push(@{$byresource{$resource}{$rev}{$scope}},$what);
- }
- } else {
- push(@{$byresource{$resource}{$rev}{$scope}},$what);
- }
- } else {
- if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
- push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
- }
- }
- }
+ 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 $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value);
+ $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.':'};
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparmsmatch)) {
+ if (ref($Apache::lonrelrequtils::checkparmsmatch{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmsmatch{$item}}) {
+ if ($value =~ /$valuematch/) {
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
+ $found{$item}{'rev'} =
+ $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch};
+ last;
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%found)) {
+ my $stdname = &Apache::lonparmset::standard_parameter_names($item);
+ my $rev = $found{$item}{'rev'};
+ my $valname = $found{$item}{'valname'};
+ my ($middle,$scope,$which,$level,$map,$resource);
+ my $start = $cid.'.';
+ if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'user';
+ } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'section/group';
+ } else {
+ $scope = 'all';
+ }
+ my $what="$stdname=$valname";
+ if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
+ $level = 'general';
+ if ($scope eq 'all') {
+ if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ }
+ $rowspan{$rev} ++;
+ } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
+ $level = 'folder';
+ $map = $1;
+ if ($scope eq 'all') {
+ if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
+ push(@{$bymap{$map}{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ }
+ } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
+ $level = 'resource';
+ $resource = $1;
+ if ($scope eq 'all') {
+ if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
+ push(@{$byresource{$resource}{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
}
}
}
@@ -2851,18 +2870,52 @@
}
sub get_param_description {
- my ($stdtype,$value) = @_;
- my $name = $value;
- my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
- unless (ref($paramstrings) eq 'ARRAY') {
- return $name;
+ my ($stdtype,$value,$regexp) = @_;
+ my ($name,$parammatches,$paramstrings, at possibles);
+ $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
+ if ($regexp) {
+ $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
+ if (ref($parammatches) eq 'ARRAY') {
+ @possibles = @{$parammatches};
+ } else {
+ undef($regexp);
+ $name = $value;
+ }
+ }
+ unless ($regexp) {
+ $name = $value;
+ if (ref($paramstrings) eq 'ARRAY') {
+ @possibles = @{$paramstrings};
+ } else {
+ return $name;
+ }
}
- foreach my $possibilities (@{$paramstrings}) {
+ foreach my $possibilities (@possibles) {
next unless (ref($possibilities) eq 'ARRAY');
- my ($thing, $description) = @{ $possibilities };
- if ($thing eq $value) {
- $name = $description;
- last;
+ my $gotregexmatch = '';
+ if ($regexp) {
+ last if ($gotregexmatch);
+ my ($item,$pattern) = @{ $possibilities };
+ if ($value =~ /$pattern/) {
+ if (ref($paramstrings) eq 'ARRAY') {
+ foreach my $possibles (@{$paramstrings}) {
+ next unless (ref($possibles) eq 'ARRAY');
+ my ($thing,$description) = @{$possibles};
+ if ($thing eq $item) {
+ $name = $description;
+ $gotregexmatch = 1;
+ last;
+ }
+ }
+ last if ($gotregexmatch);
+ }
+ }
+ } else {
+ my ($thing,$description) = @{ $possibilities };
+ if ($thing eq $value) {
+ $name = $description;
+ last;
+ }
}
}
return $name;
Index: loncom/interface/lonrelrequtils.pm
diff -u loncom/interface/lonrelrequtils.pm:1.2 loncom/interface/lonrelrequtils.pm:1.3
--- loncom/interface/lonrelrequtils.pm:1.2 Fri Jun 13 01:48:26 2014
+++ loncom/interface/lonrelrequtils.pm Tue Apr 28 13:20:41 2015
@@ -1,7 +1,7 @@
#!/usr/bin/perl
# The LearningOnline Network
#
-# $Id: lonrelrequtils.pm,v 1.2 2014/06/13 01:48:26 raeburn Exp $
+# $Id: lonrelrequtils.pm,v 1.3 2015/04/28 13:20:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,7 +84,7 @@
Returns major version and minor version requirements for a course,
based on parameters in use in the course. (Parameters which have
-version requirements are listed in /home/httpd/lonTabs/releaseslist.xml
+version requirements are listed in /home/httpd/lonTabs/releaseslist.xml).
Inputs: 2
@@ -265,20 +265,31 @@
sub init_global_hashes {
%Apache::lonrelrequtils::checkparms = ();
+ %Apache::lonrelrequtils::checkparmsmatch = ();
%Apache::lonrelrequtils::checkresponsetypes = ();
%Apache::lonrelrequtils::checkcrstypes = ();
%Apache::lonrelrequtils::anonsurvey = ();
%Apache::lonrelrequtils::randomizetry = ();
foreach my $key (keys(%Apache::lonnet::needsrelease)) {
- my ($item,$name,$value) = split(/:/,$key);
+ my ($item,$name,$value,$valuematch) = split(/:/,$key);
if ($item eq 'parameter') {
- if (ref($Apache::lonrelrequtils::checkparms{$name}) eq 'ARRAY') {
- unless(grep(/^\Q$name\E$/,@{$Apache::lonrelrequtils::checkparms{$name}})) {
+ if ($value ne '') {
+ if (ref($Apache::lonrelrequtils::checkparms{$name}) eq 'ARRAY') {
+ unless(grep(/^\Q$name\E$/,@{$Apache::lonrelrequtils::checkparms{$name}})) {
+ push(@{$Apache::lonrelrequtils::checkparms{$name}},$value);
+ }
+ } else {
push(@{$Apache::lonrelrequtils::checkparms{$name}},$value);
}
- } else {
- push(@{$Apache::lonrelrequtils::checkparms{$name}},$value);
+ } elsif ($valuematch ne '') {
+ if (ref($Apache::lonrelrequtils::checkparmsmatch{$name}) eq 'ARRAY') {
+ unless(grep(/^\Q$name\E$/,@{$Apache::lonrelrequtils::checkparmsmatch{$name}})) {
+ push(@{$Apache::lonrelrequtils::checkparmsmatch{$name}},$valuematch);
+ }
+ } else {
+ push(@{$Apache::lonrelrequtils::checkparmsmatch{$name}},$valuematch);
+ }
}
} elsif ($item eq 'resourcetag') {
if ($name eq 'responsetype') {
@@ -350,13 +361,38 @@
}
}
if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
- my ($major,$minor) = split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value});
+ my ($major,$minor) =
+ split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.':'});
($reqdmajor,$reqdminor) =
&update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
}
}
}
}
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparmsmatch)) {
+ if ($key =~ /(\Q$item\E)$/) {
+ if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ foreach my $entry (@{$Apache::lonrelrequtils::checkparms{$item}}) {
+ my $regexp;
+ if (($item eq 'lenient') && ($entry eq 'weighted')) {
+ $regexp = '^[\-\.\d]+,[\-\.\d]+,[\-\.\d]+,[\-\.\d]+$';
+ } elsif (($item eq 'acc') && ($entry eq '_denyfrom_')) {
+ $regexp = '\!';
+ }
+ if ($regexp ne '') {
+ if ($value =~ /$regexp/) {
+ my ($major,$minor) =
+ split(/\./,$Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$entry});
+ ($reqdmajor,$reqdminor) =
+ &update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor);
+ last;
+ }
+ }
+ }
+ }
+ }
+ }
}
}
return ($reqdmajor,$reqdminor);
Index: loncom/misc/releaseslist.xml
diff -u loncom/misc/releaseslist.xml:1.10 loncom/misc/releaseslist.xml:1.11
--- loncom/misc/releaseslist.xml:1.10 Fri Jun 13 01:48:31 2014
+++ loncom/misc/releaseslist.xml Tue Apr 28 13:20:48 2015
@@ -9,12 +9,14 @@
<parameter name="type" value="practice">2.2</parameter>
<parameter name="lenient" value="yes">2.11</parameter>
<parameter name="lenient" value="no">2.11</parameter>
+<parameter name="lenient" valuematch="weighted">2.12</parameter>
<parameter name="retrypartial" value="yes">2.11</parameter>
<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>
+<parameter name="acc" valuematch="_denyfrom_">2.12</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