--- loncom/interface/lonmenu.pm 2017/12/18 23:20:48 1.484 +++ loncom/interface/lonmenu.pm 2020/10/06 21:28:33 1.503 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.484 2017/12/18 23:20:48 raeburn Exp $ +# $Id: lonmenu.pm,v 1.503 2020/10/06 21:28:33 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -99,7 +99,7 @@ It gets filled in the BEGIN block of thi =over -=item prep_menuitems(\@menuitem) +=item prep_menuitems(\@menuitem,$ltitarget) This routine wraps a menuitem in proper HTML. It is used by primary_menu() and secondary_menu(). @@ -210,6 +210,7 @@ use Apache::lonenc(); use Apache::lonlocal; use Apache::lonmsg(); use LONCAPA qw(:DEFAULT :match); +use LONCAPA::ltiutils; use HTML::Entities(); use Apache::lonwishlist(); @@ -219,7 +220,7 @@ use vars qw(@desklines %category_names % my @inlineremote; sub prep_menuitem { - my ($menuitem) = @_; + my ($menuitem,$ltitarget) = @_; return '' unless(ref($menuitem) eq 'ARRAY'); my $link; if ($$menuitem[1]) { # graphical Link @@ -229,10 +230,14 @@ sub prep_menuitem { } else { # textual Link $link = &mt($$menuitem[3]); } + my $target = ' target="_top"'; + if ($ltitarget eq 'iframe') { + $target =''; + } return '
  • $link
  • |; + . qq| href="$$menuitem[0]"$target>$link|; } # primary_menu() evaluates @primary_menu and returns a two item array, @@ -242,8 +247,8 @@ sub prep_menuitem { # @primary_menu is filled within the BEGIN block of this module with # entries from mydesk.tab sub primary_menu { - my ($crstype) = @_; - my (%menu); + my ($crstype,$ltimenu) = @_; + my (%menu,%ltiexc); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition, position) my $public; @@ -260,6 +265,18 @@ sub primary_menu { my %roles_in_env; $rolecount = &Apache::lonroles::roles_from_env(\%roles_in_env,$update); } + my ($lti,$ltitarget); + if ($env{'request.lti.login'}) { + $lti = 1; + $ltitarget = $env{'request.lti.target'}; + if (ref($ltimenu) eq 'HASH') { + foreach my $item ('fullname','logout') { + unless ($ltimenu->{$item}) { + $ltiexc{$item} = 1; + } + } + } + } foreach my $menuitem (@primary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; # @@ -274,9 +291,15 @@ sub primary_menu { && !$public; # only visible to public # users next if $$menuitem[4] eq 'roles' ##show links depending on - && &Apache::loncommon::show_course(); ##term 'Courses' or - next if $$menuitem[4] eq 'courses' ##'Roles' wanted - && !&Apache::loncommon::show_course(); ## + && (&Apache::loncommon::show_course() ##term 'Courses' or + || $env{'request.lti.login'}); ##'Roles' wanted + next if $$menuitem[4] eq 'courses' ##and not LTI access + && (!&Apache::loncommon::show_course() + || !$env{'request.lti.login'}); + next if $$menuitem[4] eq 'notlti' + && $lti; + next if $$menuitem[4] eq 'ltiexc' + && exists($ltiexc{lc($menuitem->[3])}); my $title = $menuitem->[3]; if (($crstype eq 'Placement') && (!$env{'request.role.adv'})) { if ($menuitem->[4] eq 'courses') { @@ -293,7 +316,9 @@ sub primary_menu { my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; - $target = '_top'; + unless ($ltitarget eq 'iframe') { + $target = '_top'; + } } else { $link = '#'; } @@ -309,7 +334,9 @@ sub primary_menu { push(@primsub,$item); } if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { - $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); + unless ($ltiexc{'fullname'}) { + $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); + } } else { $title = &mt($title); } @@ -328,13 +355,13 @@ sub primary_menu { 'helpdeskmail', $defdom,$origmail); if ($to ne '') { - $menu{$position} .= &prep_menuitem($menuitem); + $menu{$position} .= &prep_menuitem($menuitem,$ltitarget); } } else { $menu{$position} .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } } else { - $menu{$position} .= prep_menuitem($menuitem); + $menu{$position} .= prep_menuitem($menuitem,$ltitarget); } } my @output = ('',''); @@ -373,7 +400,7 @@ sub getauthor{ } sub secondary_menu { - my ($httphost) = @_; + my ($httphost,$ltiscope,$ltimenu,$noprimary) = @_; my $menu; my $crstype = &Apache::loncommon::course_type(); @@ -394,9 +421,10 @@ sub secondary_menu { my $canmodpara = &Apache::lonnet::allowed('opa', $crs_sec); my $canvgr = &Apache::lonnet::allowed('vgr', $crs_sec); my $canmgr = &Apache::lonnet::allowed('mgr', $crs_sec); + my $canplc = &Apache::lonnet::allowed('plc', $crs_sec); my $author = &getauthor(); - my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools); + my ($cdom,$cnum,$showsyllabus,$showfeeds,$showresv,$grouptools,$lti,$ltimapres,%ltiexc); $grouptools = 0; if ($env{'request.course.id'}) { $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -420,10 +448,9 @@ sub secondary_menu { $showresv = 1; } } - my %groups = &Apache::lonnet::get_active_groups( - $env{'user.domain'}, $env{'user.name'},$cdom,$cnum); - if (%groups) { - foreach my $group (keys(%groups)) { + if ($env{'request.course.groups'} ne '') { + foreach my $group (split(/:/,$env{'request.course.groups'})) { + next unless ($group =~ /^\w+$/); my @privs = split(/:/,$env{"user.priv.$env{'request.role'}./$cdom/$cnum/$group"}); shift(@privs); if (@privs) { @@ -431,6 +458,19 @@ sub secondary_menu { } } } + if ($env{'request.lti.login'}) { + $lti = 1; + if (ref($ltimenu) eq 'HASH') { + foreach my $item ('fullname','coursetitle','role','logout','grades') { + unless ($ltimenu->{$item}) { + $ltiexc{$item} = 1; + } + } + } + if (($ltiscope eq 'map') || ($ltiscope eq 'resource')) { + $ltimapres = 1; + } + } } my ($canmodifycoauthor); @@ -441,7 +481,11 @@ sub secondary_menu { $canmodifycoauthor = 1; } } - my ($roleswitcher_js,$roleswitcher_form); + + my ($roleswitcher_js,$roleswitcher_form,$ltitarget); + if ($env{'request.lti.login'}) { + $ltitarget = $env{'request.lti.target'}; + } foreach my $menuitem (@secondary_menu) { # evaluate conditions @@ -453,7 +497,7 @@ sub secondary_menu { next if $$menuitem[4] =~ /^crsedit/ && (!$canedit && !$canvieweditor); next if $$menuitem[4] eq 'nvgr' - && $canvgr; + && ($canvgr || $ltiexc{'grades'}); next if $$menuitem[4] eq 'vgr' && !$canvgr; next if $$menuitem[4] eq 'viewusers' @@ -474,17 +518,29 @@ sub secondary_menu { && !$showsyllabus; next if $$menuitem[4] eq 'showfeeds' && !$showfeeds; + next if $$menuitem[4] eq 'plc' + && !$canplc; next if $$menuitem[4] eq 'author' && !$author; next if $$menuitem[4] eq 'cca' && !$canmodifycoauthor; + next if $$menuitem[4] eq 'notltimapres' + && $ltimapres; + next if $$menuitem[4] eq 'notlti' + && $lti; + next if $$menuitem[4] eq 'lti' + && (!$lti || !$noprimary); + next if $$menuitem[3] eq 'Logout' + && $ltiexc{'logout'}; my $title = $menuitem->[3]; if (defined($secondary_submenu{$title})) { my ($link,$target); if ($menuitem->[0] ne '') { $link = $menuitem->[0]; - $target = '_top'; + unless ($ltitarget eq 'iframe') { + $target = '_top'; + } } else { $link = '#'; } @@ -502,9 +558,21 @@ sub secondary_menu { next if ($item->[2] eq 'params' && !$canmodpara && !$canviewpara); next if ($item->[2] eq 'author' && !$author); next if ($item->[2] eq 'cca' && !$canmodifycoauthor); + next if ($item->[2] eq 'lti' && !$lti); + if ($item->[2] =~ /^lti(portfolio|wishlist|blog)$/) { + my $tool = $1; + next if !$lti; + next if (!&Apache::lonnet::usertools_access('','',$tool, + undef,'tools')); + } push(@scndsub,$item); } } + if ($title eq 'Personal' && $env{'user.name'} && $env{'user.domain'} ) { + unless ($ltiexc{'fullname'}) { + $title = &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}); + } + } if (@scndsub > 0) { $menu .= &create_submenu($link,$target,$title,\@scndsub,1); } elsif ($link ne '#') { @@ -515,11 +583,14 @@ sub secondary_menu { # special treatment for role selector ($roleswitcher_js,$roleswitcher_form,my $switcher) = &roles_selector( - $env{'course.' . $env{'request.course.id'} . '.domain'}, - $env{'course.' . $env{'request.course.id'} . '.num'}, - $httphost + $env{'course.' . $env{'request.course.id'} . '.domain'}, + $env{'course.' . $env{'request.course.id'} . '.num'}, + $httphost,$ltitarget ); $menu .= $switcher; + } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink + next if ($crstype eq 'Placement'); + $menu .= '
  • '.&Apache::loncommon::top_nav_help('Help').'
  • '; } else { if ($$menuitem[3] eq 'Syllabus' && $env{'request.course.id'}) { my $url = $$menuitem[0]; @@ -533,17 +604,19 @@ sub secondary_menu { } if ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://}) { if (($ENV{'SERVER_PORT'} == 443) || ($env{'request.use_absolute'} =~ m{^https://})) { - unless ($$menuitem[0] =~ m{^https?://}) { - $$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; - } - unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) { - $$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1'; + unless (&Apache::lonnet::uses_sts()) { + unless ($$menuitem[0] =~ m{^https?://}) { + $$menuitem[0] = 'http://'.$ENV{'SERVER_NAME'}.$$menuitem[0]; + } + unless ($$menuitem[0] =~ /(\&|\?)usehttp=1/) { + $$menuitem[0] .= (($$menuitem[0]=~/\?/) ? '&' : '?').'usehttp=1'; + } } } } $$menuitem[0] = &HTML::Entities::encode($$menuitem[0],'&<>"'); } - $menu .= &prep_menuitem(\@$menuitem); + $menu .= &prep_menuitem(\@$menuitem,$ltitarget); } } if ($menu =~ /\[url\].*\[symb\]/) { @@ -566,6 +639,7 @@ sub secondary_menu { } $menu =~ s/\[uname\]/$$author{user}/g; $menu =~ s/\[udom\]/$$author{dom}/g; + $menu =~ s/\[javascript\]/javascript:/g; if ($env{'request.course.id'}) { $menu =~ s/\[cnum\]/$cnum/g; $menu =~ s/\[cdom\]/$cdom/g; @@ -649,9 +723,25 @@ sub build_submenu { next unless (($env{'user.name'} ne '') && ($env{'user.domain'} ne '')); $href =~ s/\[domain\]/$env{'user.domain'}/g; $href =~ s/\[user\]/$env{'user.name'}/g; + } elsif (($href =~ m{^/adm/preferences\?}) && ($href =~ /\[returnurl\]/)) { + my $returnurl = $ENV{'REQUEST_URI'}; + if ($ENV{'REQUEST_URI'} =~ m{/adm/preferences\?action=(?:changedomcoord|authorsettings)\&returnurl=([^\&]+)$}) { + $returnurl = $1; + } + if (($returnurl =~ m{^/adm/createuser($|\?action=)}) || + ($returnurl =~ m{^/priv/$match_domain/$match_username}) || + ($returnurl =~ m{^/res(/?$|/$match_domain/$match_username)})) { + $returnurl =~ s{\?.*$}{}; + $returnurl = '&returnurl='.&HTML::Entities::encode($returnurl,'"<>&\''); + } else { + undef($returnurl); + } + $href =~ s/\[returnurl\]/$returnurl/; } unless (($href eq '') || ($href =~ /^\#/)) { - $target = ' target="_top"'; + if ($target eq '_top') { + $target = ' target="_top"'; + } } $menu .= '
  • '; @@ -664,7 +754,7 @@ sub build_submenu { } sub innerregister { - my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname) = @_; + my ($forcereg,$bread_crumbs,$group,$pagebuttonshide,$hostname,$ltiscope,$ltiuri) = @_; my $const_space = ($env{'request.state'} eq 'construct'); my $is_const_dir = 0; @@ -695,22 +785,29 @@ sub innerregister { my (@crumbs,@mapcrumbs); if (($env{'request.noversionuri'} ne '/adm/navmaps') && ($mapurl ne '') && (!(($crstype eq 'Placement') && !$env{'request.role.adv'}))) { - $navmap = Apache::lonnavmaps::navmap->new(); - if (ref($navmap)) { - @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); + unless ($ltiscope eq 'resource') { + if (($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) && + !(($ltiscope eq 'map') && (&Apache::lonnet::clutter($resurl) eq $ltiuri))) { + $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + @mapcrumbs = $navmap->recursed_crumbs($mapurl,$restitle); + } + } } } unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps') && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || - (($crstype eq 'Placement') && (!$env{'request.role.adv'}))) { + (($crstype eq 'Placement') && (!$env{'request.role.adv'})) || + ($ltiscope eq 'map') || ($ltiscope eq 'resource')) { @crumbs = ({text => $crstype.' Contents', href => "Javascript:gopost('/adm/navmaps','')"}); } if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { if (@mapcrumbs) { push(@crumbs,@mapcrumbs); - } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'}))) { + } elsif (!(($crstype eq 'Placement') && (!$env{'request.role.adv'})) && + ($ltiscope ne 'map') && ($ltiscope ne 'resource')) { push(@crumbs, {text => '...', no_mt => 1}); } @@ -718,8 +815,10 @@ sub innerregister { unless ((($crstype eq 'Placement') && (!$env{'request.role.adv'})) || (@mapcrumbs) || (!$maptitle) || ($maptitle eq 'default.sequence') || - ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { - push @crumbs, {text => $maptitle, no_mt => 1, href => $mapurl}; + ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'}) || + ($ltiscope eq 'resource')) { + push @crumbs, {text => $maptitle, no_mt => 1, + href => &Apache::lonnet::clutter($mapurl).'?navmap=1'}; } if ($restitle && !@mapcrumbs) { push(@crumbs,{text => $restitle, no_mt => 1}); @@ -912,7 +1011,35 @@ ENDMENUITEMS # Should probably be in mydesk.tab # $menuitems = "c&3&1"; - if (($crstype ne 'Placement') || ($env{'request.role.adv'})) { + if ($ltiscope eq 'resource') { +# Suppress display of backward arrow for LTI Provider if scope is resource. +# Suppress display of forward arrow for LTI Provider if scope is resource. + } elsif ($ltiscope eq 'map') { +# Suppress display of backward arrow for LTI Provider if scope is map and this is first resource. +# Suppress display of forward arrow for LTI Provider if scope is map and this is the last resource. + my $showforw = 1; + my $showback = 1; + my $navmap = Apache::lonnavmaps::navmap->new(); + if (ref($navmap)) { + my $mapres = $navmap->getResourceByUrl($ltiuri); + if (ref($mapres)) { + if ($navmap->isLastResource($mapres,$env{'request.symb'})) { + $showforw = 0; + } + if ($navmap->isFirstResource($mapres,$env{'request.symb'})) { + $showback = 0; + } + } + } + if ($showback) { + $menuitems.=" +s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1"; + } + if ($showforw) { + $menuitems.=" +s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3"; + } + } elsif (($crstype ne 'Placement') || ($env{'request.role.adv'})) { $menuitems.=" s&2&1&back.png&&&gopost('/adm/flip','back:'+currentURL)&Previous content resource&&1 s&2&3&forw.png&&&gopost('/adm/flip','forward:'+currentURL)&Next content resource&&3"; @@ -971,12 +1098,14 @@ if ($env{'browser.mobile'}) { } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|viewclasslist|portfolio)(\?|$)/) { - if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/docs/}) && ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) { + if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/}) && + ($env{'request.noversionuri'} !~ m{^/uploaded/$match_domain/$match_courseid/(docs/|default_\d+\.page$)}) && + ($env{'request.noversionuri'} !~ m{^/adm/.+/ext\.tool$})) { $menuitems.=(<'.$pic.''; @@ -1776,13 +1909,18 @@ sub done_button_js { key => 'Key:', nokey => 'A proctor key is required', ); + my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'})); my $navmap = Apache::lonnavmaps::navmap->new(); my ($missing,$tried) = (0,0); if (ref($navmap)) { my @resources=(); if ($type eq 'map') { my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($env{'request.symb'}); - @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() }); + if ($env{'request.symb'} =~ /\.page$/) { + @resources=$navmap->retrieveResources($resurl,sub { $_[0]->is_problem() }); + } else { + @resources=$navmap->retrieveResources($mapurl,sub { $_[0]->is_problem() }); + } } else { my $res = $navmap->getBySymb($env{'request.symb'}); if (ref($res)) { @@ -1834,6 +1972,7 @@ sub done_button_js {
    +
    @@ -1915,6 +2054,7 @@ END
    +
    @@ -1960,13 +2100,17 @@ END sub utilityfunctions { my ($httphost) = @_; my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); - if ($currenturl =~ m{^/adm/wrapper/ext/} - && $env{'request.external.querystring'} ) { + my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); + if ($currenturl =~ m{^/adm/wrapper/ext/}) { + if ($env{'request.external.querystring'}) { $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; + } + my ($anchor) = ($env{'request.symb'} =~ /(\#[^\#]+)$/); + if (($anchor) && ($currenturl !~ /\Q$anchor\E$/)) { + $currenturl .= $1; + } } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); - - my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); my $dc_popup_cid; if ($env{'user.adv'} && exists($env{'user.role.dc./'. @@ -1993,6 +2137,15 @@ sub utilityfunctions { my $countdown = &countdown_toggle_js(); + my $ltitarget; + if ($env{'request.lti.login'}) { + $ltitarget = $env{'request.lti.target'}; + } + + my $annotateurl = '/adm/annotation'; + if ($httphost) { + $annotateurl = '/adm/annotations'; + } my $hostvar = ' function setLCHost() { var lcHostname=""; @@ -2089,17 +2242,22 @@ function golist(url) { currentURL = null; currentSymb= null; var lcHostname = setLCHost(); - top.location.href=lcHostname+url; + var ltitarget = '$ltitarget'; + if (ltitarget == 'iframe') { + document.location.href=lcHostname+url; + } else { + top.location.href=lcHostname+url; + } } } -function catalog_info(isMobile) { +function catalog_info(url,isMobile) { if (isMobile == 1) { - openMyModal(window.location.pathname+'.meta?modal=1',500,400,'yes'); + openMyModal(url+'.meta?modal=1',500,400,'yes'); } else { - loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); + loncatinfo=window.open(url+'.meta',"LONcatInfo",'height=500,width=400,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); } } @@ -2121,7 +2279,7 @@ function annotate() { annotator.document.write( '$start_page_annotate' +"
    " + +"action='$annotateurl'>" +"" +"<\\/form>" +'$end_page_annotate'); @@ -2143,11 +2301,22 @@ function open_StoredLinks_Import(rat) { } function open_source() { - var url = escape(window.location.pathname); - sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+url,'LONsource', + sourcewin=window.open('/adm/source?inhibitmenu=yes&viewonly=1&filename='+currentURL,'LONsource', 'height=500,width=600,resizable=yes,location=no,menubar=no,toolbar=no,scrollbars=yes'); } +function open_aboutLC() { + var isMobile = "$env{'browser.mobile'}"; + var url = '/adm/about.html'; + if (isMobile == 1) { + openMyModal(url,600,400,'yes'); + } else { + window.open(url,"aboutLONCAPA","height=400,width=600,scrollbars=1,resizable=1,menubar=0,location=1"); + } + return; +} + + (function (\$) { \$(document).ready(function () { \$.single=function(a){return function(b){a[0]=b;return a}}(\$([1])); @@ -2168,8 +2337,12 @@ ENDUTILITY } sub serverform { + my $target; + unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { + $target = ' target="_top"'; + } return(< + @@ -2179,15 +2352,20 @@ ENDSERVERFORM } sub constspaceform { + my ($target,$printtarget); + unless (($env{'request.lti.login'}) && ($env{'request.lti.target'} eq 'iframe')) { + $target = ' target="_top"'; + $printtarget = ' target="_parent"'; + } return(< + -
    +
    -
    + @@ -2207,7 +2385,7 @@ sub hidden_button_check { } sub roles_selector { - my ($cdom,$cnum,$httphost) = @_; + my ($cdom,$cnum,$httphost,$ltitarget) = @_; my $crstype = &Apache::loncommon::course_type(); my $now = time; my (%courseroles,%seccount,%courseprivs,%roledesc); @@ -2369,7 +2547,7 @@ sub roles_selector { } } if (@submenu > 0) { - $switcher = &create_submenu('','',&mt('Switch role'),\@submenu); + $switcher = &create_submenu('','',&mt('Switch role'),\@submenu,'','',$ltitarget); } } return ($js,$form,$switcher); @@ -2714,11 +2892,19 @@ sub countdown_timer { my $now = time; if ($env{'request.filename'} =~ /\.task$/) { $type = 'Task'; + } elsif ($env{'request.symb'} =~ /ext\.tool$/) { + $type = 'tool'; } else { $type = 'problem'; } - my ($status,$accessmsg,$slot_name,$slot) = - &Apache::lonhomework::check_slot_access('0',$type); + my ($status,$accessmsg,$slot_name,$slot); + if ($type eq 'tool') { + ($status,$accessmsg,$slot_name,$slot) = + &Apache::lonhomework::check_slot_access('0',$type,$env{'request.symb'},['0']); + } else { + ($status,$accessmsg,$slot_name,$slot) = + &Apache::lonhomework::check_slot_access('0',$type); + } if ($slot_name ne '') { if (ref($slot) eq 'HASH') { if (($slot->{'starttime'} < $now) &&