[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm

raeburn raeburn at source.lon-capa.org
Thu Dec 27 00:28:33 EST 2012


raeburn		Thu Dec 27 05:28:33 2012 EDT

  Modified files:              
    /loncom/interface	lonmenu.pm 
  Log:
  - Wording change for "Switch course role" item in secondary menu.
  - Exclude current role from list of roles, unless role has multiple sections.
  - Include symb in role switcher form as destsymb element, if available. 
  
  
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.401 loncom/interface/lonmenu.pm:1.402
--- loncom/interface/lonmenu.pm:1.401	Thu Dec 27 00:24:45 2012
+++ loncom/interface/lonmenu.pm	Thu Dec 27 05:28:33 2012
@@ -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 @@
         }
     }
     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 @@
             &HTML::Entities::encode($destinationurl).'" />'."\n".
             '  <input type="hidden" name="gotorole" value="1" />'."\n".
             '  <input type="hidden" name="selectrole" value="" />'."\n".
-            '  <input type="hidden" name="switchrole" value="" />'."\n".
-            '</form>'."\n";
+            '  <input type="hidden" name="switchrole" value="" />'."\n";
+        if ($destsymb ne '') {
+            $form .= '  <input type="hidden" name="destsymb" value="'.
+                        &HTML::Entities::encode($destsymb).'" />'."\n";
+        }
+        $form .= '</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) {




More information about the LON-CAPA-cvs mailing list