--- loncom/interface/lonblockingmenu.pm 2014/06/07 19:13:42 1.12 +++ loncom/interface/lonblockingmenu.pm 2014/06/12 00:33:41 1.13 @@ -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 @@ ACT 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 @@ sub create_interval_form { 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 @@ sub create_interval_form { '" 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 @@ sub create_interval_form { '<i>'.$title.'</i>'). '</label>'.$path; } - if ($currkey eq $map) { - $intervalform .= $iteminfo; - } $intervalform .= '<br />'; } } @@ -1394,22 +1407,29 @@ sub create_interval_form { 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 @@ sub create_interval_form { '</label>'. $path; } - if ($currkey eq $resource) { - $intervalform .= $iteminfo; - } $intervalform .= '<br />'; } }