--- loncom/interface/loncoursequeueadmin.pm 2010/01/15 05:26:51 1.12.2.5
+++ 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.2.5 2010/01/15 05:26:51 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
#
@@ -67,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;
@@ -377,7 +376,7 @@ sub update_request_queue {
@processing_errors,@warn_approves,@warn_rejects,@approvals,
@rejections,@rejectionerrors,@nopermissions,%courseroles,
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,
- @warn_coursereqs);
+ @warn_coursereqs,$firsturl);
@approvals = &Apache::loncommon::get_env_multiple('form.approvereq');
@rejections = &Apache::loncommon::get_env_multiple('form.rejectreq');
$now = time;
@@ -391,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'};
@@ -403,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.',
@@ -417,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') {
@@ -429,7 +440,7 @@ sub update_request_queue {
},
{
mt => 'Visit [_1], to log-in and access the course',
- args => [$protocol.'://'.$hostname],
+ args => [$firsturl],
}];
$rejectionmsg{'course'} =
[{
@@ -442,7 +453,7 @@ sub update_request_queue {
},
{
mt => 'Visit [_1], to log-in and access the community',
- args => [$protocol.'://'.$hostname],
+ args => [$firsturl],
}];
$rejectionmsg{'community'} =
@@ -460,15 +471,29 @@ 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 eq 'gci' && $cnum eq '9615072b469884921gcil1') {
- my $enresult = &enable_gci_submission($udom,$uname,
- $access_end,$access_start);
+ 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') {
@@ -515,9 +540,9 @@ sub update_request_queue {
&Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
if ($userresult ne 'ok') {
push(@warn_approves,$uname.':'.$udom);
- } elsif ($udom eq 'gci') {
+ } elsif (ref($allnums{$udom}) eq 'HASH') {
my %changehash = (
- 'reqcrsotherdom.unofficial' => 'gcitest:autolimit=',
+ 'reqcrsotherdom.unofficial' => $udom.'test:autolimit=',
);
my $reqresult = &Apache::lonnet::put('environment',\%changehash,
$udom,$uname);
@@ -918,10 +943,8 @@ sub update_request_queue {
return $output;
}
-sub enable_gci_submission {
- my ($udom,$uname,$access_end,$access_start) = @_;
- my $cdom = 'gci';
- my $cnum = '1H96711d710194bfegcil1';
+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') {
@@ -977,8 +1000,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 {
@@ -990,12 +1013,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};
- if ($dom eq 'gcitest') {
+ my @items = qw{owner domain coursehome clonecrs clonedom cloneroster 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')) {
- my $emailenc = &Apache::lonnet::escape($owneremail);
+ my $emailenc = &escape($owneremail);
my $owner = $details->{'owner'}.':'.$details->{'domain'};
foreach my $item (@items) {
$batchhash{$item} = $details->{$item};
@@ -1078,6 +1101,11 @@ sub can_clone_course {
$canclone = 1;
}
}
+ unless ($canclone) {
+ if (&Apache::lonnet::is_course_owner($clonedom,$clonecrs,$uname,$udom)) {
+ $canclone = 1;
+ }
+ }
}
return $canclone;
}
@@ -1097,7 +1125,6 @@ sub queued_selfenrollment {
}
}
if (keys(%reqs_by_date)) {
- my $rolename = &Apache::lonnet::plaintext('st');
unless ($notitle) {
$output .= ''.&mt('Enrollment requests pending Course Coordinator approval').'
';
}
@@ -1112,6 +1139,7 @@ sub queued_selfenrollment {
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');
}