version 1.12.2.11, 2010/12/07 04:19:59
|
version 1.13, 2010/01/14 20:08:13
|
Line 33 Apache::loncoursequeueadmin.pm
|
Line 33 Apache::loncoursequeueadmin.pm
|
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
Utilities used by domain coordinators to administer queued course creation requests, |
Administration utilities used by domain coordinators for queued course creation requests, and by course coordinators for queued self-enrollment 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 |
This is part of the LearningOnline Network with CAPA project |
described at http://www.lon-capa.org. |
described at http://www.lon-capa.org. |
Line 55 described at http://www.lon-capa.org.
|
Line 53 described at http://www.lon-capa.org.
|
=item course_creation() |
=item course_creation() |
|
|
=item build_batchcreatehash() |
=item build_batchcreatehash() |
|
|
=item can_clone_course() |
=item can_clone_course() |
|
|
=item queued_selfenrollment() |
=item get_processtype() |
|
|
=back |
=back |
|
|
Line 67 described at http://www.lon-capa.org.
|
Line 65 described at http://www.lon-capa.org.
|
package Apache::loncoursequeueadmin; |
package Apache::loncoursequeueadmin; |
|
|
use strict; |
use strict; |
|
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonmsg; |
use Apache::lonmsg; |
Line 375 sub update_request_queue {
|
Line 374 sub update_request_queue {
|
@existing,@missingreq,@invalidusers,@limitexceeded,@completed, |
@existing,@missingreq,@invalidusers,@limitexceeded,@completed, |
@processing_errors,@warn_approves,@warn_rejects,@approvals, |
@processing_errors,@warn_approves,@warn_rejects,@approvals, |
@rejections,@rejectionerrors,@nopermissions,%courseroles, |
@rejections,@rejectionerrors,@nopermissions,%courseroles, |
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype, |
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype); |
@warn_coursereqs); |
|
@approvals = &Apache::loncommon::get_env_multiple('form.approvereq'); |
@approvals = &Apache::loncommon::get_env_multiple('form.approvereq'); |
@rejections = &Apache::loncommon::get_env_multiple('form.rejectreq'); |
@rejections = &Apache::loncommon::get_env_multiple('form.rejectreq'); |
$now = time; |
$now = time; |
Line 459 sub update_request_queue {
|
Line 457 sub update_request_queue {
|
} |
} |
|
|
} |
} |
my %allnums = &Apache::loncommon::get_faculty_cnums(); |
|
foreach my $item (sort {$a <=> $b} @approvals) { |
foreach my $item (sort {$a <=> $b} @approvals) { |
if ($context eq 'course') { |
if ($context eq 'course') { |
my ($num,$uname,$udom,$usec) = split(/:/,$item); |
my ($num,$uname,$udom,$usec) = split(/:/,$item); |
my $uhome = &Apache::lonnet::homeserver($uname,$udom); |
my $uhome = &Apache::lonnet::homeserver($uname,$udom); |
if ($uhome ne 'no_host') { |
if ($uhome ne 'no_host') { |
if (exists($requesthash{$uname.':'.$udom})) { |
if (exists($requesthash{$uname.':'.$udom})) { |
if (($cdom ne '') && (ref($allnums{$cdom}) eq 'HASH')) { |
|
my ($addothers,@others); |
|
foreach my $key (%{$allnums{$cdom}}) { |
|
if ($key eq $cnum) { |
|
$addothers = 1; |
|
} else { |
|
push(@others,$key); |
|
} |
|
} |
|
if ($addothers) { |
|
foreach my $crs (@others) { |
|
my $enresult = |
|
&enable_additional_roles($cdom,$crs,$udom,$uname, |
|
$access_end,$access_start); |
|
} |
|
} |
|
} |
|
if (exists($classlist->{$uname.':'.$udom})) { |
if (exists($classlist->{$uname.':'.$udom})) { |
if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { |
if (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { |
if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') || |
if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') || |
Line 528 sub update_request_queue {
|
Line 509 sub update_request_queue {
|
&Apache::lonnet::put($namespace,\%userrequest,$udom,$uname); |
&Apache::lonnet::put($namespace,\%userrequest,$udom,$uname); |
if ($userresult ne 'ok') { |
if ($userresult ne 'ok') { |
push(@warn_approves,$uname.':'.$udom); |
push(@warn_approves,$uname.':'.$udom); |
} elsif (ref($allnums{$udom}) eq 'HASH') { |
|
my %changehash = ( |
|
'reqcrsotherdom.unofficial' => $udom.'test:autolimit=', |
|
); |
|
my $reqresult = &Apache::lonnet::put('environment',\%changehash, |
|
$udom,$uname); |
|
if ($reqresult ne 'ok') { |
|
push(@warn_coursereqs,$uname.':'.$udom); |
|
} |
|
} |
} |
} else { |
} else { |
push(@processing_errors,$uname.':'.$udom); |
push(@processing_errors,$uname.':'.$udom); |
Line 921 sub update_request_queue {
|
Line 893 sub update_request_queue {
|
$output .= '</ul></p>'; |
$output .= '</ul></p>'; |
} |
} |
} |
} |
if (@warn_coursereqs) { |
|
$output .= '<p>'..&mt("For the following users, an error occurred when setting rights to request creation of Concept Test courses:").'<ul>'; |
|
foreach my $user (@warn_coursereqs) { |
|
$output .= '<li>'.$user.'</li>'; |
|
} |
|
$output .= '</ul></p>'; |
|
} |
|
return $output; |
return $output; |
} |
} |
|
|
sub enable_additional_roles { |
|
my ($cdom,$cnum,$udom,$uname,$access_end,$access_start) = @_; |
|
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 { |
sub get_student_counts { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum) = @_; |
my (%idx,%stucounts); |
my (%idx,%stucounts); |
Line 988 sub course_creation {
|
Line 938 sub course_creation {
|
} |
} |
my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs); |
my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs); |
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses', |
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses', |
\%reqdetails,$longroles,$logmsg,$newusermsg,$addresult, |
\%reqdetails,$longroles,\$logmsg,\$newusermsg,\$addresult, |
$enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype); |
\$enrollcount,\$output,\$keysmsg,$ownerdom,$ownername,$cnum,$crstype); |
if ($cid eq "/$dom/$cnum") { |
if ($cid eq "/$dom/$cnum") { |
$result = 'created'; |
$result = 'created'; |
} else { |
} else { |
Line 1001 sub course_creation {
|
Line 951 sub course_creation {
|
sub build_batchcreatehash { |
sub build_batchcreatehash { |
my ($dom,$context,$details,$owneremail,$domdefs) = @_; |
my ($dom,$context,$details,$owneremail,$domdefs) = @_; |
my %batchhash; |
my %batchhash; |
my @items = qw{owner domain coursehome clonecrs clonedom cloneroster datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users}; |
my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users}; |
if ($dom =~ /^\w+citest$/) { |
|
push(@items,'firstres'); |
|
} |
|
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) { |
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) { |
my $emailenc = &escape($owneremail); |
my $emailenc = &Apache::lonnet::escape($owneremail); |
my $owner = $details->{'owner'}.':'.$details->{'domain'}; |
my $owner = $details->{'owner'}.':'.$details->{'domain'}; |
foreach my $item (@items) { |
foreach my $item (@items) { |
$batchhash{$item} = $details->{$item}; |
$batchhash{$item} = $details->{$item}; |
Line 1089 sub can_clone_course {
|
Line 1036 sub can_clone_course {
|
$canclone = 1; |
$canclone = 1; |
} |
} |
} |
} |
unless ($canclone) { |
|
if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) { |
|
$canclone = 1; |
|
} |
|
} |
|
} |
} |
return $canclone; |
return $canclone; |
} |
} |
|
|
sub queued_selfenrollment { |
sub get_processtype { |
my ($notitle) = @_; |
my ($uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_; |
my $output; |
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH')); |
my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests'); |
if ($uname eq '' || $udom eq '') { |
my %reqs_by_date; |
$uname = $env{'user.name'}; |
foreach my $item (keys(%selfenrollrequests)) { |
$udom = $env{'user.domain'}; |
if (ref($selfenrollrequests{$item}) eq 'HASH') { |
$isadv = $env{'user.adv'}; |
if ($selfenrollrequests{$item}{'status'} eq 'request') { |
} |
if ($selfenrollrequests{$item}{'timestamp'}) { |
my (%userenv,%settings,$val); |
push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item); |
my @options = ('autolimit','validate','approval'); |
|
if ($dom eq $udom) { |
|
%userenv = |
|
&Apache::lonnet::userenvironment($udom,$uname,'requestcourses.'.$crstype,'inststatus'); |
|
if ($userenv{'requestcourses.'.$crstype}) { |
|
$val = $userenv{'requestcourses.'.$crstype}; |
|
@{$inststatuses} = ('_custom_'); |
|
} else { |
|
my ($task,%alltasks); |
|
if (ref($domconfig->{'requestcourses'}) eq 'HASH') { |
|
%settings = %{$domconfig->{'requestcourses'}}; |
|
if (ref($settings{$crstype}) eq 'HASH') { |
|
if (($isadv) && ($settings{$crstype}{'_LC_adv'} ne '')) { |
|
$val = $settings{$crstype}{'_LC_adv'}; |
|
@{$inststatuses} = ('_LC_adv_'); |
|
} else { |
|
if ($userenv{'inststatus'} ne '') { |
|
@{$inststatuses} = split(',',$userenv{'inststatus'}); |
|
} else { |
|
@{$inststatuses} = ('default'); |
|
} |
|
foreach my $status (@{$inststatuses}) { |
|
if (exists($settings{$crstype}{$status})) { |
|
my $value = $settings{$crstype}{$status}; |
|
next unless ($value); |
|
unless (exists($alltasks{$value})) { |
|
if (ref($alltasks{$value}) eq 'ARRAY') { |
|
unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) { |
|
push(@{$alltasks{$value}},$status); |
|
} |
|
} else { |
|
@{$alltasks{$value}} = ($status); |
|
} |
|
} |
|
} |
|
} |
|
my $maxlimit = 0; |
|
|
|
foreach my $key (sort(keys(%alltasks))) { |
|
if ($key =~ /^autolimit=(\d*)$/) { |
|
if ($1 eq '') { |
|
$val ='autolimit='; |
|
last; |
|
} elsif ($1 > $maxlimit) { |
|
$maxlimit = $1; |
|
} |
|
} |
|
} |
|
if ($maxlimit) { |
|
$val = 'autolimit='.$maxlimit; |
|
} else { |
|
foreach my $option (@options) { |
|
if ($alltasks{$option}) { |
|
$val = $option; |
|
last; |
|
} |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
} |
} else { |
if (keys(%reqs_by_date)) { |
%userenv = &Apache::lonnet::userenvironment($udom,$uname,'reqcrsotherdom.'.$crstype); |
unless ($notitle) { |
if ($userenv{'reqcrsotherdom.'.$crstype}) { |
$output .= '<b>'.&mt('Enrollment requests pending Course Coordinator approval').'</b><br />'; |
my @doms = split(',',$userenv{'reqcrsotherdom.'.$crstype}); |
} |
my $optregex = join('|',@options); |
$output .= &Apache::loncommon::start_data_table(). |
foreach my $item (@doms) { |
&Apache::loncommon::start_data_table_header_row(). |
my ($extdom,$extopt) = split(':',$item); |
'<th>'.&mt('Date requested').'</th><th>'.&mt('Course title').'</th>'. |
if ($extdom eq $dom) { |
'<th>'.&mt('User role').'</th><th>'.&mt('Section').'</th>'. |
if ($extopt =~ /^($optregex)(=?\d*)$/) { |
&Apache::loncommon::end_data_table_header_row(); |
$val = $1.$2; |
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(). |
last; |
'<td>'.&Apache::lonlocal::locallocaltime($item).'</td>'. |
|
'<td>'.$courseinfo{'description'}.'</td>'. |
|
'<td>'.$rolename.'</td><td>'.$usec.'</td>'. |
|
&Apache::loncommon::end_data_table_row(); |
|
} |
} |
} |
} |
|
@{$inststatuses} = ('_external_'); |
} |
} |
$output .= &Apache::loncommon::end_data_table(); |
|
} |
} |
return $output; |
return $val; |
} |
} |
|
|
1; |
1; |