--- loncom/interface/loncoursequeueadmin.pm 2020/08/22 02:05:53 1.52.2.2.2.3 +++ loncom/interface/loncoursequeueadmin.pm 2021/11/24 04:25:02 1.62 @@ -1,7 +1,7 @@ # The LearningOnline Network # Utilities to administer domain course requests and course self-enroll requests # -# $Id: loncoursequeueadmin.pm,v 1.52.2.2.2.3 2020/08/22 02:05:53 raeburn Exp $ +# $Id: loncoursequeueadmin.pm,v 1.62 2021/11/24 04:25:02 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -105,13 +105,13 @@ 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\n"], }); } 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\n"], }); if (ref($textstr) eq 'ARRAY') { push(@rawmsg,@{$textstr}); @@ -119,8 +119,8 @@ sub send_selfserve_notification { } 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"], + mt => 'Authoring requests in the following domain: [_1] have been reviewed.', + args => ["\n$contextdesc\n"], }); if (ref($textstr) eq 'ARRAY') { push(@rawmsg,@{$textstr}); @@ -128,8 +128,8 @@ sub send_selfserve_notification { } 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"], + mt => 'Account requests in the following domain: [_1] have been reviewed.', + args => ["\n$contextdesc\n"], }); if (ref($textstr) eq 'ARRAY') { push(@rawmsg,@{$textstr}); @@ -506,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') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { + unless (($context eq 'pending') || ($context eq 'displaypending') || ($context eq 'helpdesk')) { $output .= ''.&mt('Action').''; } $output .= ''.&mt('Requestor').''; @@ -528,6 +528,7 @@ sub build_queue_display { unofficial => 'Unofficial course', community => 'Community', textbook => 'Textbook course', + placement => 'Placement test', ); $output .= ''.&mt('Type').''. ''.&mt('Date requested').''. @@ -609,7 +610,7 @@ sub build_queue_display { } elsif ($context eq 'requestusername') { $row .= ''.$showtime.''."\n". ''.$detailslink.''."\n"; - } else { + } else { if ($context eq 'pending' || $context eq 'displaypending' || $context eq 'stillpending') { $row .= ''.$instcode.''."\n"; } else { @@ -879,10 +880,10 @@ sub update_request_queue { my $dbname = 'nohist_requestedusernames'; my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom); my %curr = &Apache::lonnet::get($dbname,[$uname],$cdom,$domconfiguser); - + if (ref($curr{$uname}) eq 'HASH') { - my ($username,$logtoken,$serverid,$encpass,$courseid,$id,$firstname, - $middlename,$lastname,$generation,$inststatus); + my ($logtoken,$serverid,$encpass,$courseid,$id,$firstname, + $middlename,$lastname,$generation,$inststatus,$email); $curr{$uname}{'timestamp'} = $now; $curr{$uname}{'adjudicator'} = $env{'user.name'}.':'.$env{'user.domain'}; $courseid = $curr{$uname}{'courseid'}; @@ -893,14 +894,35 @@ sub update_request_queue { $generation = $curr{$uname}{'generation'}; $inststatus = $curr{$uname}{'inststatus'}; - my ($key,$caller)=split(/&/,$curr{$uname}{'tmpinfo'}); - if ($caller eq 'createaccount') { - my $upass = &Apache::loncommon::des_decrypt($key,$curr{$uname}{'upass'}); + if ($curr{$uname}{'email'} ne '') { + $email = $curr{$uname}{'email'}; + } elsif ($uname =~ /^[^\@]+\@[^\@]+$/) { + $email = $uname; + } + + my $upass; + if ($curr{$uname}{'tmpinfo'}) { + my ($key,$caller)=split(/&/,$curr{$uname}{'tmpinfo'}); + if ($caller eq 'createaccount') { + if ($curr{$uname}{'upass'} eq '') { + $upass = $curr{$uname}{'upass'}; + } else { + $upass = &Apache::loncommon::des_decrypt($key,$curr{$uname}{'upass'}); + } + } else { + push(@processing_errors,$uname); + } + } else { + $upass = $curr{$uname}{'upass'}; + } + if ($upass eq '') { + push(@processing_errors,$uname); + } else { undef($curr{$uname}{'upass'}); my $result = &Apache::lonnet::modifyuser($cdom,$uname,$id,'internal',$upass, $firstname,$middlename,$lastname, - $generation,undef,undef,$uname); + $generation,undef,undef,$email); if ($result eq 'ok') { $curr{$uname}{'status'} = 'created'; push(@completed,$uname); @@ -921,8 +943,6 @@ sub update_request_queue { } else { push(@processing_errors,$uname); } - } else { - push(@processing_errors,$uname); } } else { push(@invalidusers,$uname); @@ -1627,7 +1647,7 @@ sub course_creation { $owneremail = $emails{$email}; last if ($owneremail ne ''); } - my %reqdetails = &build_batchcreatehash($dom,$context,$details,$owneremail,$domdefs); + my %reqdetails = &build_batchcreatehash($dom,$cnum,$context,$details,$owneremail,$domdefs); my $cid = &LONCAPA::batchcreatecourse::build_course($dom,$cnum,'requestcourses', \%reqdetails,$longroles,$logmsg,$clonemsg,$newusermsg,$addresult, $enrollcount,$output,$keysmsg,$ownerdom,$ownername,$cnum,$crstype, @@ -1649,7 +1669,7 @@ sub course_creation { } sub build_batchcreatehash { - my ($dom,$context,$details,$owneremail,$domdefs) = @_; + my ($dom,$cnum,$context,$details,$owneremail,$domdefs) = @_; my %batchhash; my @items = qw{owner domain coursehome clonecrs clonedom datemode dateshift tinyurls enrollstart enrollend accessstart accessend sections users uniquecode}; if ((ref($details) eq 'HASH') && (ref($domdefs) eq 'HASH')) { @@ -1661,7 +1681,14 @@ sub build_batchcreatehash { if (ref($details->{'crosslists'}) eq 'HASH') { foreach my $key (keys(%{$details->{'crosslists'}})) { if (ref($details->{'crosslists'}->{$key}) eq 'HASH') { - $batchhash{'crosslists'}{$key}{'inst'} = $details->{crosslists}->{$key}->{instcode}.$details->{crosslists}->{$key}->{instsec}; + my $instsec = $details->{crosslists}->{$key}->{instsec}; + $batchhash{'crosslists'}{$key}{'inst'} = $details->{crosslists}->{$key}->{instcode}; + my $crskey = $cnum.':'.$batchhash{'crosslists'}{$key}{'inst'}; + my %formatted = &Apache::lonnet::auto_instsec_reformat($dom,'clutter', + {$crskey => [$instsec]}); + if (ref($formatted{$crskey}) eq 'ARRAY') { + $batchhash{'crosslists'}{$key}{'inst'} .= $formatted{$crskey}->[0]; + } $batchhash{'crosslists'}{$key}{'loncapa'} = $details->{crosslists}->{$key}->{loncapa}; } } @@ -1678,12 +1705,16 @@ sub build_batchcreatehash { $batchhash{'authparam'} = $domdefs->{'auth_arg_def'}; if ($details->{'crstype'} eq 'community') { $batchhash{'crstype'} = 'Community'; + } elsif ($details->{'crstype'} eq 'placement') { + $batchhash{'crstype'} = 'Placement'; } else { if ($details->{'crstype'} eq 'textbook') { if ($details->{'clonecrs'} && $details->{'clonedom'}) { my %clonedfrom = &Apache::lonnet::coursedescription($details->{'clonedom'}.'_'.$details->{'clonecrs'}); $batchhash{'textbook'} = $clonedfrom{'description'}; } + } elsif ($details->{'crstype'} eq 'lti') { + $batchhash{'lti'} = 1; } $batchhash{'crstype'} = 'Course'; }