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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Tue, 26 Nov 2002 17:01:29 -0000


bowersj2		Tue Nov 26 12:01:29 2002 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  Sorry about that last commit, I tried to cancel it. This covers the last
  two commits:
  
  * Navmaps table has had the width constraints removed. It will now
    grow 'naturally'.
  * Iterator now does not return empty resources, so that's one less thing
    clients have to worry about getting right.
  * Maps that have only one resource, which is itself a map, are now suppressed
    in the nav map. This fixes in passing bug #995, but is a little more 
    powerful then just fixing the bug, in that it applies everywhere in the
    map. You can now therefore use these "redirecting" maps without fear
    of messing up the course (or anything else that uses the iterator:
    lonnavmaps automatically benefits from this. ;-) ).
  
    This also cleaned up the code a bit, removing the dependency on checking
    for a specific sequence source to tell how many levels to throw
    away.
  
  The third is somewhat lightly tested, so (Gerd) please check it on any 
  courses you had set up to file the bug in the first place and let me know
  if this fixes it properly.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.116 loncom/interface/lonnavmaps.pm:1.117
--- loncom/interface/lonnavmaps.pm:1.116	Tue Nov 26 11:25:36 2002
+++ loncom/interface/lonnavmaps.pm	Tue Nov 26 12:01:29 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.116 2002/11/26 16:25:36 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.117 2002/11/26 17:01:29 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1384,7 +1384,12 @@
         
             if (ref($curRes)) {
                 # If there's only one resource, this will save it
-                if($direction == FORWARD) { $resource = $curRes; $resourceCount++; }
+                # we have to filter empty resources from consideration here,
+                # or even "empty", redirecting maps have two (start & finish)
+                # or three (start, finish, plus redirector)
+                if($direction == FORWARD && $curRes->src()) { 
+                    $resource = $curRes; $resourceCount++; 
+                }
                 my $resultingVal = $curRes->{DATA}->{$valName};
                 my $nextResources = $curRes->$nextResourceMethod();
                 my $nextCount = scalar(@{$nextResources});
@@ -1576,6 +1581,8 @@
     }
 
     # If this is a blank resource, don't actually return it.
+    # Should you ever find you need it, make sure to add an option to the code
+    #  that you can use; other things depend on this behavior.
     if (!$self->{HERE}->src()) {
         return $self->next();
     }
@@ -1626,6 +1633,9 @@
 #  but this might as well be left seperate, since it is possible some other
 #  use might be found for it. - Jeremy
 
+# Unlike the main iterator, this DOES return all resources, even blank ones.
+#  The main iterator needs them to correctly preprocess the map.
+
 sub BEGIN_MAP { return 1; }    # begining of a new map
 sub END_MAP { return 2; }      # end of the map
 sub FORWARD { return 1; }      # go forward
@@ -1763,11 +1773,6 @@
                                              $self->{CONDITION}, $self->{DIRECTION});
     }
 
-    # If this is a blank resource, ignore it.
-    if (!$self->{HERE}->src()) {
-        return $self->next();
-    }
-    
     return $self->{HERE};
 }