--- loncom/interface/lonmenu.pm 2009/10/30 00:19:49 1.298 +++ loncom/interface/lonmenu.pm 2009/12/07 21:48:37 1.309.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.298 2009/10/30 00:19:49 raeburn Exp $ +# $Id: lonmenu.pm,v 1.309.2.2 2009/12/07 21:48:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -150,7 +150,7 @@ sub prep_menuitem { } else { # textual Link $link = &mt($$menuitem[3]); } - return '
  • '.$link.'
  • '; + return '
  • '.$link.'
  • '; } # primary_menu() evaluates @primary_menu and returns XHTML for the menu @@ -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 @@ -230,7 +235,7 @@ sub secondary_menu { next if $$menuitem[4] =~ /^(no|)remotenavCommunity$/ && $crstype ne 'Community'; next if $$menuitem[4] =~ /showgroups$/ - && $canviewgrps + && !$canviewgrps && !%groups; if ($$menuitem[3] eq 'Roles' && $env{'request.course.id'}) { @@ -277,6 +282,53 @@ sub secondary_menu { return ""; } +sub gci_secondary_menu { + my %courses = ( + 'review' => 'gci_9615072b469884921gcil1', + 'submit' => 'gci_1H96711d710194bfegcil1', + ); + my %linktext = ( + 'review' => 'Review Questions', + 'submit' => 'Submit Questions', + 'createtest' => 'Create a Test', + ); + my (%links,$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{'createtest'} = "javascript:switchpage('createtest');"; + if (($ENV{'REQUEST_URI'} eq '/adm/requestcourse') || + ($env{'form.orgurl'} eq '/adm/requestcourse')) { + $current = 'createtest'; + } + my @menutabs = ('review','submit','createtest'); + if ($env{'user.adv'}) { + my $key = 'managetest'; + push(@menutabs,$key); + $linktext{$key} = 'Manage Tests'; + $links{$key} = "javascript:switchpage('$key');"; + if (($current eq '') && (($ENV{'REQUEST_URI'} eq '/adm/menu') || + ($env{'form.orgurl'} eq '/adm/menu'))) { + $current = $key; + } + } + 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 +564,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'); @@ -545,7 +597,13 @@ sub innerregister { my $maptitle = &Apache::lonnet::gettitle($mapurl); my $restitle = &Apache::lonnet::gettitle(&Apache::lonnet::symbread()); - my @crumbs = ({text => "Course Contents", + my $contentstext; + if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Community') { + $contentstext = &mt('Community Contents'); + } else { + $contentstext = &mt('Course Contents'); + } + my @crumbs = ({text => $contentstext, href => "Javascript:gonav('/adm/navmaps')"}); if ($mapurl ne $env{'course.'.$env{'request.course.id'}.'.url'}) { @@ -561,7 +619,7 @@ sub innerregister { &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb(@crumbs); - $breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); + #$breadcrumb .= &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); unless (($env{'request.state'} eq 'edit') || ($newmail) || ($env{'request.state'} eq 'construct') || ($env{'form.register'})) { @@ -683,10 +741,22 @@ sub innerregister { } # Finally, turn the button on or off if ($cfile && !$const_space) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', + my $nocrsedit; + # Suppress display where CC has switched to student role. + if ($env{'request.course.id'}) { + unless(&Apache::lonnet::allowed('mdc', + $env{'request.course.id'})) { + $nocrsedit = 1; + } + } + if ($nocrsedit) { + $editbutton=&clear(6,1); + } else { + $editbutton=&switch + ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; + $noeditbutton = 0; + } } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } @@ -735,6 +805,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 '' ) { # @@ -811,51 +889,88 @@ ENDMENUITEMS my $addremote=0; foreach (@inlineremote) { if ($_ ne '') { $addremote=1; last;} } my $inlinebuttons=''; - if ($addremote) { - # Registered, textual output - if ($env{'environment.icons'} eq 'iconsonly') { - $inlinebuttons=(< -$inlineremote[21] $inlineremote[23] -ENDARROWSINLINE - if (&hidden_button_check() ne 'yes') { - $inlinebuttons .= (< -ENDINLINEICONS - } - } else { - if ($inlineremote[21] ne '' || $inlineremote[23] ne '') { - $inlinebuttons=(<$inlineremote[21] $inlineremote[23] -ENDFIRSTLINE - } - if (&hidden_button_check() ne 'yes') { - foreach my $row (6..9) { - if ($inlineremote[${row}.'1'] ne '' - || $inlineremote[$row.'2'] ne '' - || $inlineremote[$row.'3'] ne '') { - $inlinebuttons .= <<"ENDLINE"; -$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] -ENDLINE - } - } - } - } - } + 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] ); + if(hidden_button_check() ne 'yes'){ + # notes + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[93]); + # bookmark + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[91]); + # evaluate + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[81]); + # feedback + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[82]); + # print + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[83]); + # metadata + Apache::lonhtmlcommon::add_breadcrumb_tool( 'B', $inlineremote[63]); + + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[61]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[71]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[72]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[73]); + # ? + Apache::lonhtmlcommon::add_breadcrumb_tool( 'C', $inlineremote[92]); + + } + + #SD END +# # Registered, textual output +# if ( $env{'environment.icons'} eq 'iconsonly' ) { +# $inlinebuttons = (< +#$inlineremote[21] $inlineremote[23] +#ENDARROWSINLINE +# if ( &hidden_button_check() ne 'yes' ) { +# $inlinebuttons .= (< +#ENDINLINEICONS +# } +# } else { # not iconsonly +# if ( $inlineremote[21] ne '' || $inlineremote[23] ne '' ) { +# $inlinebuttons = (<$inlineremote[21] $inlineremote[23] +#ENDFIRSTLINE +# } +# if ( &hidden_button_check() ne 'yes' ) { +# foreach my $row ( 6 .. 9 ) { +# if ( $inlineremote[ ${row} . '1' ] ne '' +# || $inlineremote[ $row . '2' ] ne '' +# || $inlineremote[ $row . '3' ] ne '' ) +# { +# $inlinebuttons .= <<"ENDLINE"; +#$inlineremote["${row}1"]$inlineremote["${row}2"]$inlineremote["${row}3"] +#ENDLINE +# } +# } +# } +# } + } + #SD see below + $breadcrumb = &Apache::lonhtmlcommon::breadcrumbs(undef,undef,0); $result =(< // BEGIN LON-CAPA Internal $timesync $breadcrumb -$tablestart -$inlinebuttons -$tableend + + + $newmail -$separator + @@ -1213,7 +1328,7 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_icon" />'; if ($env{'browser.interface'} eq 'faketextual') { # Main Menu if ($nobreak==3) { @@ -1239,7 +1354,7 @@ sub switch { $inlineremote[$idx]=''.$pic.''; } else { $inlineremote[$idx]= - ''.$pic. + ''.$pic. ''.$desc.''; } } @@ -1269,36 +1384,59 @@ 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.='"; + $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.=''; + my $output; + if ($context eq 'gcicustom') { + $output ='
    '. + '
    '. + ''.&mt('Utilities').''. + ''; + if ($switcher) { + $output .= ''; + } + $output .= '
    choose role'.$switcher.'
    communication'.&mt('Send and display messages').'
    '; + if (($env{'request.course.id'}) && + (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + $output.= '
    '. + '
    '. + ''.&mt('Test Management').''. + ''. + ''."\n". + '
    user privs'.&mt('Manage Enrollment').'
    what is new'.&mt("What's New?").'
    '; + } + $output.='
    '; + $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; } @@ -1398,15 +1536,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 @@ -1551,12 +1705,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'}) { @@ -1568,6 +1787,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, @@ -1595,6 +1821,9 @@ return (<