--- loncom/interface/lonmenu.pm 2010/05/24 12:20:16 1.244.2.17 +++ loncom/interface/lonmenu.pm 2008/12/08 23:07:03 1.248 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.17 2010/05/24 12:20:16 raeburn Exp $ +# $Id: lonmenu.pm,v 1.248 2008/12/08 23:07:03 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -120,6 +120,11 @@ The javascript is usually similar to "go =item get_nav_status() +=item convert_menu_function() + +FIXME this needs to move into mydesktab and the other locations +the text is generated + =item hidden_button_check() =item roles_selector() @@ -139,7 +144,6 @@ use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); -use HTML::Entities(); use vars qw(@desklines %category_names %category_members %category_positions $readdesk); @@ -163,23 +167,19 @@ sub show_course { } sub initlittle { - my %lt=&Apache::lonlocal::texthash('ret' => 'Return to Last Location', - 'nav' => 'Course Contents', + return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', + 'nav' => 'Navigate Contents', 'main' => 'Main Menu', - 'roles' => (&Apache::loncommon::show_course()? + 'roles' => (&show_course()? 'Courses':'Roles'), 'other' => 'Other Roles', - 'docs' => 'Course Editor', - 'exit' => 'Logout', + 'docs' => 'Edit Course', + 'exit' => 'Exit', 'login' => 'Log In', 'launch' => 'Launch Remote Control', 'groups' => 'Groups', + 'gdoc' => 'Group Documents', ); - if (&Apache::loncommon::course_type() eq 'Community') { - $lt{'nav'} = &mt('Community Contents'); - $lt{'docs'} = &mt('Community Editor'); - } - return %lt; } sub menubuttons { @@ -207,7 +207,7 @@ sub menubuttons { my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); $logo = 'LON-CAPA Logo'; + $logo.'" alt="LON-CAPA Logo" class="noBorder" />'; if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { @@ -246,8 +246,8 @@ ENDNAV $lt{'ret'} ENDRELOAD } - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $docs=(<$lt{'docs'} ENDDOCS } @@ -299,7 +299,6 @@ ENDMAINMENU - ENDINLINEMENU } $roles = ''.$lt{'roles'}.''; @@ -313,9 +312,11 @@ ENDINLINEMENU $navmaps=(<$lt{'nav'} ENDNAV + my $is_group = (&Apache::loncommon::course_type() eq 'Group'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { + my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$lt{'docs'} +$text ENDDOCS } if ($showgroups) { @@ -349,8 +350,8 @@ ENDCRELOAD my $helplink=&Apache::loncommon::top_nav_help('Help'); return (< -// @@ -363,8 +364,8 @@ $navmaps $docs $groups $roles -$helplink -$lt{'exit'} +$helplink +$lt{'exit'} $form @@ -407,9 +408,7 @@ sub registerurl { &unescape($env{'request.noversionuri'})))) && (!$forcereg))) { return $result. - ''.$force_title; + ''.$force_title; } # Graphical display after login only if ($env{'request.registered'} && !$forcereg) { return ''; } @@ -493,7 +492,7 @@ sub innerregister { if ($env{'request.symb'} ne '' && $env{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form|task)$/) { if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_4]', + $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', "gocmd('/adm/grades','gradingmenu')", 'Modify user grades for this assessment resource'); } elsif (&Apache::lonnet::allowed('vgr',$crs)) { @@ -514,12 +513,6 @@ sub innerregister { ### resource ### my $editbutton = ''; - my $noeditbutton = 1; - my ($cnum,$cdom); - if ($env{'request.course.id'}) { - $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - } if ($env{'user.author'}) { if ($env{'request.role'}=~/^(aa|ca|au)/) { # Set defaults for authors @@ -547,7 +540,6 @@ sub innerregister { foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { $editbutton=&switch('','',6,1,$top,,$bottom,$action,$desc); - $noeditbutton = 0; } } ## @@ -556,7 +548,6 @@ sub innerregister { my $cfile=''; my $cfuname=''; my $cfudom=''; - my $uploaded; if ($env{'request.filename'}) { my $file=&Apache::lonnet::declutter($env{'request.filename'}); $file=~s/^($match_domain)\/($match_username)/\/priv\/$2/; @@ -574,42 +565,13 @@ sub innerregister { } # Finally, turn the button on or off if ($cfile && !$const_space) { - 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]', + $editbutton=&switch + ('','',6,1,'pcstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); - $noeditbutton = 0; - } } elsif ($editbutton eq '') { $editbutton=&clear(6,1); } } - if (($noeditbutton) && ($env{'request.filename'})) { - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - my $file=&Apache::lonnet::declutter($env{'request.filename'}); - if (defined($cnum) && defined($cdom)) { - if (&is_course_upload($file,$cnum,$cdom)) { - my $cfile = &edit_course_upload($file,$cnum,$cdom); - if ($cfile) { - $editbutton=&switch - ('','',6,1,'pcstr.gif','edit[_1]', - 'resource[_2]',"go('".$cfile."');", - 'Edit this resource'); - } - } - } - } - } ### ### # Prepare the rest of the buttons @@ -627,7 +589,7 @@ sub innerregister { $menuitems=(< 0){ $menuitems.="&anno-[_1]&tations[_1]&annotate()&"; $menuitems.="Make notes and annotations about this resource&&1\n"; - unless ($noremote) { - my $showreqcrs = &check_for_rcrs(); - if ($showreqcrs) { - $menuitems.="s&8&1&rcrs.gif&request[_1]&course[_16]". - "&go('/adm/requestcourse')&Course requests\n"; - } - } unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { - if ((!$env{'request.enc'}) && ($env{'request.noversionuri'} !~ m{^/adm/wrapper/ext/})) { + if (!$env{'request.enc'}) { $menuitems.=(< -// ENDREGTHIS } @@ -821,7 +774,6 @@ ENDDONOTREGTEXT $result = (< -// ENDDONOTREGTHIS } @@ -855,42 +806,6 @@ ENDDONOTREGTHIS return $result; } -sub is_course_upload { - my ($file,$cnum,$cdom) = @_; - my $uploadpath = &LONCAPA::propath($cdom,$cnum); - $uploadpath =~ s{^\/}{}; - if (($file =~ m{^\Q$uploadpath\E/userfiles/docs/}) || - ($file =~ m{^userfiles/\Q$cdom\E/\Q$cnum\E/docs/})) { - return 1; - } - return; -} - -sub edit_course_upload { - my ($file,$cnum,$cdom) = @_; - my $cfile; - if ($file =~/\.(htm|html|css|js|txt)$/) { - my $ext = $1; - my $url = &Apache::lonnet::hreflocation('',$file); - my $home = &Apache::lonnet::homeserver($cnum,$cdom); - my @ids=&Apache::lonnet::current_machine_ids(); - my $dest; - if ($home && grep(/^\Q$home\E$/,@ids)) { - $dest = $url.'?forceedit=1'; - } else { - unless (&Apache::lonnet::get_locks()) { - $dest = '/adm/switchserver?otherserver='. - $home.'&role='.$env{'request.role'}. - '&url='.$url.'&forceedit=1'; - } - } - if ($dest) { - $cfile = &HTML::Entities::encode($dest,'"<>&'); - } - } - return $cfile; -} - sub loadevents() { if ($env{'request.state'} eq 'construct' || $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } @@ -918,7 +833,6 @@ sub startupremote { my $message=&mt('"Waiting for Remote Control window to load: "+[_1]','waited'); return(< -// + ENDREMOTESTARTUP } @@ -976,10 +890,8 @@ ENDREMOTESTARTUP sub setflags() { return(< -// ENDSETFLAGS } @@ -989,9 +901,7 @@ sub maincall() { ($env{'environment.remote'} eq 'off')) { return ''; } return(< -// ENDMAINCALL } @@ -1003,9 +913,8 @@ sub load_remote_msg { ($env{'environment.remote'} eq 'off')) { return ''; } my $esclowerurl=&escape($lowerurl); - my $link=&mt('[_1]Continue[_2] on in Inline Menu mode', - '', - ''); + my $link=&mt('Continue on in Inline Menu mode', + "/adm/remote?action=collapse&url=$esclowerurl"); return(<
@@ -1036,12 +945,7 @@ sub open { my $returnval=''; if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { - return - ''; + return ''; } my $menuname = &get_menu_name(); @@ -1054,13 +958,11 @@ sub open { #} #ENDRESIZE # } - $returnval=(< ENDOPEN return ''; } @@ -1125,22 +1027,22 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="noBorder" />'; if ($env{'browser.interface'} eq 'faketextual') { # Accessibility if ($nobreak==3) { $inlineremote[$idx]="\n". ''.$text. - ''. + ''. ''.$pic.''; } elsif ($nobreak) { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic.' '.$text.''; } else { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic. ''. ''.$desc.''; @@ -1191,10 +1093,10 @@ sub inlinemenu { 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}).'
'; + #$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]) { @@ -1205,7 +1107,7 @@ sub inlinemenu { $output.=$inlineremote[$item]; } $output.='
'; - $output.=''; + $output.=''; } } $output.=""; @@ -1228,17 +1130,15 @@ sub rawconfig { my $uname=$env{'user.name'}; my $udom=$env{'user.domain'}; my $adv=$env{'user.adv'}; - my $show_course=&Apache::loncommon::show_course(); + my $show_course=&show_course(); my $author=$env{'user.author'}; my $crs=''; - my $crstype=''; if ($env{'request.course.id'}) { $crs='/'.$env{'request.course.id'}; if ($env{'request.course.sec'}) { $crs.='_'.$env{'request.course.sec'}; } $crs=~s/\_/\//g; - $crstype = &Apache::loncommon::course_type(); } my $pub=($env{'request.state'} eq 'published'); my $con=($env{'request.state'} eq 'construct'); @@ -1248,17 +1148,13 @@ sub rawconfig { my ($row,$col,$pro,$prt,$img,$top,$bot,$act,$desc,$cat)=split(/\:/,$line); $prt=~s/\$uname/$uname/g; $prt=~s/\$udom/$udom/g; - if ($prt =~ /\$crs/) { - next unless ($env{'request.course.id'}); - next if ($crstype eq 'Community'); - $prt=~s/\$crs/$crs/g; - } elsif ($prt =~ /\$cmty/) { - next unless ($env{'request.course.id'}); - next if ($crstype ne 'Community'); - $prt=~s/\$cmty/$crs/g; - } + $prt=~s/\$crs/$crs/g; $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } + my $type = &Apache::loncommon::course_type(); + if ($type eq 'Group') { + $desc = &convert_menu_function($desc,$type); + } if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1285,69 +1181,26 @@ sub rawconfig { $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); } } elsif (($pro=~/^p(\w+)/) && ($prt)) { - my $priv = $1; - if ($priv =~ /^mdc(Course|Community)/) { - if ($crstype eq $1) { - $priv = 'mdc'; - } else { - next; - } - } - if (&Apache::lonnet::allowed($priv,$prt)) { + if (&Apache::lonnet::allowed($1,$prt)) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } - } elsif ($pro eq 'course') { - if (($env{'request.course.fn'}) && ($crstype ne 'Community')) { + } elsif ($pro eq 'course') { + if ($env{'request.course.fn'}) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); - } - } elsif ($pro eq 'community') { - if (($env{'request.course.fn'}) && ($crstype eq 'Community')) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); - } + } } elsif ($pro =~ /^courseenv_(.*)$/) { my $key = $1; - 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 ($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); - } + if ($env{'course.'.$env{'request.course.id'}.'.'.$key}) { + $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); } } elsif ($pro =~ /^course_(.*)$/) { # Check for permissions inside of a course - if (($env{'request.course.id'}) && ($crstype ne 'Community') && - (&Apache::lonnet::allowed($1,$env{'request.course.id'}. - ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) - )) { - $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); - } - } elsif ($pro =~ /^community_(.*)$/) { - # Check for permissions inside of a community - if (($env{'request.course.id'}) && ($crstype eq 'Community') && + if (($env{'request.course.id'}) && (&Apache::lonnet::allowed($1,$env{'request.course.id'}. ($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:'')) )) { $output.=&switch($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$cat); - } + } } elsif ($pro eq 'author') { if ($author) { if ((($prt eq 'rca') && ($env{'request.role'}=~/^ca/)) || @@ -1374,21 +1227,8 @@ sub rawconfig { } elsif ($pro eq 'tools') { my @tools = ('aboutme','blog','portfolio'); if (grep(/^\Q$prt\E$/,@tools)) { - if (!&Apache::lonnet::usertools_access($env{'user.name'}, - $env{'user.domain'}, - $prt,undef,'tools')) { - $output.=&clear($row,$col); - next; - } - } elsif (($prt eq 'reqcrsnsc') || ($prt eq 'reqcrsshc')) { - if (($prt eq 'reqcrsnsc') && ($show_course)) { - next; - } - if (($prt eq 'reqcrsshc') && (!$show_course)) { - next; - } - my $showreqcrs = &check_for_rcrs(); - if (!$showreqcrs) { + if (defined($env{'environment.tools.'.$prt}) && + ($env{'environment.tools.'.$prt} == 0)) { $output.=&clear($row,$col); next; } @@ -1396,7 +1236,6 @@ sub rawconfig { $prt='any'; $output.=&secondlevel( $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); - } } unless (($env{'browser.interface'} eq 'textual') || @@ -1410,28 +1249,6 @@ sub rawconfig { return $output; } -sub check_for_rcrs { - my $showreqcrs = 0; - my @reqtypes = ('official','unofficial','community'); - foreach my $type (@reqtypes) { - if (&Apache::lonnet::usertools_access($env{'user.name'}, - $env{'user.domain'}, - $type,undef,'requestcourses')) { - $showreqcrs = 1; - last; - } - } - if (!$showreqcrs) { - foreach my $type (@reqtypes) { - if ($env{'environment.reqcrsotherdom.'.$type} ne '') { - $showreqcrs = 1; - last; - } - } - } - return $showreqcrs; -} - # ======================================================================= Close sub close { @@ -1440,7 +1257,6 @@ sub close { my $menuname = &get_menu_name(); return(< -// ENDCLOSE } @@ -1483,11 +1298,6 @@ sub utilityfunctions { unless (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; } my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); - if ($currenturl =~ m{^/adm/wrapper/ext/}) { - if ($env{'request.external.querystring'}) { - $currenturl .= ($currenturl=~/\?/)?'&':'?'.$env{'request.external.querystring'}; - } - } $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); @@ -1642,16 +1452,16 @@ function set_bookmark() { bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); bmquery.document.write( '$start_page_bookmark' - +'
' - +'
Link Name:
' - +'
Address:

' + +"
\\n
Link Name:
" + +"
Address:

<\\/center><\\/td>" + +"<\\/tr><\\/table><\\/form><\\/center>" +'$end_page_bookmark' ); bmquery.document.close(); } @@ -1699,6 +1509,19 @@ sub get_nav_status { return $navstatus; } +#FIXME this needs to move into mydesktab and the other locations +# the text is generated +sub convert_menu_function { + my ($rolename,$type) = @_; + if ($type eq 'Group') { + $rolename =~ s/student/member/g; + $rolename =~ s/group/team/g; + $rolename =~ s/course/group/g; + $rolename =~ s/Course/Group/g; + } + return $rolename; +} + sub hidden_button_check { my $hidden; if ($env{'request.course.id'} eq '') { @@ -1713,19 +1536,13 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; - my $crstype = &Apache::loncommon::course_type(); my $now = time; - my (%courseroles,%seccount); + my (%courseroles,%seccount,%gotnosection); my $is_cc; my $role_selector; - my $ccrole; - if ($crstype eq 'Community') { - $ccrole = 'co'; - } else { - $ccrole = 'cc'; - } - if ($env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}) { - my ($start,$end) = split(/\./,$env{'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum}); + if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { + my ($start,$end) = split(/\./,$env{'user.role.cc./'.$cdom.'/'.$cnum}); + if ((($start) && ($start<0)) || (($end) && ($end<$now)) || (($start) && ($now<$start))) { @@ -1735,9 +1552,35 @@ sub roles_selector { } } if ($is_cc) { - &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount); + my %adv_roles = + &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); + foreach my $role (keys(%adv_roles)) { + my ($urole,$usec) = split(/:/,$role); + if (!$gotnosection{$urole}) { + $seccount{$urole} ++; + $gotnosection{$urole} = 1; + } + if (ref($courseroles{$urole}) eq 'ARRAY') { + if ($usec ne '') { + if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) { + push(@{$courseroles{$urole}},$usec); + $seccount{$urole} ++; + } + } + } else { + @{$courseroles{$urole}} = (); + if ($usec ne '') { + $seccount{$urole} ++; + push(@{$courseroles{$urole}},$usec); + } + } + } + my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); + @{$courseroles{'st'}} = (); + if (keys(%sections_count) > 0) { + push(@{$courseroles{'st'}},keys(%sections_count)); + } } else { - my %gotnosection; foreach my $item (keys(%env)) { if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; @@ -1768,22 +1611,15 @@ sub roles_selector { } } } - my $switchtext; - if ($crstype eq 'Community') { - $switchtext = &mt('Switch community role to...') - } else { - $switchtext = &mt('Switch course role to...') - } - - my @roles_order = ($ccrole,'in','ta','ep','ad','st'); + my @roles_order = ('cc','in','ta','ep','ad','st'); if (keys(%courseroles) > 1) { $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= ' '."\n". '&').'" />'."\n". + $ENV{'REQUEST_URI'}.'" />'."\n". ''."\n". ''."\n". ''."\n". @@ -1802,61 +1638,6 @@ sub roles_selector { return $role_selector; } -sub get_all_courseroles { - my ($cdom,$cnum,$courseroles,$seccount) = @_; - unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) { - return; - } - my ($result,$cached) = - &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum); - if (defined($cached)) { - if (ref($result) eq 'HASH') { - if ((ref($result->{'roles'}) eq 'HASH') && - (ref($result->{'seccount'}) eq 'HASH')) { - %{$courseroles} = %{$result->{'roles'}}; - %{$seccount} = %{$result->{'seccount'}}; - return; - } - } - } - my %gotnosection; - my %adv_roles = - &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); - foreach my $role (keys(%adv_roles)) { - my ($urole,$usec) = split(/:/,$role); - if (!$gotnosection{$urole}) { - $seccount->{$urole} ++; - $gotnosection{$urole} = 1; - } - if (ref($courseroles->{$urole}) eq 'ARRAY') { - if ($usec ne '') { - if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) { - push(@{$courseroles->{$urole}},$usec); - $seccount->{$urole} ++; - } - } - } else { - @{$courseroles->{$urole}} = (); - if ($usec ne '') { - $seccount->{$urole} ++; - push(@{$courseroles->{$urole}},$usec); - } - } - } - my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']); - @{$courseroles->{'st'}} = (); - if (keys(%sections_count) > 0) { - push(@{$courseroles->{'st'}},keys(%sections_count)); - $seccount->{'st'} = scalar(keys(%sections_count)); - } - my $rolehash = { - 'roles' => $courseroles, - 'seccount' => $seccount, - }; - &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash); - return; -} - sub jump_to_role { my ($cdom,$cnum,$seccount,$courseroles) = @_; my %lt = &Apache::lonlocal::texthash( @@ -1888,9 +1669,8 @@ sub jump_to_role { ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; } } - return <<"END"; + my $output = <<"END"; END + return $output; }