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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 14 Dec 2004 15:56:42 -0000


albertel		Tue Dec 14 10:56:42 2004 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  - when viewing navmaps in a 'sorted' mode make sure links to things in pages point at the item in the page
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.309 loncom/interface/lonnavmaps.pm:1.310
--- loncom/interface/lonnavmaps.pm:1.309	Sun Dec 12 16:17:04 2004
+++ loncom/interface/lonnavmaps.pm	Tue Dec 14 10:56:41 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.309 2004/12/12 21:17:04 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.310 2004/12/14 15:56:41 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1849,7 +1849,26 @@
             # Add part 0 so we display it correctly.
             unshift @parts, '0';
         }
-
+	
+	{
+	    my ($src,$symb,$anchor,$stack);
+	    if ($args->{'sort'}) {
+		my $it = $navmap->getIterator(undef, undef, undef, 1);
+		while ( my $res=$it->next()) {
+		    if (ref($res) &&
+			$res->symb() eq  $curRes->symb()) { last; }
+		}
+		$stack=$it->getStack();
+	    } else {
+		$stack=$it->getStack();
+	    }
+	    ($src,$symb,$anchor)=getLinkForResource($stack);
+	    if (defined($anchor)) { $anchor='#'.$anchor; }
+	    my $srcHasQuestion = $src =~ /\?/;
+	    $args->{"resourceLink"} = $src.
+		($srcHasQuestion?'&':'?') .
+		'symb=' . &Apache::lonnet::escape($symb).$anchor;
+	}
         # Now, we've decided what parts to show. Loop through them and
         # show them.
         foreach my $part (@parts) {
@@ -1860,19 +1879,6 @@
 
             # Set up some data about the parts that the cols might want
             my $filter = $it->{FILTER};
-	    my ($src,$symb,$anchor);
-	    if ($args->{'sort'}) {
-		$src = $curRes->src(); # FIXME this is wrong for .pages
-		$symb = $curRes->symb(); # FIXME this is wrong for .pages
-	    } else {
-		my $stack = $it->getStack();
-		($src,$symb,$anchor)=getLinkForResource($stack);
-	    }
-	    if (defined($anchor)) { $anchor='#'.$anchor; }
-            my $srcHasQuestion = $src =~ /\?/;
-            $args->{"resourceLink"} = $src.
-                ($srcHasQuestion?'&':'?') .
-                'symb=' . &Apache::lonnet::escape($symb).$anchor;
 
             # Now, display each column.
             foreach my $col (@$cols) {