--- loncom/interface/loncoursequeueadmin.pm 2011/08/26 15:57:56 1.28
+++ loncom/interface/loncoursequeueadmin.pm 2014/04/30 17:17:35 1.47
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.28 2011/08/26 15:57:56 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.47 2014/04/30 17:17:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -70,6 +70,14 @@ described at http://www.lon-capa.org.
=item process_official_reqs()
+=item is_active_author()
+
+=item author_prompt()
+
+=item reqauthor_check()
+
+=item process_reqauthor()
+
=back
=cut
@@ -82,6 +90,7 @@ use Apache::loncommon;
use Apache::lonmsg;
use Apache::lonlocal;
use Apache::lonuserutils;
+use LONCAPA::batchcreatecourse;
use LONCAPA qw(:DEFAULT :match);
sub send_selfserve_notification {
@@ -96,13 +105,31 @@ sub send_selfserve_notification {
$rawsubj = 'Self-enrollment requests processed';
push(@rawmsg,{
mt => 'Enrollment requests in the following course: [_1] have been processed.',
- args => ["\n $contextdesc"],
+ args => ["\n$contextdesc"],
});
} elsif ($context eq 'domainmanagers') {
$rawsubj = 'Course/Community requests reviewed';
push(@rawmsg,{
- mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.',
- args => ["\n $contextdesc"],
+ mt => 'Course/Community creation requests in the following domain: "[_1]" have been reviewed.',
+ args => ["\n$contextdesc"],
+ });
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
+ } elsif ($context eq 'authormanagers') {
+ $rawsubj = 'Authoring Space requests reviewed';
+ push(@rawmsg,{
+ mt => 'Authoring requests in the following domain: "[_1]" have been reviewed.',
+ args => ["\n$contextdesc"],
+ });
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
+ } elsif ($context eq 'usernamemanagers') {
+ $rawsubj = 'LON-CAPA account requests reviewed';
+ push(@rawmsg,{
+ mt => 'Account requests in the following domain: "[_1]" have been reviewed.',
+ args => ["\n$contextdesc"],
});
if (ref($textstr) eq 'ARRAY') {
push(@rawmsg,@{$textstr});
@@ -161,14 +188,14 @@ sub send_selfserve_notification {
},
{
mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.',
- args => ["\n","\n\n ","\n\n"],
+ args => ["\n","\n\n","\n\n"],
});
} elsif ($context eq 'selfenrollreq') {
$rawsubj = 'Self-enrollment request';
if ($crstype eq 'community') {
- $msgtxt = 'Enrollment in the following community: [_1] was requested by [_2] on [_3].'
+ $msgtxt = 'Enrollment in the following community: [_1]was requested by [_2] on [_3].'
} else {
- $msgtxt = 'Enrollment in the following course: [_1] was requested by [_2] on [_3].'
+ $msgtxt = 'Enrollment in the following course: [_1]was requested by [_2] on [_3].'
}
push(@rawmsg,{
mt => $msgtxt,
@@ -185,7 +212,64 @@ sub send_selfserve_notification {
mt => $directions,
args => [" \n\n","\n"],
});
-
+ } elsif ($context eq 'authorreq') {
+ $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 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.';
+ push(@rawmsg,{
+ mt => $msgtxt,
+ args => [$timestamp."\n"],
+ });
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
+ } elsif ($context eq 'usernamereq') {
+ $rawsubj = 'LON-CAPA account request';
+ $msgtxt = 'Creation of a LON-CAPA account 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
+ -> LON-CAPA account 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 'requestusername') {
+ $rawsubj = 'LON-CAPA account request';
+ $msgtxt = 'Your request for a LON-CAPA account requested on [_1]has been reviewed by a Domain Coordinator.';
+ push(@rawmsg,{
+ mt => $msgtxt,
+ args => [$timestamp."\n"],
+ });
+ 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;
@@ -203,9 +287,14 @@ sub send_selfserve_notification {
my %reciphash = (
cc => $msgcc,
);
- my ($uname,$udom);
+ my ($uname,$udom,$need_temp_env);
if ($sender =~ /:/) {
($uname,$udom) = split(/:/,$sender);
+ if ($context eq 'usernamereq') {
+ unless ($env{'user.name'} && $env{'user.domain'}) {
+ $need_temp_env = 1;
+ }
+ }
} elsif ($context eq 'course') {
$uname = $sender;
my %courseinfo = &Apache::lonnet::coursedescription($cid);
@@ -222,9 +311,14 @@ sub send_selfserve_notification {
$message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n";
}
}
- &Apache::lonmsg::process_sent_mail($subject,'',$numsent,$stamp,$uname,$udom,$msgcount,$cid,$$,$message,\@recusers,\@recudoms,undef,undef,undef,undef,$senderuname,$senderudom);
+ &Apache::lonmsg::process_sent_mail($subject,'',$numsent,$stamp,$uname,$udom,$msgcount,$cid,$$,$message,
+ \@recusers,\@recudoms,undef,undef,undef,undef,$senderuname,$senderudom);
my ($recipid,$recipstatus) = &Apache::lonmsg::store_recipients($subject,$uname,$udom,\%reciphash);
my $status;
+ if ($need_temp_env) {
+ $env{'user.name'} = $uname;
+ $env{'user.domain'} = $udom;
+ }
foreach my $recip (sort(keys(%{$msgcc}))) {
my ($ccname,$ccdom) = split(/:/,$recip);
my $recip_lh = &Apache::loncommon::user_lang($ccname,$ccdom,$cid);
@@ -250,10 +344,29 @@ sub send_selfserve_notification {
if ($rejectedlist) {
$message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected course requests:')."\n".$rejectedlist;
}
+ } elsif ($context eq 'authormanagers') {
+ if ($approvedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved author role requests:')."\n".$approvedlist;
+ }
+ if ($rejectedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected author role requests:')."\n".$rejectedlist;
+ }
+ } elsif ($context eq 'usernamemanagers') {
+ if ($approvedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved LON-CAPA account requests:')."\n".$approvedlist;
+ }
+ if ($rejectedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected LON-CAPA account requests:')."\n".$rejectedlist;
+ }
}
- $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,\%sentmessage,undef,undef,undef,1,$recipid).',';
+ $status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,
+ \%sentmessage,undef,undef,undef,1,$recipid).',';
}
$status =~ s/,$//;
+ if ($need_temp_env) {
+ undef($env{'user.name'});
+ undef($env{'user.domain'});
+ }
return ($recipstatus,$status);
}
@@ -265,6 +378,16 @@ sub display_queued_requests {
$namespace = 'selfenrollrequests';
%requesthash = &Apache::lonnet::dump($namespace,$dom,$cnum);
$nextelement = '';
+ } elsif ($context eq 'requestauthor') {
+ $formaction = '/adm/createuser';
+ $namespace = 'requestauthorqueue';
+ %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
+ $nextelement = '';
+ } elsif ($context eq 'requestusername') {
+ $formaction = '/adm/createuser';
+ $namespace = 'usernamequeue';
+ %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
+ $nextelement = '';
} else {
$formaction = '/adm/createcourse';
$namespace = 'courserequestqueue';
@@ -287,6 +410,12 @@ sub display_queued_requests {
if ($context eq 'course') {
($timestamp, my $usec) = split(/:/,$requesthash{$item});
$entry = $item.':'.$usec;
+ } elsif ($context eq 'requestauthor') {
+ $timestamp = $requesthash{$item};
+ ($entry) = ($item =~ /^($match_username)_approval$/);
+ } elsif ($context eq 'requestusername') {
+ $timestamp = $requesthash{$item};
+ ($entry) = (&unescape($item) =~ /^($match_username)_approval$/);
} else {
$timestamp = $requesthash{$item}{'timestamp'};
if (ref($requesthash{$item}) eq 'HASH') {
@@ -316,8 +445,12 @@ sub display_queued_requests {
$output .= '
'.&mt('Requests for official courses queued pending validation').'
'.
'
'.&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.').'
'.&mt('Requests for LON-CAPA accounts queued pending approval by a Domain Coordinator').'
';
} else {
- $output .= '
'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'
';
+ $output .= '
'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'
';
}
$output .= &build_queue_display($dom,$context,\%queue_by_date).
'';
@@ -327,6 +460,10 @@ sub display_queued_requests {
$output .= &mt('There are currently no enrollment requests awaiting approval.');
} 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.');
+ } elsif ($context eq 'requestusername') {
+ $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
} elsif ($context eq 'domain') {
$output .= &mt('There are currently no course or community requests awaiting approval.');
}
@@ -346,6 +483,10 @@ sub display_queued_requests {
$output .= &mt('There are currently no enrollment requests awaiting approval.');
} 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.');
+ } elsif ($context eq 'requestusername') {
+ $output .= &mt('There are currently no requests for LON-CAPA accounts awaiting approval.');
} else {
$output .= &mt('There are currently no course or community requests awaiting approval.');
}
@@ -367,6 +508,11 @@ sub build_queue_display {
if ($context eq 'course') {
$output .= '
';
+ }
+ if ($notifylist ne '') {
+ &send_selfserve_notification($notifylist,$chgmsg,undef,$domdesc,
+ $now,'usernamemanagers',$sender,
+ $approvedlist,$rejectedlist);
+ }
} else {
$chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
if (@completed) {
@@ -841,6 +1310,9 @@ sub update_request_queue {
}
my $syllabuslink =
&Apache::loncommon::syllabuswrapper($showcourse,$cnum,$cdom);
+ if ($codes{$cnum}) {
+ $syllabuslink .= &mt('Unique code: [_1]',$codes{$cnum});
+ }
$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);
+ $output .= '
'.$userlink.'
';
+ }
+ $output .= '
';
}
}
if (@limitexceeded) {
@@ -924,17 +1423,27 @@ sub update_request_queue {
}
}
if (@nopermissions) {
- $output .= '
'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'
';
- foreach my $cnum (@nopermissions) {
- my $showcourse;
- if (ref($requesthash{$cnum.'_'.$queue})) {
- $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
- } else {
- $showcourse = $cnum;
+ if ($context eq 'course') {
+ $output .= '
'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'