--- loncom/interface/slotrequest.pm 2023/07/08 17:21:33 1.125.2.10.2.1 +++ loncom/interface/slotrequest.pm 2023/07/12 15:48:23 1.147 @@ -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.10.2.1 2023/07/08 17:21:33 raeburn Exp $ +# $Id: slotrequest.pm,v 1.147 2023/07/12 15:48:23 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,7 +50,7 @@ sub fail { } else { $r->print('

'.&mt('Failed.').'

'); } - + &return_link($r); &end_page($r); } @@ -60,8 +60,8 @@ sub start_page { my $args; if (ref($brcrum) eq 'ARRAY') { $args = {bread_crumbs => $brcrum}; - if ($bread_crumbs_component) { - $args->{bread_crumbs_component} = $bread_crumbs_component; + if ($bread_crumbs_component) { + $args->{bread_crumbs_component} = $bread_crumbs_component; } } if (($env{'form.requestattempt'}) || ($env{'form.command'} eq 'manageresv')) { @@ -284,7 +284,104 @@ function uncheckSlotRadio() { } if (slotpicks.length) { for (var i=0; i= lastresnum)) { + for (var i=lastresnum; i $last) { $last=$num; } } - + my $wanted=$last+1; &Apache::lonxml::debug("wanted $wanted
"); if (scalar(@ids) >= $max) { # full up return undef; } - + my %reservation=('name' => $env{'user.name'}.':'.$env{'user.domain'}, 'timestamp' => time, 'symb' => $symb_for_db); @@ -607,7 +704,7 @@ sub remove_registration { sub remove_registration_user { my ($r) = @_; - + my $slot_name = $env{'form.slotname'}; my $name = &Apache::loncommon::plainname($env{'form.uname'}, @@ -617,7 +714,7 @@ sub remove_registration_user { my $msg = &mt('Remove [_1] from slot [_2] for [_3]', $name,$slot_name,$title); - + &remove_registration_confirmation($r,$msg,['uname','udom','slotname', 'entry','symb','context']); } @@ -653,14 +750,14 @@ END_CONFIRM sub release_all_slot { my ($r,$mgr)=@_; - + my $slot_name = $env{'form.slotname'}; my ($cnum,$cdom)=&get_course(); my %consumed=&Apache::lonnet::dump('slot_reservations',$cdom,$cnum, "^$slot_name\0"); - + $r->print('

'.&mt('Releasing reservations').'

'); foreach my $entry (sort { $consumed{$a}{'name'} cmp @@ -704,7 +801,7 @@ sub release_slot { } else { $r->print("

$msg

"); } - + if ($mgr eq 'F') { $r->print('

'. &mt('Return to slot list').'

'); @@ -1069,7 +1166,7 @@ sub return_link { my $target = &return_target(); if (($env{'form.command'} eq 'manageresv') || ($env{'form.context'} eq 'usermanage')) { $r->print('

'. - &mt('Return to reservations')); + &mt('Return to reservations').'

'); } else { $r->print('

'. &mt('Return to last resource').'

'); @@ -1243,7 +1340,7 @@ sub allowed_slot { if (($slot->{'endreserve'}) && ($slot->{'endreserve'} < time)) { return 0; - } + } &Apache::lonxml::debug("$slot_name reserve good"); my $userallowed=0; @@ -1288,10 +1385,32 @@ 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 @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; + } + } + if ($exclude) { + unless ((ref($toskip) eq 'HASH') && ($toskip->{'symb'})) { + return 0; + } } } @@ -1320,7 +1439,7 @@ sub get_description { } sub show_choices { - my ($r,$symb,$formname,$num,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; + my ($symb,$formname,$num,$class,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; my $output; &Apache::lonxml::debug("Checking Slots"); if (!ref($available) eq 'ARRAY') { @@ -1333,8 +1452,11 @@ sub show_choices { $output .= ' '. &mt('Return to last resource').''; } - $r->print($output); - return; + if ($class) { + return '
'.$output.'
'; + } else { + return $output; + } } if (@{$available} > 1) { my $numavailable = scalar(@{$available}); @@ -1365,7 +1487,7 @@ sub show_choices { ); foreach my $option (@options) { my $onclick = "toggleSlotDisplay(this.form,'$num');"; - if (($option eq 'show') && ($env{'form.command'} eq 'manageresv')) { + if (($option eq 'show') && ($env{'form.command'} eq 'manageresv')) { $onclick .= "currSlotDisplay$num(this.form,'$num');"; } $output .= '