[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface loncoursequeueadmin.pm
raeburn
raeburn@source.lon-capa.org
Fri, 15 Jan 2010 03:29:54 -0000
raeburn Fri Jan 15 03:29:54 2010 EDT
Modified files:
/loncom/auth lonroles.pm
/loncom/interface loncoursequeueadmin.pm
Log:
- Move &queued_selfenrollment() from lonroles.pm to loncoursequeueadmin.pm
to facilitate re-use.
- &queued_selfenrollment() has a different arg - $notitle - which when true
will omit title of pending requests table.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.240 loncom/auth/lonroles.pm:1.241
--- loncom/auth/lonroles.pm:1.240 Tue Nov 3 03:01:47 2009
+++ loncom/auth/lonroles.pm Fri Jan 15 03:29:48 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.240 2009/11/03 03:01:47 raeburn Exp $
+# $Id: lonroles.pm,v 1.241 2010/01/15 03:29:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -138,6 +138,7 @@
use Apache::lonlocal;
use Apache::lonpageflip();
use Apache::lonnavdisplay();
+use Apache::loncoursequeueadmin;
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
use HTML::Entities;
@@ -711,7 +712,7 @@
.'</p>');
} else {
if ($countactive > 0) {
- &queued_selfenrollment($r);
+ $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
$r->print(
@@ -1174,8 +1175,8 @@
}
$r->print('<h3>'.&mt('Self-Enrollment').'</h3>'.
'<p>'.&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.','<a href="/adm/coursecatalog?showdom='.$esc_dom.'">','</a>',$domdesc).'<br />');
- $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>');
- &queued_selfenrollment($r);
+ $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'</p>'.
+ &Apache::loncoursequeueadmin::queued_selfenrollment());
return;
}
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.13 loncom/interface/loncoursequeueadmin.pm:1.14
--- loncom/interface/loncoursequeueadmin.pm:1.13 Thu Jan 14 20:08:13 2010
+++ loncom/interface/loncoursequeueadmin.pm Fri Jan 15 03:29:54 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.13 2010/01/14 20:08:13 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.14 2010/01/15 03:29:54 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,9 @@
=head1 SYNOPSIS
-Administration utilities used by domain coordinators for queued course creation requests, and by course coordinators for queued self-enrollment requests.
+Utilities used by domain coordinators to administer queued course creation requests,
+and by course coordinators for queued self-enrollment requests, and by general
+users to display their queued self-enrollment requests.
This is part of the LearningOnline Network with CAPA project
described at http://www.lon-capa.org.
@@ -58,6 +60,8 @@
=item get_processtype()
+=item queued_selfenrollment()
+
=back
=cut
@@ -1131,4 +1135,50 @@
return $val;
}
+sub queued_selfenrollment {
+ my ($notitle) = @_;
+ my $output;
+ 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');
+ unless ($notitle) {
+ $output .= '<b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />';
+ }
+ $output .= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt('Date requested').'</th><th>'.&mt('Course title').'</th>'.
+ '<th>'.&mt('User role').'</th><th>'.&mt('Section').'</th>'.
+ &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');
+ }
+ $output .= &Apache::loncommon::start_data_table_row().
+ '<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'.
+ '<td>'.$courseinfo{'description'}.'</td>'.
+ '<td>'.$rolename.'</td><td>'.$usec.'</td>'.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ }
+ return $output;
+}
+
1;