--- loncom/interface/lonnavmaps.pm 2023/04/04 23:15:48 1.563 +++ loncom/interface/lonnavmaps.pm 2025/02/03 19:07:54 1.571 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Navigate Maps Handler # -# $Id: lonnavmaps.pm,v 1.563 2023/04/04 23:15:48 raeburn Exp $ +# $Id: lonnavmaps.pm,v 1.571 2025/02/03 19:07:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -48,7 +48,8 @@ described at http://www.lon-capa.org. =head1 OVERVIEW -X When a user enters a course, LON-CAPA examines the +X +When a user enters a course, LON-CAPA examines the course structure and caches it in what is often referred to as the "big hash" X. You can see it if you are logged into LON-CAPA, in a course, by going to /adm/test. The content of @@ -1120,7 +1121,7 @@ sub render_resource { } # Decide what to display - $result .= "$newBranchText$linkopen$icon$linkclose"; + $result .= "$newBranchText$linkopen$icon"; my $curMarkerBegin = ''; my $curMarkerEnd = ''; @@ -1160,7 +1161,7 @@ sub render_resource { $linkopen = ""; } } - $result .= "$curMarkerBegin$linkopen$title$partLabel$linkclose$curMarkerEnd$editmapLink$nonLinkedText"; + $result .= "$curMarkerBegin$title$partLabel$curMarkerEnd$linkclose$editmapLink$nonLinkedText"; return $result; } @@ -1572,10 +1573,15 @@ sub render { my $curRes; my $foundJump = 0; my $counter = 0; - + while (($curRes = $mapIterator->next()) && !$foundJump) { if (ref($curRes)) { $counter++; } - + # Speed up display after course initialization + # when $jump is empty. Note: we still need + # $counter to be 1 in that case if there is at + # least one resource. + last if (($jump eq '') && ($counter)); + if (ref($curRes) && $jump eq $curRes->symb()) { # This is why we have to use the main iterator instead of the @@ -1594,27 +1600,19 @@ sub render { my $printKey = $args->{'printKey'}; my $printCloseAll = $args->{'printCloseAll'}; if (!defined($printCloseAll)) { $printCloseAll = 1; } - + # Print key? if ($printKey) { - $result .= ''; - $result.=''; - my $location=&Apache::loncommon::lonhttpdurl("/adm/lonMisc"); - if ($navmap->{LAST_CHECK}) { - $result .= - ' '.&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)').'

'. - '

  '. - ' '.&mt('Discussions').''. - '   '.&mt('New message (click to open)'). - '
'; + my $location = &Apache::loncommon::lonhttpdurl("/adm/lonMisc"); + $result .= '
'."\n". + ''.&mt('Key').':'. + '  '. + ' '.&mt('Unread Discussion'). + '  '. + ' '. + &mt('New message (click to open)'). + '
'. + '
'."\n"; } if ($printCloseAll && !$args->{'resource_no_folder_link'}) { @@ -1641,17 +1639,19 @@ sub render { # Check for any unread discussions in all resources. if (($args->{'caller'} eq 'navmapsdisplay') && (!$args->{'notools'})) { + my $markread = 'Mark all posts read'; &add_linkitem($args->{'linkitems'},'clearbubbles', 'document.clearbubbles.submit()', - 'Mark all posts read'); + $markread); my $time=time; + my $submit = &mt($markread); my $querystr = &HTML::Entities::encode($ENV{'QUERY_STRING'},'<>&"'); $result .= (< +
'. - &mt('Content Editor').''; + $result .= ''; } } if ($args->{'sort_html'}) { - $result .= '   '. - ''.$args->{'sort_html'}.''; + $result .= '
   '. + $args->{'sort_html'}.'
'; } } if ($result) { - $result = "$result
"; + $result = '
'.$result.'
'."\n". + '
'."\n"; } return $result; } @@ -2286,10 +2292,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. @@ -2331,7 +2344,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; @@ -2342,15 +2355,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; @@ -2857,7 +2872,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) { @@ -3046,7 +3061,7 @@ sub parmval_real { } sub recurseup_maps { - my ($self,$mapname) = @_; + my ($self,$mapname,$getsymb) = @_; my @recurseup; if ($mapname) { my $res = $self->getResourceByUrl($mapname); @@ -3054,7 +3069,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); + } } } } @@ -3182,7 +3201,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) { @@ -3383,11 +3402,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'}); @@ -5245,7 +5264,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 {