--- loncom/interface/lonnavmaps.pm 2018/04/14 17:52:43 1.542 +++ loncom/interface/lonnavmaps.pm 2018/11/13 03:59:00 1.543 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.542 2018/04/14 17:52:43 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.543 2018/11/13 03:59:00 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -963,32 +963,32 @@ sub render_resource { $newBranchText = ".mt('Branch')."; } - # links to open and close the folder - my $whitespace = $location.'/whitespace_21.gif'; - my $linkopen = ""; - my $nomodal; - if (($params->{'modalLink'}) && (!$resource->is_sequence())) { - if ($link =~m{^(?:|/adm/wrapper)/ext/([^#]+)}) { - my $exturl = $1; - if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { + my ($nomodal,$linkopen,$linkclose); + unless ($resource->is_map() || $params->{'resource_nolink'}) { + $linkopen = ""; + $linkclose = ""; + if (($params->{'modalLink'}) && (!$resource->is_sequence())) { + if ($link =~m{^(?:|/adm/wrapper)/ext/([^#]+)}) { + my $exturl = $1; + if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) { + $nomodal = 1; + } + } elsif (($link eq "/public/$LONCAPA::match_domain/$LONCAPA::match_courseid/syllabus") && + ($env{'request.course.id'}) && ($ENV{'SERVER_PORT'} == 443) && + ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { $nomodal = 1; } - } elsif (($link eq "/public/$LONCAPA::match_domain/$LONCAPA::match_courseid/syllabus") && - ($env{'request.course.id'}) && ($ENV{'SERVER_PORT'} == 443) && - ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) { - $nomodal = 1; - } - my $esclink = &js_escape($link); - if ($nomodal) { - $linkopen .= ""; + my $esclink = &js_escape($link); + if ($nomodal) { + $linkopen .= ""; + } else { + $linkopen .= ""; + } } else { - $linkopen .= ""; + $linkopen .= ""; } - } else { - $linkopen .= ""; } - my $linkclose = ""; # Default icon: unknown page my $icon = ""; @@ -1036,13 +1036,14 @@ sub render_resource { '&jump=' . &escape($resource->symb()) . "&folderManip=1\">"; - + $linkclose = ''; } else { # Don't allow users to manipulate folder $icon = "navmap.$folderType." . ($nowOpen ? 'closed' : 'open') . '.gif'; $icon = ""."\"".($nowOpen"; if ($params->{'caller'} eq 'sequence') { $linkopen = ""; + $linkclose = ''; } else { $linkopen = ""; $linkclose = ""; @@ -1061,10 +1062,15 @@ sub render_resource { } if ($params->{'mapHidden'} || $resource->randomout()) { $nonLinkedText .= ' ('.&mt('hidden').') '; + } elsif ($params->{'mapUnlisted'}) { + $nonLinkedText .= ' ('.&mt('unlisted').') '; } } else { if ($resource->randomout()) { $nonLinkedText .= ' ('.&mt('hidden').') '; + } elsif (($resource->deeplink($params->{caller}) eq 'absent') || + ($resource->deeplink($params->{caller}) eq 'grades')) { + $nonLinkedText .= ' ('.&mt('unlisted').') '; } } if (!$resource->condval()) { @@ -1388,7 +1394,9 @@ sub render { # Without renaming the filterfunc, the server seems to go into # an infinite loop my $oldFilterFunc = $filterFunc; - $filterFunc = sub { my $res = shift; return !$res->randomout() && + $filterFunc = sub { my $res = shift; return !$res->randomout() && + ($res->deeplink($args->{'caller'}) ne 'absent') && + ($res->deeplink($args->{'caller'}) ne 'grades') && &$oldFilterFunc($res);}; } @@ -1805,6 +1813,7 @@ END # If this is an empty sequence and we're filtering them, continue on $args->{'mapHidden'} = 0; + $args->{'mapUnlisted'} = 0; if (($curRes->is_map()) && (!$curRes->{DATA}->{HAS_VISIBLE_CHILDREN})) { if ($args->{'suppressEmptySequences'}) { next; @@ -1817,6 +1826,15 @@ END } else { next; } + } else { + my $deeplink = $navmap->get_mapparam(undef,$mapname,"0.deeplink"); + if (($deeplink eq 'absent') || ($deeplink eq 'grades')) { + if ($userCanSeeHidden) { + $args->{'mapUnlisted'} = 1; + } else { + next; + } + } } } } @@ -1879,8 +1897,17 @@ END $args->{'condensed'} = 1; } } - } - + } + # If deep-link parameter is set (and is not set to full) suppress link + # unless priviliged user, or calling context is sequence, and parameter + # set at map level + if ((!$curRes->deeplink($args->{'caller'})) || + ($curRes->deeplink($args->{'caller'}) eq 'full') || &advancedUser()) { + $args->{'resource_nolink'} = 0; + } else { + $args->{'resource_nolink'} = 1; + } + # If the multipart problem was condensed, "forget" it was multipart if (scalar(@parts) == 1) { $args->{'multipart'} = 0; @@ -4692,7 +4719,6 @@ sub is_task { sub is_empty_sequence { my $self=shift; - my $src = $self->src(); return !$self->is_page() && $self->navHash("is_map_", 1) && !$self->navHash("map_type_" . $self->map_pc()); } @@ -5112,6 +5138,17 @@ sub slot_control { my $available = $self->parmval("available", $part); return ($useslots,$availablestudent,$available); } +sub deeplink { + my ($self,$caller) = @_; + if ($caller eq 'sequence') { + my @deeplink = $self->parmval("deeplink"); + if ($deeplink[1] eq 'resource') { + return $deeplink[0]; + } + } else { + return $self->parmval("deeplink"); + } +} # Multiple things need this sub getReturnHash {