--- loncom/interface/loncoursequeueadmin.pm 2009/11/18 19:15:45 1.12
+++ loncom/interface/loncoursequeueadmin.pm 2010/02/26 23:39:01 1.12.2.8
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.12 2009/11/18 19:15:45 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.12.2.8 2010/02/26 23:39:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,9 @@ Apache::loncoursequeueadmin.pm
=head1 SYNOPSIS
-Adminitsration 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.
@@ -50,6 +52,14 @@ described at http://www.lon-capa.org.
=item get_student_counts()
+=item course_creation()
+
+=item build_batchcreatehash()
+
+=item can_clone_course()
+
+=item queued_selfenrollment()
+
=back
=cut
@@ -57,7 +67,6 @@ described at http://www.lon-capa.org.
package Apache::loncoursequeueadmin;
use strict;
-use Apache::Constants qw(:common :http);
use Apache::lonnet;
use Apache::loncommon;
use Apache::lonmsg;
@@ -366,7 +375,8 @@ sub update_request_queue {
@existing,@missingreq,@invalidusers,@limitexceeded,@completed,
@processing_errors,@warn_approves,@warn_rejects,@approvals,
@rejections,@rejectionerrors,@nopermissions,%courseroles,
- %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype);
+ %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,
+ @warn_coursereqs);
@approvals = &Apache::loncommon::get_env_multiple('form.approvereq');
@rejections = &Apache::loncommon::get_env_multiple('form.rejectreq');
$now = time;
@@ -455,7 +465,10 @@ sub update_request_queue {
my $uhome = &Apache::lonnet::homeserver($uname,$udom);
if ($uhome ne 'no_host') {
if (exists($requesthash{$uname.':'.$udom})) {
-
+ if ($cdom eq 'gci' && $cnum eq '9615072b469884921gcil1') {
+ my $enresult = &enable_gci_submission($udom,$uname,
+ $access_end,$access_start);
+ }
if (exists($classlist->{$uname.':'.$udom})) {
if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') ||
@@ -501,6 +514,15 @@ sub update_request_queue {
&Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
if ($userresult ne 'ok') {
push(@warn_approves,$uname.':'.$udom);
+ } elsif ($udom eq 'gci') {
+ my %changehash = (
+ 'reqcrsotherdom.unofficial' => 'gcitest:autolimit=',
+ );
+ my $reqresult = &Apache::lonnet::put('environment',\%changehash,
+ $udom,$uname);
+ if ($reqresult ne 'ok') {
+ push(@warn_coursereqs,$uname.':'.$udom);
+ }
}
} else {
push(@processing_errors,$uname.':'.$udom);
@@ -885,9 +907,33 @@ sub update_request_queue {
$output .= '
';
}
}
+ if (@warn_coursereqs) {
+ $output .= ''..&mt("For the following users, an error occurred when setting rights to request creation of Concept Test courses:").'
';
+ foreach my $user (@warn_coursereqs) {
+ $output .= '- '.$user.'
';
+ }
+ $output .= '
';
+ }
return $output;
}
+sub enable_gci_submission {
+ my ($udom,$uname,$access_end,$access_start) = @_;
+ my $cdom = 'gci';
+ my $cnum = '1H96711d710194bfegcil1';
+ my ($stucounts,$idx,$classlist) = &get_student_counts($cdom,$cnum);
+ if (exists($classlist->{$uname.':'.$udom})) {
+ if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') {
+ if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') ||
+ ($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Future')) {
+ return;
+ }
+ }
+ }
+ return
+ &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,undef,$access_end,$access_start,'selfenroll',undef,$cdom.'_'.$cnum,1);
+}
+
sub get_student_counts {
my ($cdom,$cnum) = @_;
my (%idx,%stucounts);
@@ -930,8 +976,8 @@ sub course_creation {
}
my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs);
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',
- \%reqdetails,$longroles,\$logmsg,\$newusermsg,\$addresult,
- \$enrollcount,\$output,\$keysmsg,$ownerdom,$ownername,$cnum,$crstype);
+ \%reqdetails,$longroles,$logmsg,$newusermsg,$addresult,
+ $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype);
if ($cid eq "/$dom/$cnum") {
$result = 'created';
} else {
@@ -943,9 +989,12 @@ sub course_creation {
sub build_batchcreatehash {
my ($dom,$context,$details,$owneremail,$domdefs) = @_;
my %batchhash;
- my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users};
+ my @items = qw{owner domain coursehome clonecrs clonedom cloneroster datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users};
+ if ($dom eq 'gcitest') {
+ push(@items,'firstres');
+ }
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {
- my $emailenc = &Apache::lonnet::escape($owneremail);
+ my $emailenc = &escape($owneremail);
my $owner = $details->{'owner'}.':'.$details->{'domain'};
foreach my $item (@items) {
$batchhash{$item} = $details->{$item};
@@ -1028,8 +1077,59 @@ sub can_clone_course {
$canclone = 1;
}
}
+ unless ($canclone) {
+ if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) {
+ $canclone = 1;
+ }
+ }
}
return $canclone;
}
+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)) {
+ unless ($notitle) {
+ $output .= ''.&mt('Enrollment requests pending Course Coordinator approval').'
';
+ }
+ $output .= &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'};
+ my $rolename = &Apache::lonnet::plaintext('st',$courseinfo{'type'},$crs);
+ if ($usec eq '') {
+ $usec = &mt('No section');
+ }
+ $output .= &Apache::loncommon::start_data_table_row().
+ ''.&Apache::lonlocal::locallocaltime($item).' | '.
+ ''.$courseinfo{'description'}.' | '.
+ ''.$rolename.' | '.$usec.' | '.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ }
+ return $output;
+}
+
1;