--- loncom/interface/loncoursequeueadmin.pm 2012/08/14 15:45:06 1.30 +++ loncom/interface/loncoursequeueadmin.pm 2020/08/22 02:05:53 1.52.2.2.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network # Utilities to administer domain course requests and course self-enroll requests # -# $Id: loncoursequeueadmin.pm,v 1.30 2012/08/14 15:45:06 raeburn Exp $ +# $Id: loncoursequeueadmin.pm,v 1.52.2.2.2.3 2020/08/22 02:05:53 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 { @@ -101,16 +110,25 @@ sub send_selfserve_notification { } elsif ($context eq 'domainmanagers') { $rawsubj = 'Course/Community requests reviewed'; push(@rawmsg,{ - mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.', + 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'; + $rawsubj = 'Authoring Space requests reviewed'; push(@rawmsg,{ - mt => 'Authoring requests in the following domain: [_1] have been reviewed.', + 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') { @@ -170,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, @@ -195,20 +213,19 @@ sub send_selfserve_notification { 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].'; + $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"], @@ -216,6 +233,43 @@ sub send_selfserve_notification { 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; @@ -233,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); @@ -245,52 +304,69 @@ sub send_selfserve_notification { my $stamp = time; my $msgcount = &Apache::lonmsg::get_uniq(); my $sender_lh = &Apache::loncommon::user_lang($uname,$udom,$cid); - $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj); + $subject = &mt_user($sender_lh,$rawsubj); $message = ''; foreach my $item (@rawmsg) { if (ref($item) eq 'HASH') { - $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n"; + $message .= &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); - my $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj); + my $subject = &mt_user($sender_lh,$rawsubj); my $message = ''; foreach my $item (@rawmsg) { if (ref($item) eq 'HASH') { - $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt}, - @{$item->{args}})."\n"; + $message .= &mt_user($sender_lh,$item->{mt}, + @{$item->{args}})."\n"; } } if ($context eq 'coursemanagers') { if ($approvedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist; + $message .= "\n\n".&mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist; } if ($rejectedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected enrollments:')."\n".$rejectedlist; + $message .= "\n\n".&mt_user($sender_lh,'Rejected enrollments:')."\n".$rejectedlist; } } elsif ($context eq 'domainmanagers') { if ($approvedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved course requests:')."\n".$approvedlist; + $message .= "\n\n".&mt_user($sender_lh,'Approved course requests:')."\n".$approvedlist; } if ($rejectedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected course requests:')."\n".$rejectedlist; + $message .= "\n\n".&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; + $message .= "\n\n".&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; + $message .= "\n\n".&mt_user($sender_lh,'Rejected author role requests:')."\n".$rejectedlist; + } + } elsif ($context eq 'usernamemanagers') { + if ($approvedlist) { + $message .= "\n\n".&mt_user($sender_lh,'Approved LON-CAPA account requests:')."\n".$approvedlist; + } + if ($rejectedlist) { + $message .= "\n\n".&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); } @@ -307,6 +383,11 @@ sub display_queued_requests { $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'; @@ -315,6 +396,8 @@ sub display_queued_requests { if ($context eq 'pending') { $disposition = 'pending'; $nextphase = 'requestvalidation'; + } elsif ($context eq 'displaypending') { + $disposition = 'pending'; } %requesthash = &Apache::lonnet::dump_dom($namespace,$dom,'_'.$disposition); $nextelement = ''; @@ -332,13 +415,16 @@ sub display_queued_requests { } 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') { my ($cnum,$disposition) = split('_',$item); $entry = $cnum.':'.$requesthash{$item}{'ownername'}.':'. $requesthash{$item}{'ownerdom'}.':'; - if ($context eq 'pending') { + if (($context eq 'pending') || ($context eq 'displaypending')) { $entry .= $requesthash{$item}{'instcode'}; } else { $entry .= $requesthash{$item}{'crstype'}; @@ -357,12 +443,16 @@ sub display_queued_requests { if (keys(%queue_by_date) > 0) { if ($context eq 'course') { $output .= '

'.&mt('Self-enrollment requests queued pending approval by a Coordinator').'

'; - } elsif ($context eq 'pending') { + } elsif (($context eq 'pending') || ($context eq 'displaypending')) { $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('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').'

'; + } elsif ($context eq 'requestusername') { + $output .= '

'.&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').'

'; } @@ -375,7 +465,9 @@ 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 '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.'); } @@ -384,8 +476,9 @@ sub display_queued_requests { if ($context eq 'pending') { $output .= '

'."\n". - '

'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '.&mt('Unvalidated requests will be listed for manual approval/rejection.').'

'; - } else { + '

'.&mt('Any course/community requests which are successfully validated will be created immediately.').' '. + &mt('Unvalidated requests will be listed for manual approval/rejection.').'

'; + } elsif (($context ne 'helpdesk') && ($context ne 'displaypending')) { $output .= '
'; } $output .= ''; @@ -393,8 +486,12 @@ sub display_queued_requests { $output .= '
'; if ($context eq 'course') { $output .= &mt('There are currently no enrollment requests awaiting approval.'); - } elsif ($context eq 'pending') { + } elsif (($context eq 'pending') || ($context eq 'displaypending')) { $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.'); } @@ -409,7 +506,7 @@ sub build_queue_display { my %crstypes; my $output = &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(); - unless ($context eq 'pending') { + unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { $output .= ''.&mt('Action').''; } $output .= ''.&mt('Requestor').''; @@ -418,7 +515,10 @@ sub build_queue_display { ''.&mt('Date requested').''; } elsif ($context eq 'requestauthor') { $output .= ''.&mt('Date requested').''; - } elsif ($context eq 'pending' || $context eq 'stillpending') { + } elsif ($context eq 'requestusername') { + $output .= ''.&mt('Date requested').''. + ''.&mt('Details').''; + } elsif ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { $output .= ''.&mt('Institutional code').''. ''.&mt('Date requested').''. ''.&mt('Details').''; @@ -427,6 +527,7 @@ sub build_queue_display { official => 'Official course', unofficial => 'Unofficial course', community => 'Community', + textbook => 'Textbook course', ); $output .= ''.&mt('Type').''. ''.&mt('Date requested').''. @@ -460,12 +561,21 @@ sub build_queue_display { &Apache::loncommon::plainname($request,$dom), $request,$dom); } + } elsif ($context eq 'requestusername') { + if (&Apache::lonnet::homeserver($request,$dom) eq 'no_host') { + my $queued = 'approval'; + $approve = $count.':'.$request; + $reject = $request; + $detailslink=''.$request.''; + $namelink = $request; + } } else { my ($cnum,$ownername,$ownerdom,$type,$cdesc); - my $queue = 'approval'; - if ($context eq 'pending' || $context eq 'stillpending') { + my $queued = 'approval'; + if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { ($cnum,$ownername,$ownerdom,$instcode,$cdesc)=split(/:/,$request,5); - $queue = 'pending'; + $queued = 'pending'; } else { ($cnum,$ownername,$ownerdom,$type,$cdesc)=split(/:/,$request,5); $crstype = $type; @@ -474,14 +584,14 @@ sub build_queue_display { } } $detailslink=''.$cdesc.''; + "'$dom','$cnum','$queued'".');">'.$cdesc.''; $approve = $count.':'.$cnum; $reject = $cnum; $namelink = &Apache::loncommon::aboutmewrapper( &Apache::loncommon::plainname($ownername,$ownerdom), $ownername,$ownerdom); } - unless ($context eq 'pending') { + unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { $row = ''. '