--- loncom/interface/lonmenu.pm 2010/10/04 23:00:46 1.309.2.16 +++ loncom/interface/lonmenu.pm 2010/02/10 08:24:31 1.313 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.309.2.16 2010/10/04 23:00:46 raeburn Exp $ +# $Id: lonmenu.pm,v 1.313 2010/02/10 08:24:31 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -131,7 +131,6 @@ use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); @@ -164,7 +163,6 @@ sub prep_menuitem { # entries from mydesk.tab sub primary_menu { my $menu; - my $custommenu = &Apache::loncommon::needs_gci_custom(); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition) foreach my $menuitem (@primary_menu) { @@ -180,16 +178,6 @@ sub primary_menu { next if $$menuitem[4] eq 'onlypublic'# hide links which are && $env{'user.name'} ne 'public' # only visible to public && $env{'user.domain'} ne 'public'; # users - next if $$menuitem[4] eq 'gci' - && (!$custommenu || $env{'request.role'} =~ m{^st\./gcitest/}); - next if $$menuitem[4] eq 'home' - && $custommenu; - next if $$menuitem[4] eq 'gcitest' - && $env{'user.domain'} eq 'gci'; - next if $$menuitem[4] eq 'roles' # hide links which are - && $custommenu; # not visible when GCI - next if $$menuitem[4] eq 'courses' # tabbed interface in use - && $custommenu; # 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 @@ -222,13 +210,11 @@ sub secondary_menu { $env{'user.domain'}, $env{'user.name'}, $env{'course.' . $env{'request.course.id'} . '.domain'}, $env{'course.' . $env{'request.course.id'} . '.num'}); - my $custommenu = &Apache::loncommon::needs_gci_custom(); - my $numdc = &Apache::loncommon::check_for_gci_dc(); foreach my $menuitem (@secondary_menu) { # evaluate conditions next if ref($menuitem) ne 'ARRAY'; - next if $$menuitem[4] eq 'showmenu' - && ($custommenu || !$numdc); + next if $$menuitem[4] ne 'always' + && !$env{'request.course.id'}; next if $$menuitem[4] eq 'showreturn' && !$showlink && !($env{'request.state'} eq 'construct'); @@ -249,9 +235,8 @@ sub secondary_menu { next if $$menuitem[4] =~ /showgroups$/ && !$canviewgrps && !%groups; - next if $$menuitem[4] eq 'showroles' - && ($custommenu || !$numdc); - if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'} && !$custommenu) { + + if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { # special treatment for role selector my $roles_selector = &roles_selector( $env{'course.' . $env{'request.course.id'} . '.domain'}, @@ -295,47 +280,6 @@ sub secondary_menu { return ""; } -sub gci_secondary_menu { - my %courses = ( - 'review' => 'gci_9615072b469884921gcil1', - 'submit' => 'gci_1H96711d710194bfegcil1', - 'tutorial' => 'gci_5422913620b814c90gcil1', - ); - my %linktext = ( - 'review' => 'Review Questions', - 'submit' => 'Submit Questions', - 'managetest' => 'Manage Tests', - 'tutorial' => 'Tutorials', - ); - my %links = ( - 'managetest' => '/adm/menu', - ); - my $current = 'managetest'; - if ($env{'form.destinationurl'} eq '/adm/gci_info') { - undef($current); - } - foreach my $key (keys(%courses)) { - $links{$key} = "javascript:switchpage('$key');"; - if ($env{'request.course.id'} eq $courses{$key}) { - $links{$key} = '/adm/navmaps'; - $current = $key; - $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; - } - } - my @menutabs = ('review','submit','managetest','tutorial'); - my $tabs; - foreach my $item (@menutabs) { - if ($item eq $current) { - $tabs .= '
  • '. - $linktext{$item}.'
  • '; - } else { - $tabs .= '
  • '. - $linktext{$item}.'
  • '; - } - } - return '
    '. - '

    '; -} # # This routine returns a translated hash for the menu items in the top inline menu row @@ -349,7 +293,7 @@ sub initlittle { 'roles' => (&Apache::loncommon::show_course()? 'Courses':'Roles'), 'other' => 'Other Roles', - 'docs' => 'Edit Course', + 'docs' => 'Course Editor', 'exit' => 'Logout', 'login' => 'Log In', 'launch' => 'Launch Remote Control', @@ -529,10 +473,6 @@ ENDINLINEMENU } sub show_return_link { - if (($env{'request.noversionuri'} =~ m{^/adm/(viewclasslist|navmaps)($|\?)}) - || ($env{'request.noversionuri'} =~ m{^/adm/.*/aboutme($|\?)})) { - return if ($env{'form.register'}); - } return (($env{'request.noversionuri'}=~m{^/(res|public)/} && $env{'request.symb'} eq '') || @@ -541,7 +481,7 @@ sub show_return_link { (($env{'request.noversionuri'}=~/^\/adm\//) && ($env{'request.noversionuri'}!~/^\/adm\/wrapper\//) && ($env{'request.noversionuri'}!~ - m[^/adm/.*/(smppg|bulletinboard)($|\?)]) + m[^/adm/.*/(smppg|bulletinboard|aboutme)($|\?)]) )); } @@ -614,13 +554,9 @@ sub innerregister { } else { $contentstext = &mt('Course Contents'); } - my @crumbs; - unless (($forcereg) && ($env{'request.noversionuri'} eq '/adm/navmaps') - && ($mapurl eq $env{'course.'.$env{'request.course.id'}.'.url'})) { - @crumbs = ({text => Apache::loncommon::course_type() - . ' Contents', - href => "Javascript:gopost('/adm/navmaps','')"}); - } + my @crumbs = ({text => $contentstext, + href => "Javascript:gonav('/adm/navmaps')"}); + if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { push(@crumbs, {text => '...', no_mt => 1}); @@ -864,7 +800,7 @@ $menuitems.="Make notes and annotations "&go('/adm/requestcourse')&Course requests\n"; } } - unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme|portfolio)(\?|$)/) { + unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { $menuitems.=(< @@ -1390,160 +1324,36 @@ sub openmenu { } sub inlinemenu { - my ($context) = @_; undef(@inlineremote); undef(%category_members); - my $output; - if ($context eq 'gcicustom') { - my (%can_request,%request_domains,$canreq,$createtext); - my $role = 'st'; - my $custommenu = &Apache::loncommon::needs_gci_custom(); - if ($custommenu) { - $role = 'cc'; - } - my %courses = &Apache::loncommon::existing_gcitest_courses($role); - my $numcourses = keys(%courses); - my ($switcher_js,$switcher); - my $formname = 'testpicker'; - if ($numcourses > 0) { - $switcher = &Apache::loncommon::gcitest_switcher($role,$formname,%courses); - my $current; - my $cid = $env{'request.course.id'}; - if ($cid) { - $current = $role.'./'.$env{'course.'.$cid.'.domain'}. - '/'.$env{'course.'.$cid.'.num'}; - } - $switcher_js = &Apache::loncommon::gcitest_switcher_js($current,$numcourses,$formname); - if ($switcher_js) { - $switcher_js= <<"ENDSCRIPT"; - - -ENDSCRIPT +# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control + &rawconfig(1); + my $output=''; + for (my $col=1; $col<=2; $col++) { + $output.='"; } + $output.="
    '; + for (my $row=1; $row<=8; $row++) { + foreach my $cat (keys(%category_members)) { + if ($category_positions{$cat} ne "$col,$row") { next; } + #$output.=''; + $output.='
    '; + $output.='

    '.&mt($category_names{$cat}).'

    '; + $output.='
    '.&mt($category_names{$cat}).'
    '; + my %active=(); + foreach my $menu_item (split(/\:/,$category_members{$cat})) { + if ($inlineremote[$menu_item]) { + $active{$menu_item}=1; + } + } + foreach my $item (sort(keys(%active))) { + $output.=$inlineremote[$item]; + } + $output.='
    '; + $output.=''; } - $switcher = $switcher_js.$switcher; - } - if ($env{'user.domain'} eq 'gci') { - $canreq = - &Apache::lonnet::check_can_request('gcitest',\%can_request,\%request_domains); - $createtext = &mt('Create Concept Test'); - if ($numcourses) { - $createtext = &mt('Create New Test'); - } - } - if ($env{'request.course.id'}) { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $output .= - '
    '; - } else { - my $navtext = &mt('Table of Contents'); - my $navdesc = &mt('Display Table of Contents for Geoscience Concept Inventory'); - if ($env{'request.role.domain'} eq 'gcitest') { - $navtext = &mt('Display Test Contents'); - $navdesc = &mt('Display the table of contents for this Concept Test'); - } - $output .= - '
    '. - '

    '.&mt('Utilities').'

    '. - ''; - if ($canreq) { - $output .= '
    '. - '
    '. - '
    '.$createtext.'
    '. - '
    '.&mt('Create a new Concept Test Course Container').'. '.&mt('Choose GCI questions to include in the test and upload a student roster.').'
    '; - } - $output .= '

    '; - } - } elsif ($switcher || $canreq) { - $output .= '

    '. - '
    '. - '

    '.&mt('Utilities').'

    '. - ''; - if ($switcher) { - $output .= '
    '. - '
    '; - } - } - if ($switcher) { - $output .= '
    '.&mt('Select Concept Test').'
    '. - '
    '.$switcher.'

    '; - } - $output .= '

    '; - } - } elsif ($context eq 'gcinorole') { - my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle'); - if ($queued) { - $output .= - '
    '. - '

    '.&mt('Pending Enrollment Requests').'

    '. - $queued. - '
    '; - } - } else { - # calling rawconfig with "1" will evaluate mydesk.tab, - # even if there is no active remote control - &rawconfig(1); - $output=''; - for (my $col=1; $col<=2; $col++) { - $output.='"; - } - $output.="
    '; - for (my $row=1; $row<=8; $row++) { - foreach my $cat (keys(%category_members)) { - if ($category_positions{$cat} ne "$col,$row") { next; } - $output.='
    '; - $output.='

    '.&mt($category_names{$cat}).'

    '; - $output.=''; - my %active=(); - foreach my $menu_item (split(/\:/,$category_members{$cat})) { - if ($inlineremote[$menu_item]) { - $active{$menu_item}=1; - } - } - foreach my $item (sort(keys(%active))) { - $output.=$inlineremote[$item]; - } - $output.='
    '; - $output.='
    '; - } - } - $output.="
    "; + } + $output.="
    "; return $output; } @@ -1838,54 +1648,11 @@ END } sub utilityfunctions { - my ($caller,$custommenu) = @_; + my $caller = shift; unless ($env{'environment.remote'} eq 'off' || $caller eq '/adm/menu') { return ''; } - - my $gcimenujs; - if ($custommenu) { - my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc'); - my $managetesturl = '/adm/menu'; - my $createtesturl = '/adm/requestcourse'; - if (($env{'request.course.id'}) && - ($env{'course.'.$env{'request.course.id'}.'.domain'} eq 'gci')) { - my @items = keys(%concepttests); - if (@items== 1) { - my $newrole = $items[0]; - $newrole =~ s{_}{/}; - $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1'; - } else { - $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu'; - } - } - if ($env{'request.course.id'}) { - $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse'; - } - $gcimenujs = <<"ENDCUSTOM"; - -function switchpage(caller) { - if (caller == 'review') { - document.location.href = '/adm/roles?selectrole=1&st./gci/9615072b469884921gcil1=1'; - } - if (caller == 'submit') { - document.location.href = '/adm/roles?selectrole=1&st./gci/1H96711d710194bfegcil1=1'; - } - if (caller == 'createtest') { - document.location.href = '$createtesturl'; - } - if (caller == 'managetest') { - document.location.href = '$managetesturl'; - } - if (caller == 'tutorial') { - document.location.href = '/adm/roles?selectrole=1&st./gci/5422913620b814c90gcil1=1'; - } - return; -} - -ENDCUSTOM - } - + my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); if ($currenturl =~ m{^/adm/wrapper/ext/}) { if ($env{'request.external.querystring'}) { @@ -1933,8 +1700,6 @@ return (< 0) { secok = 1;