[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncoursequeueadmin.pm
raeburn
raeburn at source.lon-capa.org
Tue Jul 2 09:55:53 EDT 2024
raeburn Tue Jul 2 13:55:53 2024 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface loncoursequeueadmin.pm
Log:
- For 2.11
Backport 1.68, 1.69
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.52.2.5 loncom/interface/loncoursequeueadmin.pm:1.52.2.6
--- loncom/interface/loncoursequeueadmin.pm:1.52.2.5 Thu Dec 9 18:14:44 2021
+++ loncom/interface/loncoursequeueadmin.pm Tue Jul 2 13:55:53 2024
@@ -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.5 2021/12/09 18:14:44 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.52.2.6 2024/07/02 13:55:53 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1629,12 +1629,12 @@
(ref($longroles) eq 'HASH')) {
return ('error: Invalid request');
}
- my ($result,$ownername,$ownerdom);
+ my ($result,$ownername,$ownerdom,$autocoowner);
my $crstype = $details->{'crstype'};
my $coursedesc = $details->{'cdescr'};
my $accessstart = $details->{'accessstart'};
my $accessend = $details->{'accessend'};
- my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses','autoenroll'],$dom);
if (ref($domconfig{'requestcourses'}) eq 'HASH') {
if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
if ($domconfig{'requestcourses'}{'uniquecode'}{$crstype}) {
@@ -1642,6 +1642,9 @@
}
}
}
+ if (ref($domconfig{'autoenroll'}) eq 'HASH') {
+ $autocoowner = $domconfig{'autoenroll'}{'co-owners'};
+ }
if ($context eq 'domain') {
$ownername = $details->{'owner'};
$ownerdom = $details->{'domain'};
@@ -1670,6 +1673,66 @@
$postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,$result,$ownername,
$ownerdom,$fullname,$coursedesc,$code,
$accessstart,$accessend,$customhash);
+ if ($autocoowner) {
+ my $instcode = $details->{'instcode'};
+ if (($instcode ne '') && (ref($reqdetails{'users'}) eq 'HASH')) {
+ my @posscoowners;
+ my $now = time;
+ foreach my $person (keys(%{$reqdetails{'users'}})) {
+ my ($uname,$udom) = split(/:/,$person);
+ next if (($udom ne $dom) || (($uname eq $ownername) && ($udom eq $ownerdom)));
+ if ((&Apache::lonnet::homeserver($uname,$udom,1) ne 'no_host') &&
+ (ref($reqdetails{'users'}{$person}) eq 'HASH')) {
+ if ((grep(/^cc$/,keys(%{$reqdetails{'users'}{$person}}))) &&
+ (ref($reqdetails{'users'}{$person}{'cc'}) eq 'HASH')) {
+ my $start = $reqdetails{'users'}{$person}{'cc'}{'start'};
+ my $end = $reqdetails{'users'}{$person}{'cc'}{'end'};
+ if ((($start eq '') || ($start <= $now)) &&
+ (($end eq '') || ($end >= $now))) {
+ push(@posscoowners,$person);
+ }
+ }
+ }
+ }
+ my @coowners;
+ if (@posscoowners) {
+ foreach my $user (@posscoowners) {
+ my ($checkcc,$desc) =
+ &Apache::lonnet::auto_validate_instcode($cnum,$dom,$instcode,$user);
+ unless ($checkcc eq 'valid') {
+ if (ref($reqdetails{'crosslists'}) eq 'HASH') {
+ foreach my $key (keys(%{$reqdetails{'crosslists'}})) {
+ if (ref($reqdetails{'crosslists'}{$key}) eq 'HASH') {
+ my $inst_crosslist = $reqdetails{'crosslists'}{$key}{'inst'};
+ if ($inst_crosslist ne '') {
+ $checkcc =
+ &Apache::lonnet::auto_validate_inst_crosslist($cnum,$dom,$instcode,
+ $inst_crosslist,$user);
+ last if ($checkcc eq 'valid');
+ }
+ }
+ }
+ }
+ }
+ if ($checkcc eq 'valid') {
+ if (@coowners > 0) {
+ unless (grep(/^\Q$user\E$/, at coowners)) {
+ push(@coowners,$user);
+ }
+ } else {
+ push(@coowners,$user);
+ }
+ }
+ }
+ }
+ if (@coowners > 0) {
+ my $chome = &Apache::lonnet::homeserver($cnum,$dom);
+ unless ($chome eq 'no_host') {
+ &Apache::lonnet::store_coowners($dom,$cnum,$chome,'', at coowners);
+ }
+ }
+ }
+ }
} else {
$result = 'error: '.$cid;
}
@@ -2253,7 +2316,7 @@
my %needcrsidput = (
'internal.selfenroll_types' => 1,
'internal.selfenroll_start_date' => 1,
- 'internal. selfenroll_end_date' => 1,
+ 'internal.selfenroll_end_date' => 1,
);
my (@needupdate,%newcrsenv);
foreach my $key (keys(%{$postprocessenv})) {
More information about the LON-CAPA-cvs
mailing list