--- loncom/interface/loncoursequeueadmin.pm 2009/11/18 19:15:45 1.12 +++ loncom/interface/loncoursequeueadmin.pm 2010/12/08 03:49:34 1.12.2.12 @@ -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.12 2010/12/08 03:49:34 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,$firsturl); @approvals = &Apache::loncommon::get_env_multiple('form.approvereq'); @rejections = &Apache::loncommon::get_env_multiple('form.rejectreq'); $now = time; @@ -380,6 +390,12 @@ sub update_request_queue { $hostname = &Apache::lonnet::hostname($chome); $protocol = $Apache::lonnet::protocol{$chome}; $protocol = 'http' if ($protocol ne 'https'); + my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); + if ($domdefaults{'portal_def'}) { + $firsturl = $domdefaults{'portal_def'}; + } else { + $firsturl = $protocol.'://'.$hostname; + } %requesthash = &Apache::lonnet::dump($namespace,$cdom,$cnum); $access_start = $env{'course.'.$cid.'.internal.selfenroll_start_access'}; $access_end = $env{'course.'.$cid.'.internal.selfenroll_end_access'}; @@ -392,7 +408,7 @@ sub update_request_queue { }, { mt => 'Visit [_1], to log-in and access the course', - args => [$protocol.'://'.$hostname], + args => [$firsturl], }]; $rejectedmsg = [{ mt => 'Your request for enrollment has not been approved.', @@ -406,6 +422,12 @@ sub update_request_queue { $hostname = &Apache::lonnet::hostname($chome); $protocol = $Apache::lonnet::protocol{$chome}; $protocol = 'http' if ($protocol ne 'https'); + my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); + if ($domdefaults{'portal_def'}) { + $firsturl = $domdefaults{'portal_def'}; + } else { + $firsturl = $protocol.'://'.$hostname; + } my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom); if (ref($domconfig{'requestcourses'}) eq 'HASH') { if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') { @@ -418,7 +440,7 @@ sub update_request_queue { }, { mt => 'Visit [_1], to log-in and access the course', - args => [$protocol.'://'.$hostname], + args => [$firsturl], }]; $rejectionmsg{'course'} = [{ @@ -431,7 +453,7 @@ sub update_request_queue { }, { mt => 'Visit [_1], to log-in and access the community', - args => [$protocol.'://'.$hostname], + args => [$firsturl], }]; $rejectionmsg{'community'} = @@ -449,13 +471,30 @@ sub update_request_queue { } } + my %allnums = &Apache::loncommon::get_faculty_cnums(); foreach my $item (sort {$a <=> $b} @approvals) { if ($context eq 'course') { my ($num,$uname,$udom,$usec) = split(/:/,$item); my $uhome = &Apache::lonnet::homeserver($uname,$udom); if ($uhome ne 'no_host') { 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 (ref($classlist->{$uname.':'.$udom}) eq 'ARRAY') { if (($classlist->{$uname.':'.$udom}->[$idx->{'status'}] eq 'Active') || @@ -501,6 +540,15 @@ sub update_request_queue { &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname); if ($userresult ne 'ok') { 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 { push(@processing_errors,$uname.':'.$udom); @@ -885,9 +933,31 @@ 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:").'