--- loncom/interface/slotrequest.pm 2016/08/06 21:32:55 1.125.2.1 +++ loncom/interface/slotrequest.pm 2015/09/23 23:04:53 1.126 @@ -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.125.2.1 2016/08/06 21:32:55 raeburn Exp $ +# $Id: slotrequest.pm,v 1.126 2015/09/23 23:04:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1000,10 +1000,21 @@ sub allowed_slot { return 0 if (!$userallowed); # not allowed for this resource - if (defined($slot->{'symb'}) - && $slot->{'symb'} ne $symb) { - unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) { - return 0; + 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)) { + $exclude = 0; + } + } elsif ($slot->{'symb'} eq $symb) { + $exclude = 0; + } + if ($exclude) { + unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) { + return 0; + } } } @@ -1349,7 +1360,7 @@ sub show_table { 'secret' => 'Secret Word', 'space' => '# of students/max', 'ip' => 'IP or DNS restrictions', - 'symb' => 'Resource slot is restricted to.', + 'symb' => 'Resource/Map slot is restricted to.', 'allowedsections' => 'Sections slot is restricted to.', 'allowedusers' => 'Users slot is restricted to.', 'uniqueperiod' => 'Period of time slot is unique', @@ -2672,7 +2683,7 @@ sub csvupload_fields { ['proctor','List of proctor ids'], ['description','Slot Description'], ['maxspace','Maximum number of reservations'], - ['symb','Resource Restriction'], + ['symb','Resource/Map Restriction'], ['uniqueperiod','Date range of slot exclusion'], ['secret','Secret word proctor uses to validate'], ['allowedsections','Sections slot is restricted to'], @@ -2740,12 +2751,8 @@ sub csv_upload_assign { } if ($entries{$fields{'startreserve'}}) { - my $date = &UnixDate($entries{$fields{'startreserve'}},"%s"); - if ($date eq '') { - push(@errors,"$name -- No reservation start time set for slot -- value provided had invalid format"); - } else { - $slot{'startreserve'} = $date; - } + $slot{'startreserve'}= + &UnixDate($entries{$fields{'startreserve'}},"%s"); } if (defined($slot{'startreserve'}) && $slot{'startreserve'} > $slot{'starttime'}) { @@ -2754,12 +2761,8 @@ sub csv_upload_assign { } if ($entries{$fields{'endreserve'}}) { - my $date = &UnixDate($entries{$fields{'endreserve'}},"%s"); - if ($date eq '') { - push(@errors,"$name -- No reservation end time set for slot -- value provided had invalid format"); - } else { - $slot{'endreserve'} = $date; - } + $slot{'endreserve'}= + &UnixDate($entries{$fields{'endreserve'}},"%s"); } if (defined($slot{'endreserve'}) && $slot{'endreserve'} > $slot{'starttime'}) { @@ -2819,14 +2822,12 @@ sub csv_upload_assign { } } if ($entries{$fields{'uniqueperiod'}}) { - my ($start,$end)= map { &UnixDate($_,"%s"); } split(',',$entries{$fields{'uniqueperiod'}}); - if (($start ne '') && ($end ne '')) { - $slot{'uniqueperiod'}=[$start,$end]; - } else { - push(@errors,"$name -- Slot's unique period ignored -- one or both of the comma separated values for start and end had an invalid format"); - } + my ($start,$end)=split(',',$entries{$fields{'uniqueperiod'}}); + my @times=(&UnixDate($start,"%s"), + &UnixDate($end,"%s")); + $slot{'uniqueperiod'}=\@times; } - if (ref($slot{'uniqueperiod'}) eq 'ARRAY' + if (defined($slot{'uniqueperiod'}) && $slot{'uniqueperiod'}[0] > $slot{'uniqueperiod'}[1]) { push(@errors,"$name not created -- Slot's unique period start time is later than the unique period's end time."); next;