--- loncom/interface/lonmenu.pm 2009/11/18 11:18:23 1.303 +++ loncom/interface/lonmenu.pm 2009/12/24 18:28:58 1.309.2.5 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.303 2009/11/18 11:18:23 droeschl Exp $ +# $Id: lonmenu.pm,v 1.309.2.5 2009/12/24 18:28:58 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -160,6 +160,7 @@ 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) { @@ -175,6 +176,10 @@ 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 '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 @@ -277,6 +282,45 @@ sub secondary_menu { return ""; } +sub gci_secondary_menu { + my %courses = ( + 'review' => 'gci_9615072b469884921gcil1', + 'submit' => 'gci_1H96711d710194bfegcil1', + ); + my %linktext = ( + 'review' => 'Review Questions', + 'submit' => 'Submit Questions', + 'managetest' => 'Manage Tests', + ); + 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'); + 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 @@ -512,7 +556,7 @@ sub registerurl { } sub innerregister { - my ($forcereg, $titletable) = @_; + my ($forcereg,$titletable,$bread_crumbs) = @_; my $result = ''; my ($uname,$thisdisfn); my $const_space = ($env{'request.state'} eq 'construct'); @@ -753,6 +797,14 @@ s&7&1&del.gif&delete[_1]&resource[_2]&go s&7&2&prt.gif&prepare[_1]&printout[_1]&gocstr('/adm/printout','/~$uname/$cleandisfn')&Prepare a printable document ENDMENUITEMS } + if ($noremote) { + if (ref($bread_crumbs) eq 'ARRAY') { + &Apache::lonhtmlcommon::clear_breadcrumbs(); + foreach my $crumb (@{$bread_crumbs}){ + &Apache::lonhtmlcommon::add_breadcrumb($crumb); + } + } + } } elsif ( defined($env{'request.course.id'}) && $env{'request.symb'} ne '' ) { # @@ -832,6 +884,7 @@ ENDMENUITEMS if ($addremote) { #SD START (work in progress!) + Apache::lonhtmlcommon::clear_breadcrumb_tools(); # Arrows for navigation Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[21] ); Apache::lonhtmlcommon::add_breadcrumb_tool( 'A', $inlineremote[23] ); @@ -905,11 +958,11 @@ ENDMENUITEMS $timesync $breadcrumb - - - + + + $newmail - + @@ -1323,36 +1376,65 @@ sub openmenu { } sub inlinemenu { + my ($context,$switcher) = @_; undef(@inlineremote); undef(%category_members); -# 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.='
    '; - 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.=''; + my $output; + if ($context eq 'gcicustom') { + my $createtext = &mt('Create Concept Test'); + if ($switcher) { + $createtext = &mt('Create New Test'); + } + $output=''. + ''; + if (($env{'request.course.id'}) && + (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + $output.= ''; + } + $output.='
    '. + '
    '. + '

    '.&mt('Utilities').'

    '. + ''; + if ($switcher) { + $output .= ''; + } + $output .= '
    choose role'.$createtext.'
    choose role'.$switcher.'
    communication'.&mt('Send/Display Messages').'
    '. + '
    '. + '

    '.&mt('Test Management').'

    '. + ''."\n". + ''."\n". + ''."\n". + '
    course contentsConcept Test Contents
    assemble testAssemble Concept Test
    user privs'.&mt('Manage Enrollment').'
    what is new'.&mt("What's New?").'
    '; + } 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.=""; + } + $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; } @@ -1452,15 +1534,31 @@ sub rawconfig { } } elsif ($pro =~ /^courseenv_(.*)$/) { my $key = $1; - if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) && - ($crstype ne 'Community')) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + if ($crstype ne 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } } elsif ($pro =~ /^communityenv_(.*)$/) { my $key = $1; - if (($env{'course.'.$env{'request.course.id'}.'.'.$key}) && - ($crstype eq 'Community')) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + if ($crstype eq 'Community') { + my $coursepref = $env{'course.'.$env{'request.course.id'}.'.'.$key}; + if ($key eq 'canuse_pdfforms') { + if ($env{'request.course.id'} && $coursepref eq '') { + my %domdefs = &Apache::lonnet::get_domain_defaults($env{'course.'.$env{'request.course.id'}.'.domain'}); + $coursepref = $domdefs{'canuse_pdfforms'}; + } + } + if ($coursepref) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); + } } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course @@ -1605,12 +1703,77 @@ function gonav(url) { NAVCONTROL } +sub dc_popup_js { + my %lt = &Apache::lonlocal::texthash( + more => '(More ...)', + less => '(Less ...)', + ); + return <<"END"; + +function showCourseID() { + document.getElementById('dccid').style.display='block'; + document.getElementById('dccid').style.textAlign='left'; + document.getElementById('dccid').style.textFace='normal'; + document.getElementById('dccidtext').innerHTML ='$lt{'less'}'; + return; +} + +function hideCourseID() { + document.getElementById('dccid').style.display='none'; + document.getElementById('dccidtext').innerHTML ='$lt{'more'}'; + return; +} + +END + +} + sub utilityfunctions { - my $caller = shift; + my ($caller,$custommenu) = @_; unless ($env{'environment.remote'} eq 'off' || $caller eq '/adm/menu') { return ''; } - + + my $gcimenujs; + if ($custommenu) { + my %concepttests = &Apache::loncommon::existing_gcitest_courses(); + 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'; + } + 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'}) { @@ -1622,6 +1785,13 @@ sub utilityfunctions { my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); my $nav_control=&nav_control_js(); + my $dc_popup_cid; + if ($env{'user.adv'} && exists($env{'user.role.dc./'. + $env{'course.'.$env{'request.course.id'}. + '.domain'}.'/'})) { + $dc_popup_cid = &dc_popup_js(); + } + my $start_page_annotate = &Apache::loncommon::start_page('Annotator',undef, {'only_body' => 1, @@ -1649,6 +1819,9 @@ return (<