--- loncom/interface/lonnavmaps.pm 2023/07/06 20:32:17 1.509.2.14.2.9 +++ loncom/interface/lonnavmaps.pm 2025/05/28 13:42:14 1.509.2.14.2.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.509.2.14.2.9 2023/07/06 20:32:17 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.509.2.14.2.12 2025/05/28 13:42:14 raeburn Exp $ # # Copyright Michigan State University Board of Trustees @@ -1366,13 +1366,17 @@ sub cmp_title { sub render { my $args = shift; &Apache::loncommon::get_unprocessed_cgi($ENV{QUERY_STRING}); - my $result = ''; # Configure the renderer. my $cols = $args->{'cols'}; if (!defined($cols)) { # no columns, no nav maps. return ''; } + my $legend = ''; + my $tools = ''; + my $result = ''; + my $tools_printed = 0; + my $tablestarted = 0; my $navmap; if (defined($args->{'navmap'})) { $navmap = $args->{'navmap'}; @@ -1584,24 +1588,24 @@ sub render { # Print key? if ($printKey) { - $result .= ''; - $result.=''; + $legend = '
Key:  
'; + $legend .= ''; my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); if ($navmap->{LAST_CHECK}) { - $result .= + $legend .= ' '.&mt('New discussion since').' '. strftime("%A, %b %e at %I:%M %P", localtime($navmap->{LAST_CHECK})). ''; } else { - $result .= ''; } - $result .= '
Key:    '. ' '.&mt('New message (click to open)').'

'. '

  '. + $legend .= '  '. ' '.&mt('Discussions').''. '   '.&mt('New message (click to open)'). '
