--- loncom/interface/lonnavmaps.pm 2022/06/23 19:31:39 1.559 +++ loncom/interface/lonnavmaps.pm 2022/10/04 20:39:59 1.562 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.559 2022/06/23 19:31:39 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.562 2022/10/04 20:39:59 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1020,8 +1020,12 @@ sub render_resource { if ($it->{CONDITION}) { $nowOpen = !$nowOpen; } - - my $folderType = $resource->is_sequence() ? 'folder' : 'page'; + my $folderType; + if (&advancedUser() && $resource->is_missing_map()) { + $folderType = 'none'; + } else { + $folderType = $resource->is_sequence() ? 'folder' : 'page'; + } my $title=$resource->title; $title=~s/\"/\&qout;/g; if (!$params->{'resource_no_folder_link'}) { @@ -1724,11 +1728,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(); @@ -1747,8 +1771,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; } } @@ -3057,8 +3082,12 @@ sub recursed_crumbs { my $pc = $map->map_pc(); next if ((!$pc) || ($pc == 1)); push(@links,$map); - push(@revmapinfo,{'href' => $env{'request.use_absolute'}.$map->link().'?navmap=1','text' => $map->title(),'no_mt' => 1,}); - $totallength += length($map->title()); + my $text = $map->title(); + if ($text eq '') { + $text = '...'; + } + push(@revmapinfo,{'href' => $env{'request.use_absolute'}.$map->link().'?navmap=1','text' => $text,'no_mt' => 1,}); + $totallength += length($text); } my $numlinks = scalar(@links); if ($numlinks) { @@ -3070,7 +3099,11 @@ sub recursed_crumbs { } @revmapinfo = (); foreach my $map (@links) { - my $showntitle = &truncate_crumb_text($map->title(),$avg); + my $title = $map->title(); + if ($title eq '') { + $title = '...'; + } + my $showntitle = &truncate_crumb_text($title,$avg); if ($showntitle ne '') { push(@revmapinfo,{'href' => $env{'request.use_absolute'}.$map->link().'?navmap=1','text' => $showntitle,'no_mt' => 1,}); } @@ -4776,6 +4809,11 @@ sub is_sequence { return $self->navHash("is_map_", 1) && $self->navHash("map_type_" . $self->map_pc()) eq 'sequence'; } +sub is_missing_map { + my $self=shift; + return $self->navHash("is_map_", 1) && + $self->navHash("map_type_" . $self->map_pc()) eq 'none'; +} sub is_survey { my $self = shift(); my $part = shift();