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

raeburn raeburn at source.lon-capa.org
Wed Jun 11 20:33:41 EDT 2014


raeburn		Thu Jun 12 00:33:41 2014 EDT

  Modified files:              
    /loncom/interface	lonblockingmenu.pm 
  Log:
  - Check $item retrieved by $navmap->getResourceByUrl() and 
    $navmap->getBySymb() is an object before calling compTitle() method.
  - Skip items with interval parameter set where corresponding map or resource
    is a zombie to avoid ISEs in the case where an interval parameter exists 
    for a (now) deleted map or resource.
  
  
Index: loncom/interface/lonblockingmenu.pm
diff -u loncom/interface/lonblockingmenu.pm:1.12 loncom/interface/lonblockingmenu.pm:1.13
--- loncom/interface/lonblockingmenu.pm:1.12	Sat Jun  7 19:13:42 2014
+++ loncom/interface/lonblockingmenu.pm	Thu Jun 12 00:33:41 2014
@@ -2,7 +2,7 @@
 # Routines for configuring blocking of access to collaborative functions, 
 # and specific resources during an exam
 #
-# $Id: lonblockingmenu.pm,v 1.12 2014/06/07 19:13:42 raeburn Exp $
+# $Id: lonblockingmenu.pm,v 1.13 2014/06/12 00:33:41 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1047,16 +1047,26 @@
                 if (&Apache::lonnet::is_on_map($url)) { 
                     if ($type eq 'map') {
                         if (ref($navmap)) {
-                            my $res = $navmap->getResourceByUrl($item);
-                            my $title = $res->compTitle();
+                            my $title;
+                            my $resobj = $navmap->getResourceByUrl($item);
+                            if (ref($resobj)) { 
+                                $title = $resobj->compTitle();
+                            } else {
+                                $title = &Apache::lonnet::gettitle($item);
+                            }
                             $itemname = &mt('Timer for all items in folder: [_1]',
                                             '<span style="font-style:italic">'.
                                             $title.'</span>');
                         }
                     } else {
                         if (ref($navmap)) {
-                            my $res = $navmap->getBySymb($item);
-                            my $title = $res->compTitle();
+                            my $title;
+                            my $resobj = $navmap->getBySymb($item);
+                            if (ref($resobj)) {
+                                $title = $resobj->compTitle();
+                            } else {
+                                $title = &Apache::lonnet::gettitle($item);
+                            }
                             $itemname = &mt('Timer for resource: [_1]',
                                              '<span style="font-style:italic">'.
                                              $title.'</span>');
@@ -1358,6 +1368,8 @@
                 if (ref($intervals->{$type}) eq 'HASH') {
                     if (ref($navmap)) {
                         foreach my $map (sort(keys(%{$intervals->{$type}}))) {
+                            next if ((!&Apache::lonnet::is_on_map($map)) &&
+                                     ($currkey ne $map));
                             my ($checked,$clickaction);
                             if ($currkey eq $map) {
                                 $checked = ' checked="checked"';
@@ -1368,12 +1380,16 @@
                                              '" value="'.&HTML::Entities::encode($map,'"<>&').'"'.
                                              $checked.$clickaction.' />';
                             if ($currkey eq $map) {
-                                $intervalform .= $itemname.'</label>';
+                                $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {
-                                my $res = $navmap->getResourceByUrl($map);
-                                my $title = $res->compTitle();
-                                my $path;
-                                my $hierarchy = &show_timer_path($type,$map,$navmap);
+                                my ($resobj,$title,$path,$hierarchy);
+                                $resobj = $navmap->getResourceByUrl($map);
+                                if (ref($resobj)) {
+                                    $title = $resobj->compTitle();
+                                } else {
+                                    $title = &Apache::lonnet::gettitle($map);
+                                }
+                                $hierarchy = &show_timer_path($type,$map,$navmap);
                                 if ($hierarchy) {
                                     $path = ' <span style="font-size:90%;">'.
                                             &mt('(in: [_1])',$hierarchy).
@@ -1383,9 +1399,6 @@
                                                      '<i>'.$title.'</i>').
                                                  '</label>'.$path;
                             }
-                            if ($currkey eq $map) {
-                                $intervalform .= $iteminfo;
-                            }
                             $intervalform .= '<br />';
                         }
                     }
@@ -1394,22 +1407,29 @@
                 if (ref($intervals->{$type}) eq 'HASH') {
                     if (ref($navmap)) {
                         foreach my $resource (sort(keys(%{$intervals->{$type}}))) {
-                            my ($checked,$clickaction);
+                            my ($checked,$clickaction,$resobj);
                             if ($currkey eq $resource) {
                                 $checked = ' checked="checked"';
-                            } elsif ($jschg) {
-                                $clickaction = ' onclick="'.$jschg.'"';
+                            } else {
+                                $resobj = $navmap->getBySymb($resource);
+                                next unless(ref($resobj));
+                                if ($jschg) {
+                                    $clickaction = ' onclick="'.$jschg.'"';
+                                }
                             }
                             $intervalform .= '<label><input type="radio" name="firstaccess_'.$parmcount.
                                              '" value="'.&HTML::Entities::encode($resource,'"<>&').'"'.
                                              $checked.$clickaction.' />';
                             if ($currkey eq $resource) {
-                                $intervalform .= $itemname.'</label>';
+                                $intervalform .= $itemname.'</label>'.$iteminfo;
                             } else {
-                                my $res = $navmap->getBySymb($resource);
-                                my $title = $res->compTitle();
-                                my $path;
-                                my $hierarchy = &show_timer_path($type,$resource,$navmap);
+                                my ($title,$path,$hierarchy);
+                                if (ref($resobj)) {
+                                    $title = $resobj->compTitle();
+                                } else {
+                                    $title = &Apache::lonnet::gettitle($resource);
+                                }
+                                $hierarchy = &show_timer_path($type,$resource,$navmap);
                                 if ($hierarchy) {
                                     $path = ' <span style="font-size:90%;">'.
                                             &mt('(in: [_1])',$hierarchy).
@@ -1419,9 +1439,6 @@
                                                  '</label>'.
                                                  $path;
                             }
-                            if ($currkey eq $resource) {
-                                $intervalform .= $iteminfo;
-                            }
                             $intervalform .= '<br />';
                         }
                     }




More information about the LON-CAPA-cvs mailing list