--- loncom/interface/loncoursequeueadmin.pm 2013/12/25 20:43:46 1.40
+++ loncom/interface/loncoursequeueadmin.pm 2014/01/08 17:18:11 1.42
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.40 2013/12/25 20:43:46 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.42 2014/01/08 17:18:11 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -116,7 +116,7 @@ sub send_selfserve_notification {
push(@rawmsg,@{$textstr});
}
} elsif ($context eq 'authormanagers') {
- $rawsubj = 'Authoring space requests reviewed';
+ $rawsubj = 'Authoring Space requests reviewed';
push(@rawmsg,{
mt => 'Authoring requests in the following domain: "[_1]" have been reviewed.',
args => ["\n$contextdesc"],
@@ -203,20 +203,19 @@ sub send_selfserve_notification {
args => [" \n\n","\n"],
});
} elsif ($context eq 'authorreq') {
- $rawsubj = 'Authoring space request to review';
+ $rawsubj = 'Authoring Space request to review';
$msgtxt = 'Assignment of an author role in the [_1] domain[_2]was requested by [_3] on [_4].';
push(@rawmsg,{
mt => $msgtxt,
args => [$contextdesc,"\n",$textstr,$timestamp],
},
{
- 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.',
+ mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring Space requests[_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.';
+ $rawsubj = 'Authoring Space request';
+ $msgtxt = 'Your request for an Authoring Space requested on [_1]has been reviewed by a Domain Coordinator.';
push(@rawmsg,{
mt => $msgtxt,
args => [$timestamp."\n"],
@@ -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;
@@ -375,7 +384,7 @@ sub display_queued_requests {
'
'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'
'.
&mt('Validation is attempted when the request is submitted.').' '.&mt('If unvalidated, the request will be held in a queue.').' '.&mt('Validation of pending requests is automatically repeated daily.').'
';
} elsif ($context eq 'requestauthor') {
- $output .= ''.&mt('Requests for authoring space queued pending approval by a Domain Coordinator').'
';
+ $output .= ''.&mt('Requests for Authoring Space queued pending approval by a Domain Coordinator').'
';
} else {
$output .= ''.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'
';
}
@@ -388,7 +397,7 @@ sub display_queued_requests {
} elsif ($context eq 'pending') {
$output .= &mt('There are currently no requests for official courses awaiting validation.');
} elsif ($context eq 'requestauthor') {
- $output .= &mt('There are currently no requests for authoring space awaiting approval.');
+ $output .= &mt('There are currently no requests for Authoring Space awaiting approval.');
} elsif ($context eq 'domain') {
$output .= &mt('There are currently no course or community requests awaiting approval.');
}
@@ -590,14 +599,14 @@ sub update_request_queue {
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
$firsturl = &course_portal_url($domconfiguser,$cdom);
$approvedmsg = [{
- mt => 'Your request for authoring space has been approved.',
+ mt => 'Your request for Authoring Space has been approved.',
},
{
mt => 'Visit [_1] to log-in and select your author role',
args => [$firsturl],
}];
$rejectedmsg = [{
- mt => 'Your request for authoring space has not been approved.',
+ mt => 'Your request for Authoring Space has not been approved.',
}];
$domdesc = &Apache::lonnet::domain($cdom);
} else {
@@ -789,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'};
@@ -812,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);
@@ -1020,7 +1050,7 @@ sub update_request_queue {
$approvedlist,$rejectedlist,$crstype);
}
} elsif ($context eq 'requestauthor') {
- $chgmsg = "'Action was taken on the following authoring space requests by [_1].',$namelink";
+ $chgmsg = "'Action was taken on the following Authoring Space requests by [_1].',$namelink";
if (@completed) {
$approvedlist = join("\n",@completed);
$output .= ''.&mt('The following requests were approved:').'
';
@@ -1098,7 +1128,7 @@ sub update_request_queue {
}
$output .= '
';
} elsif ($context eq 'requestauthor') {
- $output .= ''.&mt('Authoring space requests from the following users were deleted because one already exists:').'
';
+ $output .= ''.&mt('Authoring Space requests from the following users were deleted because one already exists:').'
';
foreach my $uname (@existing) {
my $userlink =
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
@@ -1151,7 +1181,7 @@ sub update_request_queue {
}
$output .= '
';
} elsif ($context eq 'requestauthor') {
- $output .= ''.&mt('The following authoring space requests were deleted because the requestor does not have a LON-CAPA account:').'
';
+ $output .= ''.&mt('The following Authoring Space requests were deleted because the requestor does not have a LON-CAPA account:').'
';
foreach my $uname (@invalidusers) {
my $userlink =
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
@@ -1183,7 +1213,7 @@ sub update_request_queue {
}
$output .= '
';
} elsif ($context eq 'requestauthor') {
- $output .= ''.&mt('The following requests could not be processed because the requestor does not have rights to request an authoring space:').'
';
+ $output .= ''.&mt('The following requests could not be processed because the requestor does not have rights to request an Authoring Space:').'
';
foreach my $uname (@nopermissions) {
my $userlink =
&Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
@@ -1325,13 +1355,14 @@ 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') {
@@ -1347,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') {
@@ -1357,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 {
@@ -1388,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);
@@ -1725,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';
@@ -1749,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,
@@ -1861,13 +1930,13 @@ sub process_reqauthor {
my ($dispositionref,$updateref) = @_;
if (&is_active_author()) {
return ''.
- &mt('An authoring space has already been assigned to you.').'
'.
+ &mt('An Authoring Space has already been assigned to you.').'
'.
&mt('Please select the Author role from your [_1]roles page[_2].','',
'').'';
}
unless ($env{'environment.canrequest.author'}) {
return ''.
- &mt('You do not currently have rights to request an authoring space.').'
'.
+ &mt('You do not currently have rights to request an Authoring Space.').'
'.
&mt('Please contact the [_1]helpdesk[_2] for assistance.','',
'').'';
}
@@ -1875,7 +1944,7 @@ sub process_reqauthor {
if ($queued =~ /^approval:(\d+)$/) {
my $timestamp = $1;
return ''.
- &mt('A request for authoring space submitted on [_1] is awaiting approval',
+ &mt('A request for Authoring Space submitted on [_1] is awaiting approval',
&Apache::lonlocal::locallocaltime($timestamp)).
'';
} elsif ($queued =~ /^approved:(\d+)$/) {
@@ -1884,7 +1953,7 @@ sub process_reqauthor {
['active'],['au'],[$env{'user.domain'}]);
if (keys(%roleshash) > 0) {
return ''.
- &mt('A request for authoring space submitted on [_1] has been approved.',
+ &mt('A request for Authoring Space submitted on [_1] has been approved.',
&Apache::lonlocal::locallocaltime($timestamp)).
'';
}
@@ -1901,7 +1970,7 @@ sub process_reqauthor {
if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/',
'au',undef,$start,undef,undef,'requestauthor') eq 'ok') {
$output = ''.
- &mt('Access to authoring space has been activated').'
';
+ &mt('Access to Authoring Space has been activated').'
';
&Apache::lonroles::update_session_roles();
&Apache::lonnet::appenv({'user.update.time' => $now});
if (ref($updateref)) {
@@ -1912,7 +1981,7 @@ sub process_reqauthor {
}
} else {
$output = ''.
- &mt('An error occurred while activating your access to authoring space');
+ &mt('An error occurred while activating your access to Authoring Space');
}
} elsif ($val eq 'approval') {
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($env{'user.domain'});
@@ -1943,12 +2012,12 @@ sub process_reqauthor {
my $userresult =
&Apache::lonnet::put('requestauthor',\%userrequest,$env{'user.domain'},$env{'user.name'});
$output = ''.
- &mt('Your request for authoring space has been submitted for approval.').
+ &mt('Your request for Authoring Space has been submitted for approval.').
'';
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now});
} else {
$output = ''.
- &mt('An error occurred saving your request for authoring space.').
+ &mt('An error occurred saving your request for Authoring Space.').
'';
}
}