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

raeburn raeburn at source.lon-capa.org
Wed Jan 16 15:23:42 EST 2019


raeburn		Wed Jan 16 20:23:42 2019 EDT

  Modified files:              
    /loncom/interface	lonnavmaps.pm 
    /rat	lonsequence.pm 
  Log:
  - Check $map is an object to avoid an ISE.
  
  
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.545 loncom/interface/lonnavmaps.pm:1.546
--- loncom/interface/lonnavmaps.pm:1.545	Sat Dec 29 23:24:40 2018
+++ loncom/interface/lonnavmaps.pm	Wed Jan 16 20:23:37 2019
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.545 2018/12/29 23:24:40 raeburn Exp $
+# $Id: lonnavmaps.pm,v 1.546 2019/01/16 20:23:37 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1490,10 +1490,13 @@
         if ($args->{'iterator_map'}) {
             my $map = $args->{'iterator_map'};
             $map = $navmap->getResourceByUrl($map);
-            my $firstResource = $map->map_start();
-            my $finishResource = $map->map_finish();
-
-            $args->{'iterator'} = $it = $navmap->getIterator($firstResource, $finishResource, $filterHash, $condition);
+            if (ref($map)) {
+                my $firstResource = $map->map_start();
+                my $finishResource = $map->map_finish();
+                $args->{'iterator'} = $it = $navmap->getIterator($firstResource, $finishResource, $filterHash, $condition);
+            } else {
+                return;
+            }
         } else {
             $args->{'iterator'} = $it = $navmap->getIterator(undef, undef, $filterHash, $condition,undef,$args->{'include_top_level_map'});
         }
Index: rat/lonsequence.pm
diff -u rat/lonsequence.pm:1.50 rat/lonsequence.pm:1.51
--- rat/lonsequence.pm:1.50	Sat Apr 14 17:52:53 2018
+++ rat/lonsequence.pm	Wed Jan 16 20:23:42 2019
@@ -2,7 +2,7 @@
 #
 # Sequence Handler
 #
-# $Id: lonsequence.pm,v 1.50 2018/04/14 17:52:53 raeburn Exp $
+# $Id: lonsequence.pm,v 1.51 2019/01/16 20:23:42 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -246,6 +246,15 @@
                }
            }
 
+           &Apache::loncommon::content_type($r,'text/html');
+           $r->send_http_header;
+
+           my $mapurl = &Apache::lonnet::declutter($requrl);
+           my $maptitle = &Apache::lonnet::gettitle($mapurl);
+           my @crumbs = ({text => $maptitle, no_mt => 1});
+           my $args = {'bread_crumbs' => \@crumbs,
+                       'bread_crumbs_nomenu' => 1};
+
            # Create the nav map
            my $navmap = Apache::lonnavmaps::navmap->new();
 
@@ -258,8 +267,7 @@
                        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
                        ($ltiscope,$ltiuri) = &LONCAPA::ltiutils::lti_provider_scope($env{'request.lti.uri'},$cdom,$cnum);
                    }
-                   my $mapurl = &Apache::lonnet::declutter($requrl);
-                   my @crumbs;
+                   @crumbs = ();
                    unless ($ltiscope eq 'resource') {
                        unless ($ltiscope eq 'map') {
                            @crumbs = ({text  => $crstype.' Contents',
@@ -281,13 +289,9 @@
                            }
                        }
                    }
-                   my $maptitle = &Apache::lonnet::gettitle($mapurl);
                    push(@crumbs,{text => $maptitle, no_mt => 1});
-                   my $args = {'bread_crumbs' => \@crumbs,
-                               'bread_crumbs_nomenu' => 1};
-                   &Apache::loncommon::content_type($r,'text/html');
-                   $r->send_http_header;
-
+                   $args = {'bread_crumbs' => \@crumbs,
+                            'bread_crumbs_nomenu' => 1};
                    $r->print(&Apache::loncommon::start_page($maptitle,undef,$args));
 
                    my $renderArgs = { 'cols'                    => [0,1,2,3],
@@ -307,14 +311,27 @@
 
                    # If no resources were found let the user know.
                    if ($renderArgs->{'counter'} == 0) {
-                       $r->print("<p><span class=\"LC_info\">".
-                                 &mt("This folder is empty.")."</span></p>");
+                       $r->print('<p class="LC_info">'.
+                                 &mt('No items found in folder').
+                                 '</p>');
                    }
                    $r->print(&Apache::loncommon::end_page());
-                   $r->rflush();
-                   return OK;
+               } else {
+                   $r->print(&Apache::loncommon::start_page($maptitle,undef,$args).
+                             '<p class="LC_info">'.
+                             &mt('Folder no longer appears to be a part of the course').
+                             '</p>'.
+                             &Apache::loncommon::end_page());
                }
+           } else {
+               $r->print(&Apache::loncommon::start_page($maptitle,undef,$args).
+                         '<p class="LC_warning">'.
+                         &mt('Error: could not determine contents of folder').
+                         '</p>'.
+                         &Apache::loncommon::end_page());
            }
+           $r->rflush();
+           return OK;
        }
    }
 




More information about the LON-CAPA-cvs mailing list