[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface loncommon.pm lonmenu.pm

raeburn raeburn@source.lon-capa.org
Mon, 07 Dec 2009 20:04:19 -0000


This is a MIME encoded message

--raeburn1260216259
Content-Type: text/plain

raeburn		Mon Dec  7 20:04:19 2009 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	lonmenu.pm loncommon.pm 
  Log:
  - Customization for GCI_3
    - secondary_menu() replaced with custom tabbed interface for GCI contributors
      in gci domain and CCs of Concept Tests in gcitest domain.
  
  
--raeburn1260216259
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091207200419.txt"

Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.309 loncom/interface/lonmenu.pm:1.309.2.1
--- loncom/interface/lonmenu.pm:1.309	Thu Dec  3 14:27:16 2009
+++ loncom/interface/lonmenu.pm	Mon Dec  7 20:04:18 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines to control the menu
 #
-# $Id: lonmenu.pm,v 1.309 2009/12/03 14:27:16 bisitz Exp $
+# $Id: lonmenu.pm,v 1.309.2.1 2009/12/07 20:04:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -160,6 +160,7 @@
 # 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 @@
         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,53 @@
     return "<ul id=\"LC_secondary_menu\">$menu</ul>";
 }
 
+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 .= ' <li id="current"><a href="'.$links{$item}.'">'.
+                     $linktext{$item}.'</a></li>';
+        } else {
+            $tabs .= ' <li><a href="'.$links{$item}.'">'.
+                     $linktext{$item}.'</a></li>';
+        }
+    }
+    return '<div id="gciheader">'.
+           '<ul>'.$tabs.'</ul></div><br />';
+}
 
 #
 # This routine returns a translated hash for the menu items in the top inline menu row
@@ -1332,36 +1384,58 @@
 }
 
 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='<table><tr>';
-    for (my $col=1; $col<=2; $col++) {
-        $output.='<td class="LC_mainmenu_col_fieldset">';
-        for (my $row=1; $row<=8; $row++) {
-            foreach my $cat (keys(%category_members)) {
-               if ($category_positions{$cat} ne "$col,$row") { next; }
-               #$output.='<table><tr><td colspan="4" class="LC_menubuttons_category">'.&mt($category_names{$cat}).'</td></tr>';
-               $output.='<div class="LC_Box LC_400Box">';
-	       $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
-               $output.='<table>';
-               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.='</table>';
-               $output.='</div>';
+    my $output;
+    if ($context eq 'gcicustom') {
+        $output.='<div class="LC_left_float">'.
+                 '<fieldset id="LC_mainmenu_fieldset">'.
+                 '<legend class="LC_mainmenu_fieldset_category">'.&mt('Utilities').'</legend>'.
+                '<table id="LC_menubuttons_mainmenu">';
+        if ($switcher) {
+            $output .= '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:courseswitcher('."'icon'".');"><img alt="choose role" src="/res/adm/pages/roles.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><span class="LC_menubuttons_inline_text">'.$switcher.'</span></td></tr>';
+        }
+        $output .= '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/communicate'".');"><img alt="communication" src="/res/adm/pages/com.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/communicate'".');"><span class="LC_menubuttons_inline_text">'.&mt('Send and display messages').'</span></a></td></tr></table></fieldset></div>';
+        if (($env{'request.course.id'}) &&
+            (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) {
+            $output.= '<div class="LC_left_float">'.
+                '<fieldset id="LC_mainmenu_fieldset">'.
+                '<legend class="LC_mainmenu_fieldset_category">'.&mt('Test Management').'</legend>'.
+                '<table id="LC_menubuttons_mainmenu">'.
+                '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/createuser'".');"><img alt="user privs" src="/res/adm/pages/cprv.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/createuser'".');"><span class="LC_menubuttons_inline_text">'.&mt('Manage Enrollment').'</span></a></td></tr>'."\n".
+                '<tr><td class="LC_menubuttons_img" align="left"><a href="javascript:go('."'/adm/whatsnew'".');"><img alt="what is new" src="/res/adm/pages/new.png" align="left" /></a></td><td class="LC_menubuttons_text" colspan="3"><a class="LC_menubuttons_link" href="javascript:go('."'/adm/whatsnew'".');"><span class="LC_menubuttons_inline_text">'.&mt("What's New?").'</span></a></td></tr></table></fieldset></div>';
+        }
+        $output.='<br clear="all />';
+    } else 
+        # calling rawconfig with "1" will evaluate mydesk.tab, 
+        # even if there is no active remote control
+        &rawconfig(1);
+        my $output='<table><tr>';
+        for (my $col=1; $col<=2; $col++) {
+            $output.='<td class="LC_mainmenu_col_fieldset">';
+            for (my $row=1; $row<=8; $row++) {
+                foreach my $cat (keys(%category_members)) {
+                    if ($category_positions{$cat} ne "$col,$row") { next; }
+                    $output.='<div class="LC_Box LC_400Box">';
+	            $output.='<h3 class="LC_hcell">'.&mt($category_names{$cat}).'</h3>';
+                    $output.='<table>';
+                    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.='</table>';
+                    $output.='</div>';
             }
-         }
-         $output.="</td>";
+            $output.="</td>";
+        }
+        $output.="</tr></table>";
     }
-    $output.="</tr></table>";
     return $output;
 }
 
@@ -1656,11 +1730,51 @@
 }
 
 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'}) {
@@ -1708,6 +1822,8 @@
 $nav_control
 $dc_popup_cid
 
+$gcimenujs
+
 function go(url) {
    if (url!='' && url!= null) {
        currentURL = null;
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.925.2.1 loncom/interface/loncommon.pm:1.925.2.2
--- loncom/interface/loncommon.pm:1.925.2.1	Mon Dec  7 17:11:49 2009
+++ loncom/interface/loncommon.pm	Mon Dec  7 20:04:18 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.925.2.1 2009/12/07 17:11:49 raeburn Exp $
+# $Id: loncommon.pm,v 1.925.2.2 2009/12/07 20:04:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4527,6 +4527,7 @@
         if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { 
             return $bodytag; 
         } 
+        my $custommenu = &needs_gci_custom(); 
 
         if ($env{'request.state'} eq 'construct') { $forcereg=1; }
 
@@ -4548,7 +4549,7 @@
         $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>|;
 
         $bodytag .= Apache::lonhtmlcommon::scripttag(
-            Apache::lonmenu::utilityfunctions(), 'start');
+            Apache::lonmenu::utilityfunctions('',$custommenu), 'start');
 
         $bodytag .= Apache::lonmenu::primary_menu();
 
@@ -4559,7 +4560,11 @@
 
         #don't show menus for public users
         if($env{'user.name'} ne 'public' && $env{'user.domain'} ne 'public'){
-            $bodytag .= Apache::lonmenu::secondary_menu();
+            if ($custommenu) {
+                $bodytag .= &Apache::lonmenu::gci_secondary_menu();
+            } else { 
+                $bodytag .= Apache::lonmenu::secondary_menu();
+            }
             $bodytag .= Apache::lonmenu::serverform();
             $bodytag .= Apache::lonhtmlcommon::scripttag('', 'end');
             if ($env{'request.state'} eq 'construct') {

--raeburn1260216259--