--- loncom/interface/loncoursequeueadmin.pm 2013/01/02 01:15:26 1.33
+++ 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.33 2013/01/02 01:15:26 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.';
@@ -224,6 +223,21 @@ sub send_selfserve_notification {
if (ref($textstr) eq 'ARRAY') {
push(@rawmsg,@{$textstr});
}
+ } elsif ($context eq 'uniquecode') {
+ $rawsubj = 'Course Identifier';
+ 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;
@@ -435,6 +449,7 @@ sub build_queue_display {
official => 'Official course',
unofficial => 'Unofficial course',
community => 'Community',
+ textbook => 'Textbook course',
);
$output .= '
'.&mt('Type').' | '.
''.&mt('Date requested').' | '.
@@ -533,15 +548,15 @@ sub update_request_queue {
@processing_errors,@warn_approves,@warn_rejects,@approvals,@warn_dels,
@rejections,@rejectionerrors,@nopermissions,%courseroles,@toremove,
%communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
- $firsturl);
+ $firsturl,$uniquecode,%codes);
my $count=0;
while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {
- if (@course[0] =~ /^\d+:.*/) {
- push(@approvals,@course[0]);
- } elsif (@course[0] =~ /^later:.*/) {
+ if ($course[0] =~ /^\d+:.*/) {
+ push(@approvals,$course[0]);
+ } elsif ($course[0] =~ /^later:.*/) {
#decide later
} else {
- push(@rejections,@course[0]);
+ push(@rejections,$course[0]);
}
$count+=1;
}
@@ -783,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);
- my $result = &course_creation($cdom,$cnum,$context,$history{'details'},\$logmsg,
- \$newusermsg,\$addresult,\$enrollcount,
- \$response,\$keysmsg,\%domdefs,$longroles);
+ 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'};
@@ -798,6 +823,25 @@ sub update_request_queue {
if (ref($approvedmsg->[1]) eq 'HASH') {
$approvedmsg->[1]->{'args'} = [$firsturl];
}
+ if ($code) {
+ push(@{$approvedmsg},
+ {
+ mt => 'Students can automatically select your course by entering this code: [_1]',
+ args => [$code],
+ });
+ $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);
@@ -1047,6 +1091,9 @@ sub update_request_queue {
}
my $syllabuslink =
&Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
+ if ($codes{$cnum}) {
+ $syllabuslink .= &mt('Unique code: [_1]',$codes{$cnum});
+ }
$output .= ''.$syllabuslink.'';
}
$output .= '';
@@ -1256,7 +1303,7 @@ sub update_request_queue {
}
$output .= '';
} else {
- $output .= ''.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'
';
+ $output .= ''.&mt("For the following course/community requests an error occurred when removing requests from the pending queue:").'
';
foreach my $cnum (@warn_dels) {
my $showcourse;
if (ref($requesthash{$cnum.'_'.$queue})) {
@@ -1308,13 +1355,22 @@ sub get_student_counts {
sub course_creation {
my ($dom,$cnum,$context,$details,$logmsg,$newusermsg,$addresult,$enrollcount,$output,
- $keysmsg,$domdefs,$longroles) = @_;
+ $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'};
@@ -1322,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') {
@@ -1331,19 +1388,26 @@ 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);
+ $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 {
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};
+ my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift enrollstart enrollend accessstart accessend sections crosslists users uniquecode};
if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) {
my $emailenc = &escape($owneremail);
my $owner = $details->{'owner'}.':'.$details->{'domain'};
@@ -1352,6 +1416,9 @@ sub build_batchcreatehash {
}
$batchhash{'title'} = $details->{'cdescr'};
$batchhash{'coursecode'} = $details->{'instcode'};
+ if ($domdefs->{'officialcredits'} || $domdefs->{'unofficialcredits'}) {
+ $batchhash{'defaultcredits'} = $details->{'defaultcredits'};
+ }
$batchhash{'emailenc'} = $emailenc;
$batchhash{'adds'} = $details->{'autoadds'};
$batchhash{'drops'} = $details->{'autodrops'};
@@ -1360,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);
@@ -1696,8 +1769,21 @@ sub process_official_reqs {
}
$reqstatus = $disposition;
if ($disposition eq 'process') {
- my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg);
- my $result = &course_creation($dom,$cnum,'domain',$history{'details'},\$logmsg,\$newusermsg,\$addresult,\$enrollcount,\$response,\$keysmsg,\%domdefs,\%longroles);
+ my ($logmsg,$newusermsg,$addresult,$enrollcount,$response,$keysmsg,$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';
@@ -1721,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,
@@ -1840,7 +1937,7 @@ sub process_reqauthor {
unless ($env{'environment.canrequest.author'}) {
return ''.
&mt('You do not currently have rights to request an authoring space.').'
'.
- &mt('Please contact the [_1]helpdesk[_2].','',
+ &mt('Please contact the [_1]helpdesk[_2] for assistance.','',
'').'';
}
my $queued = &reqauthor_check();