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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 09 Oct 2003 21:02:11 -0000


bowersj2		Thu Oct  9 17:02:11 2003 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
  Log:
  navmaps should now honor part order.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.238 loncom/interface/lonnavmaps.pm:1.239
--- loncom/interface/lonnavmaps.pm:1.238	Wed Oct  8 15:22:17 2003
+++ loncom/interface/lonnavmaps.pm	Thu Oct  9 17:02:11 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.238 2003/10/08 19:22:17 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.239 2003/10/09 21:02:11 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3578,32 +3578,46 @@
 
     # Retrieve part count, if this is a problem
     if ($self->is_problem()) {
+	my $partorder;
+	# Hypothetically, replace previous line with:
+	# my $partorder = &Apache::lonnet::metadata($self->src(), 'partorder');
+	# and it'll all work...
         my $metadata = &Apache::lonnet::metadata($self->src(), 'packages');
-        if (!$metadata) {
-            $self->{RESOURCE_ERROR} = 1;
-            $self->{PARTS} = [];
-            $self->{PART_TYPE} = {};
-            return;
-        }
-        foreach (split(/\,/,$metadata)) {
-            if ($_ =~ /^part_(.*)$/) {
-                my $part = $1;
-                # This floods the logs if it blows up
-                if (defined($parts{$part})) {
-                    Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
-                  }
 
-                # check to see if part is turned off.
-
-                if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
-                    $parts{$part} = 1;
-                }
-            }
+	if ($partorder) {
+	    my @parts;
+	    for my $part (split (/,/,$partorder)) {
+		if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+		    push @parts, $part;
+		}
+	    }
+	    $self->{PARTS} = \@parts;
+	} else {
+	    if (!$metadata) {
+		$self->{RESOURCE_ERROR} = 1;
+		$self->{PARTS} = [];
+		$self->{PART_TYPE} = {};
+		return;
+	    }
+	    foreach (split(/\,/,$metadata)) {
+		if ($_ =~ /^part_(.*)$/) {
+		    my $part = $1;
+		    # This floods the logs if it blows up
+		    if (defined($parts{$part})) {
+			Apache::lonnet::logthis("$part multiply defined in metadata for " . $self->symb());
+		      }
+		    
+		    # check to see if part is turned off.
+		    
+		    if (!Apache::loncommon::check_if_partid_hidden($part, $self->symb())) {
+			$parts{$part} = 1;
+		    }
+		}
+	    }
+	    my @sortedParts = sort keys %parts;
+	    $self->{PARTS} = \@sortedParts;
         }
         
-        
-        my @sortedParts = sort keys %parts;
-        $self->{PARTS} = \@sortedParts;
 
         my %responseIdHash;
         my %responseTypeHash;
@@ -3615,7 +3629,7 @@
         }
 
         # Now, the unfortunate thing about this is that parts, part name, and
-        # response if are delimited by underscores, but both the part
+        # response id are delimited by underscores, but both the part
         # name and response id can themselves have underscores in them.
         # So we have to use our knowlege of part names to figure out 
         # where the part names begin and end, and even then, it is possible