--- loncom/interface/lonnavmaps.pm 2022/06/11 14:51:49 1.558 +++ loncom/interface/lonnavmaps.pm 2022/06/27 20:35:51 1.560 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.558 2022/06/11 14:51:49 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.560 2022/06/27 20:35:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1423,6 +1423,37 @@ sub render { my $condition = 0; if ($env{'form.condition'}) { $condition = 1; + } elsif (($env{'request.deeplink.login'}) && ($env{'request.course.id'}) && (!$userCanSeeHidden)) { + if (!defined($navmap)) { + $navmap = Apache::lonnavmaps::navmap->new(); + } + if (defined($navmap)) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $symb = &Apache::loncommon::symb_from_tinyurl($env{'request.deeplink.login'},$cnum,$cdom); + if ($symb) { + my $deeplink; + my $res = $navmap->getBySymb($symb); + if ($res->is_map()) { + my $mapname = &Apache::lonnet::declutter($res->src()); + $mapname = &Apache::lonnet::deversion($mapname); + $deeplink = $navmap->get_mapparam(undef,$mapname,"0.deeplink"); + } else { + $deeplink = $res->deeplink(); + } + if ($deeplink ne '') { + if ((split(/,/,$deeplink))[1] eq 'hide') { + if ($res->is_map()) { + map { $filterHash->{$_} = 1 if $_ } split(/,/,$res->map_hierarchy()); + } else { + my $mapurl = (&Apache::lonnet::decode_symb($symb))[0]; + my $map = $navmap->getResourceByUrl($mapurl); + map { $filterHash->{$_} = 1 if $_ } split(/,/,$map->map_hierarchy()); + } + } + } + } + } } if (!$env{'form.folderManip'} && !defined($args->{'iterator'}) && !$args->{'nocurrloc'}) { @@ -1693,11 +1724,31 @@ END # mark as hidden for users who have $userCanSeeHidden. # Use DFS for speed, since structure actually doesn't matter, # except what map has what resources. + # + # To ensure the "Selected Resources from selected folder in course" + # printout generation option will work in sessions launched via a + # deep link, the value of $args->{'filterFunc'} included in the + # call to lonnavmaps::render() is omitted from the filter function + # used with the DFS Iterator when $args->{'caller'} is 'printout'. + # + # As a result $sequence->{DATA}->{HAS_VISIBLE_CHILDREN} can be + # set to 1 for folder(s) which include resources only accessible + # for sessions launched via a deep link, when the current session + # is of that type. my $dfsit = Apache::lonnavmaps::DFSiterator->new($navmap, $it->{FIRST_RESOURCE}, $it->{FINISH_RESOURCE}, {}, undef, 1); + my $dfsFilterFunc; + if ($args->{'caller'} eq 'printout') { + $dfsFilterFunc = sub { my $res = shift; return !$res->randomout() && + ($res->deeplink($args->{'caller'}) ne 'absent') && + ($res->deeplink($args->{'caller'}) ne 'grades') && + !$res->deeplinkout();}; + } else { + $dfsFilterFunc = $filterFunc; + } my $depth = 0; $dfsit->next(); my $curRes = $dfsit->next(); @@ -1716,8 +1767,9 @@ END } elsif ($curRes->src()) { # Not a sequence: if it's filtered, ignore it, otherwise # rise up the stack and mark the sequences as having children - if (&$filterFunc($curRes)) { + if (&$dfsFilterFunc($curRes)) { for my $sequence (@{$dfsit->getStack()}) { + next unless ($sequence->is_map()); $sequence->{DATA}->{HAS_VISIBLE_CHILDREN} = 1; } }