[LON-CAPA-cvs] cvs: loncom /interface lonnavmaps.pm

raeburn raeburn at source.lon-capa.org
Tue May 27 19:31:50 EDT 2025


raeburn		Tue May 27 23:31:50 2025 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  - Don't show tools on Contents page if nothing is listea,d unless user is a
    privileged user or user had selected "show only uncompleted problems" or
    show first "due" problem. 
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.574 loncom/interface/lonnavmaps.pm:1.575
--- loncom/interface/lonnavmaps.pm:1.574	Mon May 26 19:55:09 2025
+++ loncom/interface/lonnavmaps.pm	Tue May 27 23:31:49 2025
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.574 2025/05/26 19:55:09 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.575 2025/05/27 23:31:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1380,13 +1380,17 @@
 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'};
@@ -1604,15 +1608,15 @@
     # Print key?
     if ($printKey) {
         my $location = &Apache::loncommon::lonhttpdurl("/adm/lonMisc");
-        $result .= '<div class="LC_navtools">'."\n".
-                   '<span class="LC_middle LC_right">'.&mt('Key').':</span>'.
-                   '<span class="LC_middle LC_center">  '.
-                   '<img src="'.$location.'/chat.gif" alt="" /> '.&mt('Unread Discussion').
-                   '  '.
-                   '<img src="'.$location.'/feedback.gif" alt="" /> '.
-                   &mt('New message (click to open)').
-                   '</span></div>'.
-                   '<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
+        $legend = '<div class="LC_navtools">'."\n".
+                  '<span class="LC_middle LC_right">'.&mt('Key').':</span>'.
+                  '<span class="LC_middle LC_center">  '.
+                  '<img src="'.$location.'/chat.gif" alt="" /> '.&mt('Unread Discussion').
+                  '  '.
+                  '<img src="'.$location.'/feedback.gif" alt="" /> '.
+                  &mt('New message (click to open)').
+                  '</span></div>'.
+                  '<div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
     }
 
     if ($printCloseAll && !$args->{'resource_no_folder_link'}) {
@@ -1632,9 +1636,9 @@
                               "location.href='$link'",$text);
             }
 	} else {
-	    $result.= '<a href="'.$link.'">'.&mt($text).'</a>';
+	    $tools = '<a href="'.$link.'">'.&mt($text).'</a>';
 	}
-        $result .= "\n";
+        $tools .= "\n";
     }
 
     # Check for any unread discussions in all resources.
@@ -1646,7 +1650,7 @@
 	my $time=time;
         my $submit = &mt($markread);
         my $querystr = &HTML::Entities::encode($ENV{'QUERY_STRING'},'<>&"');
-	$result .= (<<END);
+	$tools .= (<<END);
     <form name="clearbubbles" method="post" action="/adm/feedback" aria-hidden="true">
 	<input type="hidden" name="navurl" value="$querystr" />
 	<input type="hidden" name="navtime" value="$time" />
@@ -1663,12 +1667,12 @@
 	    }
 	    if ($totdisc > 0) {
 		$haveDisc =~ s/:$//;
-		$result .= (<<END);
+		$tools .= (<<END);
 	<input type="hidden" name="navmaps" value="$haveDisc" />
 END
             }
 	}
-	$result .= <<END;
+	$tools .= <<END;
         <input type="submit" value="$submit" class="LC_visually_hidden" tabindex="-1" disabled="disabled" />
     </form>
 END
@@ -1693,31 +1697,15 @@
     }
 
     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 .= "<br />\n";
-    if ($r) {
-        $r->print($result);
-        $r->rflush();
-        $result = "";
-    }
+    #$tools .= "<br />\n";
     # End parameter setting
-    
-    $result .= "<br />\n";
 
     # Data
-    if ($counter) {
-        $result.=&Apache::loncommon::start_data_table("LC_tableOfContent").
-                 &Apache::loncommon::start_data_table_header_row('LC_visually_hidden').
-                 '<th>'.&mt('Resource or Folder').'</th>'.
-                 '<th>'.&mt('Alerts').'</th>'.
-                 '<th>'.&mt('Status Icon').'</th>'.
-                 '<th>'.&mt('Date/Completion Status').'</th>'.
-                 &Apache::loncommon::end_data_table_row()."\n";
-    }
 
     my $res = "Apache::lonnavmaps::resource";
     my %condenseStatuses =
@@ -1956,6 +1944,16 @@
         }
 
         $args->{'counter'}++;
+        unless ($tablestarted) {
+            $result.=&Apache::loncommon::start_data_table("LC_tableOfContent").
+                     &Apache::loncommon::start_data_table_header_row('LC_visually_hidden').
+                     '<th>'.&mt('Resource or Folder').'</th>'.
+                     '<th>'.&mt('Alerts').'</th>'.
+                     '<th>'.&mt('Status Icon').'</th>'.
+                     '<th>'.&mt('Date/Completion Status').'</th>'.
+                     &Apache::loncommon::end_data_table_row()."\n";
+                     $tablestarted = 1;
+        }
 
         # Does it have multiple parts?
         $args->{'multipart'} = 0;
@@ -2106,6 +2104,12 @@
         }
 
         if ($r && $rownum % 20 == 0) {
+            unless ($tools_printed) {
+                $r->print($legend.$tools);
+                $legend = "";
+                $tools = "";
+                $tools_printed = 1;
+            }
             $r->print($result);
             $result = "";
             $r->rflush();
@@ -2121,8 +2125,8 @@
 	}
     }
 
-    if ($counter) {
-        $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
@@ -2141,12 +2145,23 @@
     }
 
     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 {




More information about the LON-CAPA-cvs mailing list