[LON-CAPA-cvs] cvs: loncom /html/adm/helper newslot.helper /interface slotrequest.pm
raeburn
raeburn at source.lon-capa.org
Sun Sep 27 18:35:50 EDT 2015
raeburn Sun Sep 27 22:35:50 2015 EDT
Modified files:
/loncom/interface slotrequest.pm
/loncom/html/adm/helper newslot.helper
Log:
- Usage restriction for a particular slot can be for one or more .sequences
and/or .pages (in which casethe slot may be used for all resources within
those map(s)), or for one or more specific .problem(s).
-------------- next part --------------
Index: loncom/interface/slotrequest.pm
diff -u loncom/interface/slotrequest.pm:1.129 loncom/interface/slotrequest.pm:1.130
--- loncom/interface/slotrequest.pm:1.129 Sun Sep 27 14:21:48 2015
+++ loncom/interface/slotrequest.pm Sun Sep 27 22:35:39 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler for requesting to have slots added to a students record
#
-# $Id: slotrequest.pm,v 1.129 2015/09/27 14:21:48 raeburn Exp $
+# $Id: slotrequest.pm,v 1.130 2015/09/27 22:35:39 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1114,14 +1114,25 @@
# not allowed for this resource
if (defined($slot->{'symb'})) {
my $exclude = 1;
- my ($slotmap,$slotid,$sloturl) = &Apache::lonnet::decode_symb($slot->{'symb'});
- if ($sloturl=~/\.(page|sequence)$/) {
- my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
- if (($map ne '') && ($map eq $slotmap)) {
+ my @symbs;
+ if ($slot->{'symb'} =~ /,/) {
+ @symbs = split(/\s*,\s*/,$slot->{'symb'});
+ } else {
+ @symbs = ($slot->{'symb'});
+ }
+ my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
+ foreach my $reqsymb (@symbs) {
+ next if ($reqsymb eq '');
+ my ($slotmap,$slotid,$sloturl) = &Apache::lonnet::decode_symb($reqsymb);
+ if ($sloturl=~/\.(page|sequence)$/) {
+ if (($map ne '') && ($map eq $sloturl)) {
+ $exclude = 0;
+ last;
+ }
+ } elsif ($reqsymb eq $symb) {
$exclude = 0;
+ last;
}
- } elsif ($slot->{'symb'} eq $symb) {
- $exclude = 0;
}
if ($exclude) {
unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) {
@@ -1478,7 +1489,7 @@
'secret' => 'Secret Word',
'space' => '# of students/max',
'ip' => 'IP or DNS restrictions',
- 'symb' => 'Resource/Map slot is restricted to.',
+ 'symb' => 'Resource(s)/Map(s) slot is restricted to.',
'allowedsections' => 'Sections slot is restricted to.',
'allowedusers' => 'Users slot is restricted to.',
'uniqueperiod' => 'Period of time slot is unique',
@@ -1693,13 +1704,21 @@
localtime($slots{$slot}{'uniqueperiod'}[1]);
}
- my $title;
+ my @titles;
if (exists($slots{$slot}{'symb'})) {
- my (undef,undef,$res)=
- &Apache::lonnet::decode_symb($slots{$slot}{'symb'});
- $res = &Apache::lonnet::clutter($res);
- $title = &Apache::lonnet::gettitle($slots{$slot}{'symb'});
- $title='<a href="'.$res.'?symb='.$slots{$slot}{'symb'}.'">'.$title.'</a>';
+ my @symbs;
+ if ($slots{$slot}{'symb'} =~ /,/) {
+ @symbs = split(/\s*,\s*/,$slots{$slot}{'symb'});
+ } else {
+ @symbs = ($slots{$slot}{'symb'});
+ }
+ foreach my $reqsymb (@symbs) {
+ my (undef,undef,$res) =
+ &Apache::lonnet::decode_symb($reqsymb);
+ $res = &Apache::lonnet::clutter($res);
+ my $title = &Apache::lonnet::gettitle($reqsymb);
+ push(@titles,'<a href="'.$res.'?symb='.$reqsymb.'">'.$title.'</a>');
+ }
}
my $allowedsections;
@@ -1816,7 +1835,7 @@
$colspan++;$r->print("<td>$slots{$slot}{'ip'}</td>\n");
}
if (exists($show{'symb'})) {
- $colspan++;$r->print("<td>$title</td>\n");
+ $colspan++;$r->print("<td>".join('<br />', at titles)."</td>\n");
}
if (exists($show{'allowedsections'})) {
$colspan++;$r->print("<td>$allowedsections</td>\n");
@@ -2186,9 +2205,26 @@
foreach my $slot (@{$allavailable}) {
# not allowed for this resource
if (ref($slots->{$slot}) eq 'HASH') {
- if ((defined($slots->{$slot}->{'symb'})) &&
- ($slots->{$slot}->{'symb'} ne $symb)) {
- next;
+ if ($slots->{$slot}->{'symb'} ne '') {
+ my ($map,$id,$url) = &Apache::lonnet::decode_symb($symb);
+ my $exclude = 1;
+ my @reqsymbs = split(/\s*,\s*/,$slots->{$slot}->{'symb'});
+ if (@reqsymbs) {
+ if (grep(/^\Q$symb\E$/, at reqsymbs)) {
+ $exclude = 0;
+ } else {
+ foreach my $reqsymb (@reqsymbs) {
+ my (undef,undef,$sloturl) = &Apache::lonnet::decode_symb($reqsymb);
+ if ($sloturl=~/\.(page|sequence)$/) {
+ if (($map ne '') && ($map eq $sloturl)) {
+ $exclude = 0;
+ last;
+ }
+ }
+ }
+ }
+ next if ($exclude);
+ }
}
}
push(@available,$slot);
@@ -2919,7 +2955,7 @@
['proctor','List of proctor ids'],
['description','Slot Description'],
['maxspace','Maximum number of reservations'],
- ['symb','Resource/Map Restriction'],
+ ['symb','Resource(s)/Map(s) Restriction'],
['uniqueperiod','Date range of slot exclusion'],
['secret','Secret word proctor uses to validate'],
['allowedsections','Sections slot is restricted to'],
Index: loncom/html/adm/helper/newslot.helper
diff -u loncom/html/adm/helper/newslot.helper:1.31 loncom/html/adm/helper/newslot.helper:1.32
--- loncom/html/adm/helper/newslot.helper:1.31 Wed Sep 23 23:05:04 2015
+++ loncom/html/adm/helper/newslot.helper Sun Sep 27 22:35:50 2015
@@ -220,12 +220,18 @@
<choices variable="restricttosymb">
<choice nextstate="PROCTOR" computer='any'>usable for any resource.</choice>
- <choice nextstate="MAPSELECT" computer='map'>restricted to resources in a specific folder/composite page.</choice>
- <choice nextstate="RESOURCESELECT" computer='resource'>restricted to a specific resource.</choice>
+ <choice nextstate="MAPSELECT" computer='map'>restricted to resources in specific folder(s)/composite page(s).</choice>
+ <choice nextstate="RESOURCESELECT" computer='resource'>restricted to specific resource(s).</choice>
<defaultvalue>
my $default=&{$helper->{DATA}{origslot}}('symb');
if ($default) {
- if ($default =~ /\.(page|sequence)$/) {
+ my @symbs;
+ if ($default =~ /,/) {
+ @symbs = split(/\s*,\s*/,$default);
+ } else {
+ @symbs = ($default);
+ }
+ if (grep(/\.(page|sequence)$/, at symbs)) {
return 'map';
} else {
return 'resource';
@@ -255,11 +261,17 @@
<nextstate>PROCTOR</nextstate>
- <resource variable="symb">
- <filterfunc>return $res->is_problem()</filterfunc>
+ <resource variable="symb" multichoice="1">
+ <filterfunc>return $res->is_map() || $res->is_problem()</filterfunc>
+ <choicefunc>return $res->is_problem()</choicefunc>
<valuefunc>return $res->symb()</valuefunc>
<defaultvalue>
- return &{$helper->{DATA}{origslot}}('symb');
+ my @defaults;
+ my $default=&{$helper->{DATA}{origslot}}('symb');
+ if ($default) {
+ @defaults=(split(/\s*,\s*/,$default));
+ }
+ return @defaults;
</defaultvalue>
</resource>
</state>
@@ -268,11 +280,16 @@
<nextstate>PROCTOR</nextstate>
- <resource variable="symb">
+ <resource variable="symb" multichoice="1">
<filterfunc>return $res->is_map()</filterfunc>
<valuefunc>return $res->symb()</valuefunc>
<defaultvalue>
- return &{$helper->{DATA}{origslot}}('symb');
+ my @defaults;
+ my $default=&{$helper->{DATA}{origslot}}('symb');
+ if ($default) {
+ @defaults=(split(/\s*,\s*/,$default));
+ }
+ return @defaults;
</defaultvalue>
</resource>
</state>
@@ -314,16 +331,16 @@
</message>
<message>
- Select sections to limit slot availability to: <br />
+ <h3>Select sections to limit slot availability to: </h3>
</message>
<section variable="allowedsections" multichoice="1" allowempty="1">
<defaultvalue>
- return join('|||',
+ return join('|||',
split(',',&{$helper->{DATA}{origslot}}('allowedsections')));
</defaultvalue>
</section>
<message>
- Select users to limit slot availability to: <br />
+ <br /><h3>Select users to limit slot availability to: </h3>
</message>
<student variable="allowedusers" multichoice="1" coursepersonnel="1"
activeonly="1" emptyallowed="1">
@@ -346,7 +363,7 @@
$slot{$which} = $helper->{'VARS'}{$which};
}
- foreach my $which ('ip','description','maxspace','secret','symb') {
+ foreach my $which ('ip','description','maxspace','secret') {
if ( $helper->{'VARS'}{$which} =~/\S/ ) {
$slot{$which} = $helper->{'VARS'}{$which};
}
@@ -361,6 +378,17 @@
}
}
+ if (($helper->{'VARS'}{'restricttosymb'} =~ /^(map|resource)$/) &&
+ ($helper->{'VARS'}{'symb'} =~ /\S/)) {
+ my @symbs;
+ foreach my $symb (split(/\|\|\|/, $helper->{'VARS'}{'symb'})) {
+ push(@symbs,$symb);
+ }
+ # make sure the symbs are unique
+ my %symbs = map { ($_,1) } @symbs;
+ $slot{'symb'}=join(',',sort(keys(%symbs)));
+ }
+
if ( $helper->{'VARS'}{'startreserve'} > 0) {
$slot{'startreserve'} = $helper->{'VARS'}{'startreserve'};
}
@@ -384,7 +412,7 @@
my ($uname,$udomain)=split(/:/,$user);
push(@names,"$uname:$udomain");
}
- # make sure the usernmaes are unique
+ # make sure the usernames are unique
my %proctors = map { ($_,1) } @names;
$slot{'proctor'}=join(',',sort(keys(%proctors)));
}
@@ -425,13 +453,26 @@
"\n".'<li> Type: '.$slot{'type'}.'</li>';
my %labels =
map {($_->[0],$_->[1])} &Apache::slotrequest::csvupload_fields();
- foreach my $which ('ip','description','maxspace','secret','symb',
+ foreach my $which ('ip','description','maxspace','secret',
'allowedsections','allowedusers') {
if (exists($slot{$which})) {
$result.="\n".'<li> '.$labels{$which}.': '.
&HTML::Entities::encode($slot{$which}).'</li>';
}
}
+ if (exists($slot{'symb'})) {
+ $result.="\n".'<li> '.$labels{'symb'}.': ';
+ if ($slot{'symb'} =~ /,/) {
+ $result.='<ul>';
+ foreach my $symb (split(/\s*,\s*/,$slot{'symb'})) {
+ $result.='<li>'.&HTML::Entities::encode($symb).'</li>';
+ }
+ $result.='</ul>';
+ } else {
+ $result.=&HTML::Entities::encode($slot{'symb'});
+ }
+ $result.='</li>';
+ }
if (exists($slot{'startreserve'})) {
$result.="\n".'<li> '.$labels{'startreserve'}.': '.
&Apache::lonlocal::locallocaltime($slot{'startreserve'}).'</li>';
More information about the LON-CAPA-cvs
mailing list