--- loncom/interface/slotrequest.pm 2015/09/27 14:21:48 1.129
+++ loncom/interface/slotrequest.pm 2018/06/24 04:11:08 1.138
@@ -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.138 2018/06/24 04:11:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -465,7 +465,7 @@ sub get_consumed_uniqueperiods {
return 'error: Unable to determine current status';
}
my @problems = $navmap->retrieveResources(undef,
- sub { $_[0]->is_problem() },1,0);
+ sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0);
my %used_slots;
foreach my $problem (@problems) {
my $symb = $problem->symb();
@@ -805,7 +805,7 @@ sub release_reservation {
if ($passed_resource->is_map()) {
my ($a_resource) =
$navmap->retrieveResources($passed_resource,
- sub {$_[0]->is_problem()},0,1);
+ sub {$_[0]->is_problem() || $_[0]->is_tool() },0,1);
$symb = $a_resource->symb();
}
} else {
@@ -938,9 +938,15 @@ sub get_slot {
if ($slot_name && $slot_name ne $conflictable_slot) {
my %slot=&Apache::lonnet::get_slot($slot_name);
my $description1=&get_description($slot_name,\%slot);
+ my $slottype1=$slot{'type'};
%slot=&Apache::lonnet::get_slot($env{'form.slotname'});
my $description2=&get_description($env{'form.slotname'},\%slot);
- if ($slot_name ne $env{'form.slotname'}) {
+ if ($slottype1 eq 'preassigned') {
+ $r->print('
'.&mt('You already have a reservation: "[_1]", assigned by your instructor.',
+ $description1).'
'.
+ '
'.&mt('Your instructor must unassign it before you can make a new reservation.').
+ '
');
+ } elsif ($slot_name ne $env{'form.slotname'}) {
$r->print(<
@@ -1114,14 +1120,25 @@ sub allowed_slot {
# 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,12 +1495,13 @@ sub show_table {
'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',
'scheduled' => 'Scheduled Students',
- 'proctor' => 'List of proctors');
+ 'proctor' => 'List of proctors',
+ 'iptied' => 'Unique IP each student',);
if ($crstype eq 'Community') {
$show_fields{'startreserve'} = &mt('Time members can start reserving');
$show_fields{'endreserve'} = &mt('Time members can no longer reserve');
@@ -1491,7 +1509,7 @@ sub show_table {
}
my @show_order=('name','description','type','starttime','endtime',
'startreserve','endreserve','reservationmsg','secret','space',
- 'ip','symb','allowedsections','allowedusers','uniqueperiod',
+ 'ip','iptied','symb','allowedsections','allowedusers','uniqueperiod',
'scheduled','proctor');
my @show =
(exists($env{'form.show'})) ? &Apache::loncommon::get_env_multiple('form.show')
@@ -1590,15 +1608,16 @@ sub show_table {
$r->print('');
$r->print('');
my $linkstart=''.$show_fields{$which}.'');
+ $tableheader .= '
'.$linkstart.$which.'">'.$show_fields{$which}.'
';
}
}
- $r->print(&Apache::loncommon::end_data_table_header_row());
+ $tableheader .= &Apache::loncommon::end_data_table_header_row();
+ my $shownheader = 0;
my %name_cache;
my $slotsort = sub {
@@ -1693,13 +1712,21 @@ sub show_table {
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=''.$title.'';
+ 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,''.$title.'');
+ }
}
my $allowedsections;
@@ -1747,30 +1774,39 @@ sub show_table {
delete => 'Delete',
slotlog => 'History',
);
- my $edit=(<<"EDITLINK");
+ my ($edit,$delete,$showlog,$remove_all);
+ if ($mgr) {
+ $edit=(<<"EDITLINK");
$lt{'edit'}
EDITLINK
- my $delete=(<<"DELETELINK");
+ $delete=(<<"DELETELINK");
$lt{'delete'}
DELETELINK
- my $showlog=(<<"LOGLINK");
+ $remove_all=&remove_link($slot,'remove all').' ';
+
+ if ($ids eq '') {
+ undef($remove_all);
+ } else {
+ undef($delete);
+ }
+ }
+
+ $showlog=(<<"LOGLINK");
$lt{'slotlog'}
LOGLINK
- my $remove_all=&remove_link($slot,'remove all').' ';
-
- if ($ids eq '') {
- undef($remove_all);
- } else {
- undef($delete);
- }
if ($slots{$slot}{'type'} ne 'schedulable_student') {
undef($showlog);
undef($remove_all);
}
+ unless ($shownheader) {
+ $r->print($tableheader);
+ $shownheader = 1;
+ }
+
my $row_start=&Apache::loncommon::start_data_table_row();
my $row_end=&Apache::loncommon::end_data_table_row();
$r->print($row_start.
@@ -1815,8 +1851,18 @@ LOGLINK
if (exists($show{'ip'})) {
$colspan++;$r->print("
$slots{$slot}{'ip'}
\n");
}
+ if (exists($show{'iptied'})) {
+ $colspan++;
+ if ($slots{$slot}{'iptied'} eq 'yes') {
+ $r->print('