'; + $legend .= ''; } if ($printCloseAll && !$args->{'resource_no_folder_link'}) { @@ -1621,9 +1625,9 @@ sub render { "location.href='$link'",$text); } } else { - $result.= ''.&mt($text).''; + $tools = ''.&mt($text).''; } - $result .= "\n"; + $tools .= "\n"; } # Check for any unread discussions in all resources. @@ -1633,7 +1637,7 @@ sub render { 'Mark all posts read'); my $time=time; my $querystr = &HTML::Entities::encode($ENV{'QUERY_STRING'},'<>&"'); - $result .= (< @@ -1650,13 +1654,13 @@ END } if ($totdisc > 0) { $haveDisc =~ s/:$//; - $result .= (< END } } - $result.=''; + $tools .= ''; } if (($args->{'caller'} eq 'navmapsdisplay') && ($env{'request.course.id'})) { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -1678,23 +1682,15 @@ END } if ($args->{'caller'} eq 'navmapsdisplay') { - $result .= &show_linkitems_toolbar($args,$condition); + $tools .= &show_linkitems_toolbar($args,$condition); } elsif ($args->{'sort_html'}) { - $result.=$args->{'sort_html'}; + $tools .= $args->{'sort_html'}; } - #$result .= "
\n"; - if ($r) { - $r->print($result); - $r->rflush(); - $result = ""; - } + #$tools .= "
\n"; # End parameter setting - - $result .= "
\n"; # Data - $result.=&Apache::loncommon::start_data_table("LC_tableOfContent"); my $res = "Apache::lonnavmaps::resource"; my %condenseStatuses = @@ -1706,7 +1702,8 @@ END $args->{'counter'} = 0; # counts the rows $args->{'indentLevel'} = 0; $args->{'isNewBranch'} = 0; - $args->{'condensed'} = 0; + $args->{'condensed'} = 0; + $args->{'deeplinknolist'} = 0; my $location = &Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif"); $args->{'indentString'} = setDefault($args->{'indentString'}, ""); @@ -1882,6 +1879,9 @@ END # If this has been filtered out, continue on if (!(&$filterFunc($curRes))) { + if (!$userCanSeeHidden && !$curRes->randomout && $curRes->deeplinkout) { + $args->{'deeplinknolist'} ++; + } $args->{'isNewBranch'} = 0; # Don't falsely remember this next; } @@ -1906,6 +1906,7 @@ END if ($userCanSeeHidden) { $args->{'mapHiddenDeepLink'} = 1; } else { + $args->{'deeplinknolist'} ++; next; } } else { @@ -1915,6 +1916,7 @@ END if ($userCanSeeHidden) { $args->{'mapUnlisted'} = 1; } else { + $args->{'deeplinknolist'} ++; next; } } @@ -1928,6 +1930,10 @@ END } $args->{'counter'}++; + unless ($tablestarted) { + $result .= "
\n".&Apache::loncommon::start_data_table("LC_tableOfContent"); + $tablestarted = 1; + } # Does it have multiple parts? $args->{'multipart'} = 0; @@ -2078,6 +2084,12 @@ END } if ($r && $rownum % 20 == 0) { + unless ($tools_printed) { + $r->print($legend.$tools); + $legend = ""; + $tools = ""; + $tools_printed = 1; + } $r->print($result); $result = ""; $r->rflush(); @@ -2093,8 +2105,10 @@ END } } - $result.=&Apache::loncommon::end_data_table(); - + if ($tablestarted) { + $result.=&Apache::loncommon::end_data_table(); + } + # Print out the part that jumps to #curloc if it exists # delay needed because the browser is processing the jump before # it finishes rendering, so it goes to the wrong place! @@ -2111,12 +2125,23 @@ if (location.href.indexOf('#curloc')==-1 } if ($r) { + unless ($tools_printed) { + if (($args->{'counter'}) || ($userCanSeeHidden) || + (($args->{'caller'} eq 'navmapsdisplay') && + ($env{'form.showOnlyHomework'} || + $ENV{QUERY_STRING} =~ /^jumpToFirstHomework/))) { + $r->print($legend.$tools); + } + $legend = ""; + $tools = ""; + $tools_printed = 1; + } $r->print($result); $result = ""; $r->rflush(); } - return $result; + return $legend.$tools.$result; } sub add_linkitem { @@ -2274,10 +2299,17 @@ sub new { $self->{USERNAME} = shift || $env{'user.name'}; $self->{DOMAIN} = shift || $env{'user.domain'}; + $self->{SECTION} = shift; $self->{CODE} = shift; - $self->{NOHIDE} = shift; + $self->{NOHIDE} = shift; + if (($self->{SECTION} eq '') && ($env{'request.course.sec'} ne '')) { + if (($self->{USERNAME} eq $env{'user.name'}) && + ($self->{USERNAME} eq $env{'user.domain'})) { + $self->{SECTION} = $env{'request.course.sec'}; + } + } # Resource cache stores navmap resources as we reference them. We generate # them on-demand so we don't pay for creating resources unless we use them. @@ -2319,7 +2351,7 @@ sub new { $self->{PARM_HASH} = \%parmhash; $self->{PARM_CACHE} = {}; } else { - $self->change_user($self->{USERNAME}, $self->{DOMAIN}, $self->{CODE}, $self->{NOHIDE}); + $self->change_user($self->{USERNAME}, $self->{DOMAIN}, $self->{SECTION}, $self->{CODE}, $self->{NOHIDE}); } return $self; @@ -2330,15 +2362,17 @@ sub new { # username/domain associated with a navmap (e.g. to navigate for someone # else besides the current user...if sufficiently privileged. # Parameters: -# user - New user. -# domain- Domain the user belongs to. -# code - Anonymous CODE in use. +# user - New user. +# domain - Domain to which the user belongs. +# section - Section to which the user belongs. +# code - Anonymous CODE in use. # Implicit inputs: # sub change_user { my $self = shift; $self->{USERNAME} = shift; $self->{DOMAIN} = shift; + $self->{SECTION} = shift; $self->{CODE} = shift; $self->{NOHIDE} = shift; @@ -2844,7 +2878,7 @@ sub parmval_real { $self->generate_course_user_opt(); my $cid=$env{'request.course.id'}; - my $csec=$env{'request.course.sec'}; + my $csec=$self->{SECTION}; my $cgroup=''; my @cgrps=split(/:/,$env{'request.course.groups'}); if (@cgrps > 0) { @@ -2957,7 +2991,7 @@ sub parmval_real { } sub recurseup_maps { - my ($self,$mapname) = @_; + my ($self,$mapname,$getsymb) = @_; my @recurseup; if ($mapname) { my $res = $self->getResourceByUrl($mapname); @@ -2965,7 +2999,11 @@ sub recurseup_maps { my @pcs = split(/,/,$res->map_hierarchy()); shift(@pcs); if (@pcs) { - @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs); + if ($getsymb) { + @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->symb()); } reverse(@pcs); + } else { + @recurseup = map { &Apache::lonnet::declutter($self->getByMapPc($_)->src()); } reverse(@pcs); + } } } } @@ -3093,7 +3131,7 @@ sub get_mapparam { # Get the course id and section if there is one. my $cid=$env{'request.course.id'}; - my $csec=$env{'request.course.sec'}; + my $csec=$self->{SECTION}; my $cgroup=''; my @cgrps=split(/:/,$env{'request.course.groups'}); if (@cgrps > 0) { @@ -3262,11 +3300,11 @@ sub getcourseparam { my $uname = $self->{USERNAME}; my $udom = $self->{DOMAIN}; + my $csec = $self->{SECTION}; - # Course, section, group ids come from the env: + # Course and group ids come from the env: my $cid = $env{'request.course.id'}; - my $csec = $env{'request.course.sec'}; my $cgroup = ''; # Assume no group my @cgroups = split(/:/, $env{'request.course.groups'}); @@ -5128,7 +5166,7 @@ sub weight { my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight', $self->{SYMB}, $self->{DOMAIN}, $self->{USERNAME}, - $env{'request.course.sec'}); + $self->{SECTION}); return $weight; } sub part_display {