[LON-CAPA-cvs] cvs: loncom /interface loncoursequeueadmin.pm
raeburn
raeburn at source.lon-capa.org
Sat Aug 19 19:32:13 EDT 2023
raeburn Sat Aug 19 23:32:13 2023 EDT
Modified files:
/loncom/interface loncoursequeueadmin.pm
Log:
- Bug 6982. Processing of course requests for "officiali" courses.
Co-ownership set automatically on course creation for Course Coordinator
roles assigned to verified instructor(s) of record (except requester/owner).
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.68 loncom/interface/loncoursequeueadmin.pm:1.69
--- loncom/interface/loncoursequeueadmin.pm:1.68 Sat Aug 19 23:23:05 2023
+++ loncom/interface/loncoursequeueadmin.pm Sat Aug 19 23:32:13 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.68 2023/08/19 23:23:05 raeburn Exp $
+# $Id: loncoursequeueadmin.pm,v 1.69 2023/08/19 23:32:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2653,12 +2653,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}) {
@@ -2666,6 +2666,9 @@
}
}
}
+ if (ref($domconfig{'autoenroll'}) eq 'HASH') {
+ $autocoowner = $domconfig{'autoenroll'}{'co-owners'};
+ }
if ($context eq 'domain') {
$ownername = $details->{'owner'};
$ownerdom = $details->{'domain'};
@@ -2695,6 +2698,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;
}
More information about the LON-CAPA-cvs
mailing list