--- loncom/interface/slotrequest.pm 2021/01/18 21:58:57 1.125.2.10 +++ loncom/interface/slotrequest.pm 2023/07/08 17:21:33 1.125.2.10.2.1 @@ -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 2021/01/18 21:58:57 raeburn Exp $ +# $Id: slotrequest.pm,v 1.125.2.10.2.1 2023/07/08 17:21:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -56,7 +56,7 @@ sub fail { } sub start_page { - my ($r,$title,$brcrum,$bread_crumbs_component,$js)=@_; + my ($r,$title,$brcrum,$bread_crumbs_component,$js,$mgr)=@_; my $args; if (ref($brcrum) eq 'ARRAY') { $args = {bread_crumbs => $brcrum}; @@ -74,6 +74,31 @@ sub start_page { $args = { 'add_entries' => \%loaditems }; } } + unless (($env{'form.context'} eq 'usermanage') || (($mgr eq 'F') && + (($env{'form.command'} eq 'release') || + ($env{'form.command'} eq 'remove_registration')))) { + if ($env{'form.symb'}) { + my $symb=&unescape($env{'form.symb'}); + my ($mapurl,$id,$resurl) = &Apache::lonnet::decode_symb($symb); + if ($resurl =~ /ext\.tool$/) { + my $target; + my ($marker,$exttool) = (split(m{/},$resurl))[3,4]; + $marker=~s/\D//g; + if (($marker) && ($exttool) && ($env{'request.course.id'})) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my ($idx,$crstool,$is_tool,%toolhash,%toolsettings); + if ($resurl eq "adm/$cdom/$cnum/$marker/$exttool") { + my %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); + $target = $toolsettings{'target'}; + } + } + if ($target eq 'iframe') { + $args->{'only_body'} = 1; + } + } + } + } $r->print(&Apache::loncommon::start_page($title,$js,$args)); } @@ -371,7 +396,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(); @@ -869,7 +894,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); $parm_symb = $a_resource->symb(); } } else { @@ -965,7 +990,7 @@ sub update_selectable { 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_for_parm = $a_resource->symb(); } # get parameter string, check for existence, rebuild string with the slot @@ -1041,15 +1066,32 @@ sub delete_slot { sub return_link { my ($r) = @_; + my $target = &return_target(); if (($env{'form.command'} eq 'manageresv') || ($env{'form.context'} eq 'usermanage')) { - $r->print('

'. + $r->print('

'. &mt('Return to reservations')); } else { - $r->print('

'. + $r->print('

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

'); } } +sub return_target { + my ($target,$ltitarget,$deeplinktarget); + if ($env{'request.lti.login'}) { + $ltitarget = $env{'request.lti.target'}; + } + if ($env{'request.deeplink.login'}) { + $deeplinktarget = $env{'request.deeplink.target'}; + } + if (($ltitarget eq 'iframe') || ($deeplinktarget eq '_self')) { + $target = '_self'; + } else { + $target = '_top'; + } + return $target; +} + sub get_slot { my ($r,$symb,$conflictable_slot,$inhibit_return_link)=@_; @@ -1287,7 +1329,8 @@ sub show_choices { if (!@{$available}) { $output = ''.&mt('No available times.').''; if ($env{'form.command'} ne 'manageresv') { - $output .= ' '. + my $target = &return_target(); + $output .= ' '. &mt('Return to last resource').''; } $r->print($output); @@ -2028,15 +2071,15 @@ sub manage_reservations { my $symb = $resource->symb(); my $ressymb = $symb; $contents{$lastcontainer} ++; - next if (!$resource->is_problem() && !$resource->is_sequence() && - !$resource->is_page()); + next if (!$resource->is_problem() && && !$resource->is_tool() && + !$resource->is_sequence() && !$resource->is_page()); $count ++; if (($resource->is_sequence()) || ($resource->is_page())) { $lastcontainer = $count; $container{$lastcontainer} = $resource; $container_title{$lastcontainer} = $resource->compTitle(); } - if ($resource->is_problem()) { + if ($resource->is_problem() || $resource->is_tool()) { my ($useslots) = $resource->slot_control(); next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i)); my ($msg,$get_choices,$slotdescription); @@ -3224,7 +3267,7 @@ sub handler { if (($env{'form.requestattempt'}) || ($env{'form.command'} eq 'manageresv')) { $js = &reservation_js(\%slots,$consumed_uniqueperiods,$available,$got_slots,$symb); } - &start_page($r,$title,$brcrum,$bread_crumbs_component,$js); + &start_page($r,$title,$brcrum,$bread_crumbs_component,$js,$mgr); if ($env{'form.command'} eq 'manageresv') { $allavailable = $available;