--- loncom/interface/loncoursequeueadmin.pm 2013/12/25 09:52:42 1.39
+++ loncom/interface/loncoursequeueadmin.pm 2014/01/03 18:39:51 1.41
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.39 2013/12/25 09:52:42 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.41 2014/01/03 18:39:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -213,7 +213,6 @@ sub send_selfserve_notification {
mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring space reqests[_3]to display a list of pending requests, which you can either approve or reject.',
args => ["\n","\n\n ","\n\n"],
});
-
} elsif ($context eq 'requestauthor') {
$rawsubj = 'Authoring space request';
$msgtxt = 'Your request for an authoring space requested on [_1]has been reviewed by a Domain Coordinator.';
@@ -229,6 +228,16 @@ sub send_selfserve_notification {
if (ref($textstr) eq 'ARRAY') {
push(@rawmsg,@{$textstr});
}
+ } elsif ($context eq 'queuedcrsreq') {
+ $rawsubj = 'Course Request Queued';
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
+ } elsif ($context eq 'createdcrsreq') {
+ $rawsubj = 'Course Creation Information';
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
}
my @to_notify = split(/,/,$notifylist);
my $numsent = 0;
@@ -614,9 +623,6 @@ sub update_request_queue {
if (ref($domconfig{'requestcourses'}{'notify'}) eq 'HASH') {
$notifylist = $domconfig{'requestcourses'}{'notify'}{'approval'};
}
- if ($domconfig{'requestcourses'}{'uniquecode'}) {
- $uniquecode = 1;
- }
}
$approvalmsg{'course'} =
[{
@@ -792,10 +798,20 @@ sub update_request_queue {
$ownerdom,$ownername);
if ((ref($history{'details'}) eq 'HASH') &&
($history{'disposition'} eq $queue)) {
- my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code);
- my $result = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,
- \$newusermsg,\$addresult,\$enrollcount,
- \$response,\$keysmsg,\%domdefs,$longroles,\$code);
+ my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code,%customitems);
+ my $fullname = '';
+ my $inprocess = &Apache::lonnet::auto_crsreq_update($cdom,$cnum,$crstype,'process',$ownername,
+ $ownerdom,$fullname,$coursedesc);
+ if (ref($inprocess) eq 'HASH') {
+ foreach my $key (keys(%{$inprocess})) {
+ if (exists($history{'details'}{$key})) {
+ $customitems{$key} = $history{'details'}{$key};
+ }
+ }
+ }
+ my ($result,$postprocess) = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,
+ \$newusermsg,\$addresult,\$enrollcount,
+ \$response,\$keysmsg,\%domdefs,$longroles,\$code,\%customitems);
if ($result eq 'created') {
if ($crstype eq 'community') {
$approvedmsg = $approvalmsg{'community'};
@@ -815,6 +831,17 @@ sub update_request_queue {
});
$codes{$cnum} = $code;
}
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
+ foreach my $item (@{$postprocess->{'createdmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$approvedmsg},$item);
+ }
+ }
+ }
+ }
+ }
}
push(@completed,$cnum);
@@ -1064,7 +1091,7 @@ sub update_request_queue {
}
my $syllabuslink =
&Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
- if ($uniquecode && $codes{$cnum}) {
+ if ($codes{$cnum}) {
$syllabuslink .= &mt('Unique code: [_1]',$codes{$cnum});
}
$output .= '
'.$syllabuslink.'';
@@ -1328,13 +1355,22 @@ sub get_student_counts {
sub course_creation {
my ($dom,$cnum,$context,$details,$logmsg,$newusermsg,$addresult,$enrollcount,$output,
- $keysmsg,$domdefs,$longroles,$coderef) = @_;
+ $keysmsg,$domdefs,$longroles,$coderef,$customhash) = @_;
unless ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH') &&
(ref($longroles) eq 'HASH')) {
return 'error: Invalid request';
}
my ($result,$ownername,$ownerdom);
my $crstype = $details->{'crstype'};
+ my $coursedesc = $details->{'cdescr'};
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'],$dom);
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
+ if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
+ $details->{'uniquecode'} = 1;
+ }
+ }
+ }
if ($context eq 'domain') {
$ownername = $details->{'owner'};
$ownerdom = $details->{'domain'};
@@ -1342,6 +1378,7 @@ sub course_creation {
$ownername = $env{'user.name'};
$ownerdom = $env{'user.domain'};
}
+ my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
my $owneremail;
my %emails = &Apache::loncommon::getemails($ownername,$ownerdom);
foreach my $email ('permanentemail','critnotification','notification') {
@@ -1352,12 +1389,19 @@ sub course_creation {
my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses',
\%reqdetails,$longroles,$logmsg,$newusermsg,$addresult,
$enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype,$coderef);
+ my $postprocess;
if ($cid eq "/$dom/$cnum") {
$result = 'created';
+ my $code;
+ if (ref($coderef)) {
+ $code = $$coderef;
+ }
+ $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,
+ $ownerdom,$fullname,$coursedesc,$code,$customhash);
} else {
$result = 'error: '.$cid;
}
- return $result;
+ return ($result,$postprocess);
}
sub build_batchcreatehash {
@@ -1383,6 +1427,12 @@ sub build_batchcreatehash {
if ($details->{'crstype'} eq 'community') {
$batchhash{'crstype'} = 'Community';
} else {
+ if ($details->{'crstype'} eq 'textbook') {
+ if ($details->{'clonecrs'} && $details->{'clonedom'}) {
+ my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'});
+ $batchhash{'textbook'} = $clonedfrom{'description'};
+ }
+ }
$batchhash{'crstype'} = 'Course';
}
my ($owner_firstname,$owner_lastname);
@@ -1720,7 +1770,20 @@ sub process_official_reqs {
$reqstatus = $disposition;
if ($disposition eq 'process') {
my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$code);
- my $result = &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,\$code);
+ my %customitems;
+ my $fullname = &Apache::loncommon::plainname($ownername,$ownerdom);
+ my $inprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'process',$ownername,
+ $ownerdom,$fullname,$cdescr);
+ if (ref($inprocess) eq 'HASH') {
+ foreach my $key (keys(%{$inprocess})) {
+ if (exists($history{'details'}{$key})) {
+ $customitems{$key} = $history{'details'}{$key};
+ }
+ }
+ }
+ my ($result,$postprocess) =
+ &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,
+ \$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles,\$code,\%customitems);
if ($result eq 'created') {
$disposition = 'created';
$reqstatus = 'created';
@@ -1744,6 +1807,17 @@ sub process_official_reqs {
mt => 'If currently logged-in to LON-CAPA, log-out and log-in again to select your new course role.'
}];
my $sender = $dcname.':'.$dcdom;
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
+ foreach my $item (@{$postprocess->{'createdmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$approvedmsg},$item);
+ }
+ }
+ }
+ }
+ }
&send_selfserve_notification($owner,$approvedmsg,
$cid,$cdescr,$now,
$beneficiary,$sender,