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

raeburn raeburn@source.lon-capa.org
Fri, 19 Dec 2008 23:04:13 -0000


raeburn		Fri Dec 19 23:04:13 2008 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  - Check that navmap object could be created to avoid ISE when checking for folders with randomly ordered resources.
  - Return warning message if navmap object unavailable. 
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.546 loncom/interface/lonprintout.pm:1.547
--- loncom/interface/lonprintout.pm:1.546	Sat Dec  6 12:49:18 2008
+++ loncom/interface/lonprintout.pm	Fri Dec 19 23:04:13 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.546 2008/12/06 12:49:18 bisitz Exp $
+# $Id: lonprintout.pm,v 1.547 2008/12/19 23:04:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2487,17 +2487,23 @@
 
     my $postdata = $env{'form.postdata'} || $helper->{VARS}{'postdata'};
     my $navmap = Apache::lonnavmaps::navmap->new();
-    my $res = $navmap->getResourceByUrl($map);
-    if ($res) {
-	my $func = 
-	    sub { return ($_[0]->is_map() && $_[0]->randomorder); };
-	my @matches = $navmap->retrieveResources($res, $func,1,1,1);
-	if (@matches) {
-	    $message = "Some of the items below are in folders set to be randomly ordered. However, when printing the contents of these folders, they will be printed in the original order for all students, not the randomized order.";
-	}
-    }
-    if ($message) {
-	return '<message type="warning">'.$message.'</message>';
+    if (defined($navmap)) {
+        my $res = $navmap->getResourceByUrl($map);
+        if ($res) {
+	    my $func = 
+	        sub { return ($_[0]->is_map() && $_[0]->randomorder); };
+	    my @matches = $navmap->retrieveResources($res, $func,1,1,1);
+	    if (@matches) {
+	        $message = "Some of the items below are in folders set to be randomly ordered. However, when printing the contents of these folders, they will be printed in the original order for all students, not the randomized order.";
+	    }
+        }
+        if ($message) {
+	    return '<message type="warning">'.$message.'</message>';
+        }
+    } else {
+        &Apache::lonnet::logthis('Retrieval of resources to check for folders set to be randomly ordered failed - could not create navmap object');
+        $message = "Retrieval of information about ordering of resources failed."; 
+        return '<message type="warning">'.$message.'</message>';
     }
     return;
 }