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

raeburn raeburn@source.lon-capa.org
Fri, 19 Dec 2008 18:57:43 -0000


raeburn		Fri Dec 19 18:57:43 2008 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  - Check that navmap object could be created to avoid ISE.
    - Display error message and log to lonnet.log if navmap object undefined.
  - &exportcourse() - remove duplicate &Apache::loncommon::end_page() -- one is added within calling handler().
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.324 loncom/interface/londocs.pm:1.325
--- loncom/interface/londocs.pm:1.324	Mon Dec 15 16:37:44 2008
+++ loncom/interface/londocs.pm	Fri Dec 19 18:57:43 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.324 2008/12/15 16:37:44 raeburn Exp $
+# $Id: londocs.pm,v 1.325 2008/12/19 18:57:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -280,6 +280,15 @@
                                                $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
     my $numdisc = keys(%discussiontime);
     my $navmap = Apache::lonnavmaps::navmap->new();
+    if (!defined($navmap)) {
+        $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package').
+                  '<h2>IMS Export Failed</h2>'.
+                  '<div class="LC_error">'.
+                  &mt('Unable to retrieve information about course contents').
+                  '</div><a href="/adm/coursedocs">'.&mt('Return to Course Editor').'</a>');
+        &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
+        return;
+    }
     my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
     my $curRes;
     my $outcome;
@@ -471,8 +480,7 @@
 	$r->print($display.'</table>'.
                   '<p><input type="hidden" name="finishexport" value="1">'.
                   '<input type="submit" name="exportcourse" value="'.
-                  &mt('Export '.$type.' DOCS').'" /></p></form>'.
-		  &Apache::loncommon::end_page());
+                  &mt('Export '.$type.' DOCS').'" /></p></form>');
     }
 }
 
@@ -2136,19 +2144,27 @@
 sub list_symbs {
     my ($r) = @_;
 
+    my $type = &Apache::loncommon::course_type();
     $r->print(&Apache::loncommon::start_page('Symb List'));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
     my $navmap = Apache::lonnavmaps::navmap->new();
-    $r->print("<pre>\n");
-    foreach my $res ($navmap->retrieveResources()) {
-	$r->print($res->compTitle()."\t".$res->symb()."\n");
+    if (!defined($navmap)) {
+        $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
+                  '<div class="LC_error">'.
+                  &mt('Unable to retrieve information about course contents').
+                  '</div>');
+        &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($type).':'.$env{'request.course.id'});
+    } else {
+        $r->print("<pre>\n");
+        foreach my $res ($navmap->retrieveResources()) {
+	    $r->print($res->compTitle()."\t".$res->symb()."\n");
+        }
+        $r->print("\n</pre>\n");
     }
-    $r->print("\n</pre>\n");
     $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
 }
 
 
-
 sub verifycontent {
     my ($r) = @_;
     my $type = &Apache::loncommon::course_type();