--- loncom/auth/lonroles.pm 2010/12/05 16:35:58 1.240.2.21
+++ loncom/auth/lonroles.pm 2010/01/18 16:47:17 1.243
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.240.2.21 2010/12/05 16:35:58 raeburn Exp $
+# $Id: lonroles.pm,v 1.243 2010/01/18 16:47:17 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -165,7 +165,6 @@ sub redirect_user {
my $start_page = &Apache::loncommon::start_page('Switching Role',undef,
{'redirect' => [1,$url],
'bread_crumbs' => $brcrum,});
- &Apache::lonhtmlcommon::clear_breadcrumbs();
my $end_page = &Apache::loncommon::end_page();
# Note to style police:
@@ -226,7 +225,6 @@ sub handler {
my %dcroles = ();
my $numdc = &check_fordc(\%dcroles,$then);
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
- my $custommenu = &Apache::loncommon::needs_gci_custom();
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
@@ -321,9 +319,7 @@ sub handler {
}
}
}
- if (($env{'form.cm'}) && ($env{'form.orgurl'})) {
- $r->internal_redirect($env{'form.orgurl'});
- }
+
foreach $envkey (keys %env) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -450,16 +446,8 @@ ENDENTERKEY
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
my $msg;
- if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
- &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
my ($furl,$ferr)=
&Apache::lonuserstate::readmap($cdom.'/'.$cnum);
- if ($custommenu) {
- unless (($ferr) || ($env{'form.switchrole'})) {
- &Apache::lonnet::put('nohist_crslastlogin',{$env{'user.name'}.':'.$env{'user.domain'}.':'.$csec.':'.$role => $now},
- $cdom,$cnum);
- }
- }
if (($env{'form.orgurl'}) &&
($env{'form.orgurl'}!~/^\/adm\/flip/)) {
my $dest=$env{'form.orgurl'};
@@ -471,6 +459,8 @@ ENDENTERKEY
}
$dest .= 'symb='.$env{'form.symb'};
}
+ if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
+ &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
if (($ferr) && ($tadv)) {
&error_page($r,$ferr,$dest);
} else {
@@ -489,6 +479,8 @@ ENDENTERKEY
.'
'.&mt('Please try again.').'
'
.'
'.$ferr.'
';
}
+ if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
+ &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
if (($ferr) && ($tadv)) {
&error_page($r,$ferr,$furl);
@@ -500,7 +492,7 @@ ENDENTERKEY
$courseid = substr($courseid, 1);
}
$courseid =~ s/\//_/;
- if (($cdom !~ /^\w+citest$/) && (($role eq 'cc') || ($role eq 'co'))
+ if ((($role eq 'cc') || ($role eq 'co'))
&& ($env{'course.' . $courseid .'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
@@ -524,7 +516,7 @@ ENDENTERKEY
.$env{'request.course.sec'})
) {
my $startpage = &courseloadpage($courseid);
- unless (($startpage eq 'firstres') || ($cdom =~ /^\w+citest$/)) {
+ unless ($startpage eq 'firstres') {
$msg = &mt('Entering [_1] ...',
$env{'course.'.$courseid.'.description'});
&redirect_user($r,&mt('New in course'),
@@ -539,9 +531,6 @@ ENDENTERKEY
# Guess not ...
$furl=&Apache::lonpageflip::first_accessible_resource();
}
- if (($cdom =~ /^\w+citest$/) && ($custommenu)) {
- $furl = '/adm/navmaps';
- }
$msg = &mt('Entering [_1] ...',
$env{'course.'.$courseid.'.description'});
&redirect_user($r,&mt('Entering [_1]',
@@ -584,6 +573,7 @@ ENDENTERKEY
}
}
+
# =============================================================== No Roles Init
&Apache::loncommon::content_type($r,'text/html');
@@ -591,43 +581,25 @@ ENDENTERKEY
$r->send_http_header;
return OK if $r->header_only;
- my ($crumbtext,$pagetitle,$recent,$show_course);
- $show_course=&Apache::loncommon::show_course();
- my $noscript=' '.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').' '.&mt('As this is not the case, most functionality in the system will be unavailable.').' ';
- if ($custommenu) {
- my $start_page = &Apache::loncommon::start_page('Main Menu');
- $r->print(<<"ENDCUSTOM");
-$start_page
-
-ENDCUSTOM
- } else {
- $crumbtext = 'User Roles';
- $pagetitle = 'My Roles';
- $recent = &mt('Recent Roles');
- my $standby=&mt('Role selected. Please stand by.');
- if ($show_course) {
- $crumbtext = 'Courses';
- $pagetitle = 'My Courses';
- $recent = &mt('Recent Courses');
- $standby = &mt('Course selected. Please stand by.');
- }
- my $brcrum = [{ href => '/adm/roles',
- text => $crumbtext,},
- ];
- my $args;
- if ($numdc) {
- $args = {bread_crumbs => $brcrum};
- } else {
- $args = {bread_crumbs => $brcrum,
- bread_crumbs_menulink => '_nomenu'};
- }
- my $start_page=&Apache::loncommon::start_page($pagetitle,undef,$args);
- my $swinfo=&Apache::lonmenu::rawconfig();
- $standby=~s/\n/\\n/g;
- $r->print(<"/adm/roles",text=>$crumbtext}];
+ my $swinfo=&Apache::lonmenu::rawconfig();
+ my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
+ my $standby=&mt('Role selected. Please stand by.');
+ $standby=~s/\n/\\n/g;
+ my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').' '.&mt('As this is not the case, most functionality in the system will be unavailable.').' ';
+
+ $r->print(<
@@ -652,7 +624,6 @@ function enterrole (thisform,rolecode,bu
// ]]>
ENDHEADER
- }
# ------------------------------------------ Get Error Message from Environment
@@ -720,12 +691,10 @@ ENDHEADER
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
}
- unless ($custommenu) {
- $r->print('');
if ($countfuture) {
- if ($show_course) {
- if ($env{'user.domain'} =~ /^\w+citest$/) {
- $r->print(&mt('The following [quant,_1,Concept Test] will be available in the future:',$countfuture));
- } else {
- $r->print(&mt('The following [quant,_1,course] will become active in the future:',$countfuture));
- }
- } else {
- $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
- }
+ $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,
$nochoose);
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
@@ -848,30 +768,9 @@ ENDHEADER
}
$r->print(&Apache::loncommon::end_page());
return OK;
- } elsif ($countactive==1) { # Is there only one choice?
- my $needs_switchserver;
- if ($env{'user.author'}) {
- $needs_switchserver = &check_needs_switchserver($possiblerole);
- }
- if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) {
- $r->print('
\n".
- &mt('Construction Space access is only available from '.
- 'the home server of the corresponding Author.').' '.
- &mt("Click the 'Switch Server' link to go there.").' ');
- }
}
# ----------------------------------------------------------------------- Table
- unless ((!$show_course) || ($nochoose) || ($countactive==1)) {
+ unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
$r->print("
Welcome to the Geoscience Concept Inventory WebCenter
-
-Use the tabs to navigate the WebCenter and...
-
-
Review and comment on existing GCI questions
-
Submit GCI questions of your own
-
Create an online test for your students
-
View tutorials on creating online tests
-
-
-
For more information about writing and reviewing Concept Inventory questions
-please refer to the GCI Workbook.
-
-END
-}
-
sub gather_roles {
my ($then,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
@@ -1294,15 +1173,10 @@ sub findcourse_advice {
} else {
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').' ');
}
- my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment();
- if ($queued) {
- $r->print($queued);
- } else {
- $r->print(&mt('You have no request for contributor access pending approval by the GCI WebCenter team.').'
'.
- '
'.&mt('This may mean that action was taken on your request in the time since your most recent log-in.[_1]View [_2]Message[_3] to see if this is the case.',' ','','').'
'.
- '
'.&mt('If you logout and log-in again you may find you now have access to the Geoscience Concept Inventory, as a contributor.').'
'.
- '
');
- }
+ $r->print('
'.&mt('Self-Enrollment').'
'.
+ '
'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).' ');
+ $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.
+ &Apache::loncoursequeueadmin::queued_selfenrollment());
return;
}
@@ -1358,6 +1232,49 @@ sub requestcourse_advice {
}
return;
}
+
+sub queued_selfenrollment {
+ my ($r) = @_;
+ my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests');
+ my %reqs_by_date;
+ foreach my $item (keys(%selfenrollrequests)) {
+ if (ref($selfenrollrequests{$item}) eq 'HASH') {
+ if ($selfenrollrequests{$item}{'status'} eq 'request') {
+ if ($selfenrollrequests{$item}{'timestamp'}) {
+ push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item);
+ }
+ }
+ }
+ }
+ if (keys(%reqs_by_date)) {
+ my $rolename = &Apache::lonnet::plaintext('st');
+ $r->print(''.&mt('Enrollment requests pending Course Coordinator approval').' '.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
'.&mt('Date requested').'
'.&mt('Course title').'
'.
+ '
'.&mt('User role').'
'.&mt('Section').'
'.
+ &Apache::loncommon::end_data_table_header_row());
+ my @sorted = sort { $a <=> $b } (keys(%reqs_by_date));
+ foreach my $item (@sorted) {
+ if (ref($reqs_by_date{$item}) eq 'ARRAY') {
+ foreach my $crs (@{$reqs_by_date{$item}}) {
+ my %courseinfo = &Apache::lonnet::coursedescription($crs);
+ my $usec = $selfenrollrequests{$crs}{'section'};
+ if ($usec eq '') {
+ $usec = &mt('No section');
+ }
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '