[LON-CAPA-cvs] cvs: loncom /interface lonmenu.pm
raeburn
raeburn@source.lon-capa.org
Tue, 07 Dec 2010 04:33:09 -0000
raeburn Mon Dec 6 23:33:09 2010 EDT
Modified files:
/loncom/interface lonmenu.pm
Log:
- Customization for GCI_3
- Tabs displayed to faculty depend on Concept Inventory in use.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.309.2.23 loncom/interface/lonmenu.pm:1.309.2.24
--- loncom/interface/lonmenu.pm:1.309.2.23 Sun Dec 5 19:44:36 2010
+++ loncom/interface/lonmenu.pm Tue Dec 7 04:33:49 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.309.2.23 2010/12/05 19:44:36 raeburn Exp $
+# $Id: lonmenu.pm,v 1.309.2.24 2010/12/07 04:33:49 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -328,8 +328,8 @@
}
my %allnums = &Apache::loncommon::get_faculty_cnums();
if (($inventory ne '') && (ref($allnums{$inventory}) eq 'HASH')) {
- foreach my $key (%{$allnums{$inventory}}) {
- $courses{$inventory.'_'.$key} = $allnums{$inventory}->{$key};
+ foreach my $key (keys(%{$allnums{$inventory}})) {
+ $courses{$key} = $inventory.'_'.$allnums{$inventory}->{$key};
}
}
@@ -339,10 +339,16 @@
'managetest' => 'Manage Tests',
'tutorial' => 'Tutorials',
);
- my %links = (
- 'managetest' => '/adm/menu',
- );
- my $current = 'managetest';
+ my (%links,@menutabs,$current,%can_request,%request_domains);
+ my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc');
+ my $canreq = &Apache::lonnet::check_can_request($env{'user.domain'}.'test',
+ \%can_request,\%request_domains);
+ if (($canreq) || (keys(%concepttests) > 0)) {
+ %links = (
+ 'managetest' => '/adm/menu',
+ );
+ $current = 'managetest';
+ }
if ($env{'form.destinationurl'} eq '/adm/ci_info') {
undef($current);
}
@@ -355,12 +361,16 @@
$links{$key} = '/adm/navmaps';
}
$current = $key;
- $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
+ if (($canreq) || (keys(%concepttests) > 0) {
+ $links{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
+ }
}
}
- my @menutabs = ('review','submit','managetest','tutorial');
+ my @posstabs = ('review','submit','managetest','tutorial');
my $tabs;
- foreach my $item (@menutabs) {
+ foreach my $item (@posstabs) {
+ next if ($links{$item} eq '');
+ push(@menutabs,$item);
if ($item eq $current) {
$tabs .= '<li id="current"><a href="'.$links{$item}.'">'.
$linktext{$item}.'</a></li>';
@@ -1899,52 +1909,54 @@
my $gcimenujs;
if ($custommenu) {
my %concepttests = &Apache::loncommon::existing_gcitest_courses('cc');
- my $managetesturl = '/adm/menu';
- my $createtesturl = '/adm/requestcourse';
+ my (@calls,%switchpage_call,%canrequest,%request_domains);
+ my $canreq = &Apache::lonnet::check_can_request($env{'user.domain'}.'test',
+ \%canrequest,\%request_domains);
+ if ($canreq) {
+ foreach my $call ('createtest','managetest') {
+ push(@calls,$call);
+ }
+ $switchpage_call{'managetest'} = '/adm/menu';
+ $switchpage_call{'createtest'} = '/adm/requestcourse';
+ if ($env{'request.course.id'}) {
+ $switchpage_call{'createtest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
+ }
+ }
if (($env{'request.course.id'}) &&
($env{'course.'.$env{'request.course.id'}.'.domain'} !~ /^\w+citest$/)) {
my @items = keys(%concepttests);
- if (@items== 1) {
+ if (@items==1) {
my $newrole = $items[0];
$newrole =~ s{_}{/};
- $managetesturl = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
+ $switchpage_call{'managetest'} = '/adm/roles?selectrole=1&cc./'.$newrole.'=1';
} else {
- $managetesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
+ $switchpage_call{'managetest'} = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2fmenu';
}
}
- if ($env{'request.course.id'}) {
- $createtesturl = '/adm/roles?selectrole=1&cm=1&orgurl=%2fadm%2frequestcourse';
- }
my %allnums = &Apache::loncommon::get_faculty_cnums();
my $udom = $env{'user.domain'};
- my %crs_by_caller;
if (ref($allnums{$udom}) eq 'HASH') {
foreach my $key (keys(%{$allnums{$udom}})) {
- $crs_by_caller{$allnums{$udom}->{$key}} = 'st./'.$udom.'/'.$key.'=1';
+ $switchpage_call{$key} = '/adm/roles?selectrole=1&'.
+ 'st./'.$udom.'/'.$allnums{$udom}->{$key}.'=1';
+ push(@calls,$key);
}
}
- $gcimenujs = <<"ENDCUSTOM";
-
+ if (@calls > 0) {
+ $gcimenujs = '
function switchpage(caller) {
- if (caller == 'review') {
- document.location.href = '/adm/roles?selectrole=1&'.$crs_by_caller{'review'};
- }
- if (caller == 'submit') {
- document.location.href = '/adm/roles?selectrole=1&'.$crs_by_caller{'submit'};
- }
- if (caller == 'createtest') {
- document.location.href = '$createtesturl';
- }
- if (caller == 'managetest') {
- document.location.href = '$managetesturl';
- }
- if (caller == 'tutorial') {
- document.location.href = '/adm/roles?selectrole=1&'.$crs_by_caller{'tutorial'};
- }
+';
+ foreach my $call (@calls) {
+ $gcimenujs .= "
+ if (caller == '$call') {
+ document.location.href = '$switchpage_call{$call}';
+ }";
+ }
+ $gcimenujs .= '
return;
}
-
-ENDCUSTOM
+';
+ }
}
my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0]));