--- loncom/interface/lonmenu.pm 2012/12/27 00:24:45 1.401
+++ loncom/interface/lonmenu.pm 2012/12/27 05:28:33 1.402
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.401 2012/12/27 00:24:45 raeburn Exp $
+# $Id: lonmenu.pm,v 1.402 2012/12/27 05:28:33 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1663,12 +1663,18 @@ sub roles_selector {
}
}
if ($crstype eq 'Community') {
- $switchtext = &mt('Switch community role to...')
+ $switchtext = &mt('Switch community role')
} else {
- $switchtext = &mt('Switch course role to...')
+ $switchtext = &mt('Switch course role')
}
my @roles_order = ($ccrole,'in','ta','ep','ad','st');
- if (keys(%courseroles) > 1) {
+ my $numdiffsec;
+ if (keys(%seccount) == 1) {
+ foreach my $key (keys(%seccount)) {
+ $numdiffsec = $seccount{$key};
+ }
+ }
+ if ((keys(%seccount) > 1) || ($numdiffsec > 1)) {
my @submenu;
$js = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles,\%courseprivs,$priv);
$form =
@@ -1677,19 +1683,42 @@ sub roles_selector {
&HTML::Entities::encode($destinationurl).'" />'."\n".
' '."\n".
' '."\n".
- ' '."\n".
- ''."\n";
+ ' '."\n";
+ if ($destsymb ne '') {
+ $form .= ' '."\n";
+ }
+ $form .= ''."\n";
foreach my $role (@roles_order) {
+ my $include;
if (defined($courseroles{$role})) {
+ if ($env{'request.role'} =~ m{^\Q$role\E}) {
+ if ($seccount{$role} > 1) {
+ $include = 1;
+ }
+ } else {
+ $include = 1;
+ }
+ }
+ if ($include) {
push(@submenu,['javascript:adhocRole('."'$role'".')',
&Apache::lonnet::plaintext($role,$crstype)]);
}
}
foreach my $role (sort(keys(%courseroles))) {
if ($role =~ /^cr/) {
- push(@submenu,['javascript:adhocRole('."'$role'".')',
- &Apache::lonnet::plaintext($role)]);
-
+ my $include;
+ if ($env{'request.role'} =~ m{^\Q$role\E}) {
+ if ($seccount{$role} > 1) {
+ $include = 1;
+ }
+ } else {
+ $include = 1;
+ }
+ if ($include) {
+ push(@submenu,['javascript:adhocRole('."'$role'".')',
+ &Apache::lonnet::plaintext($role)]);
+ }
}
}
if (@submenu > 0) {