version 1.34, 2016/09/14 20:58:27
|
version 1.36, 2021/12/28 02:04:35
|
Line 52
|
Line 52
|
foreach my $dom (@domains) { |
foreach my $dom (@domains) { |
#only run if configured to |
#only run if configured to |
my $run_enroll = 0; |
my $run_enroll = 0; |
my ($domsettings,$autofailsafe); |
my ($domsettings,$autofailsafe,$autofailsafetype); |
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['autoenroll','coursedefaults'],$dom); |
&Apache::lonnet::get_dom('configuration',['autoenroll','coursedefaults'],$dom); |
if (ref($domconfig{'autoenroll'}) eq 'HASH') { |
if (ref($domconfig{'autoenroll'}) eq 'HASH') { |
Line 63
|
Line 63
|
if ($domsettings->{'autofailsafe'} ne '') { |
if ($domsettings->{'autofailsafe'} ne '') { |
$autofailsafe = $domsettings->{'autofailsafe'}; |
$autofailsafe = $domsettings->{'autofailsafe'}; |
} |
} |
|
if ($domsettings->{'failsafe'} =~ /^(zero|any|off)$/) { |
|
$autofailsafetype = $domsettings->{'failsafe'}; |
|
} |
} else { |
} else { |
$run_enroll = &localenroll::run($dom); |
$run_enroll = &localenroll::run($dom); |
} |
} |
Line 74
|
Line 77
|
# Determine the courses |
# Determine the courses |
my %courses = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,\@hostids,'Course'); |
my %courses = &Apache::lonnet::courseiddump($dom,'.',1,'.','.','.',1,\@hostids,'Course'); |
my %affiliates = (); |
my %affiliates = (); |
|
my %unclutteredsec = (); |
|
my %unclutteredlcsec = (); |
my %enrollvar = (); |
my %enrollvar = (); |
my %reply = (); |
my %reply = (); |
my %LC_code = (); |
my %LC_code = (); |
Line 120
|
Line 125
|
$sections[0] = $enrollvar{$crs}{sectionnums}; |
$sections[0] = $enrollvar{$crs}{sectionnums}; |
} |
} |
if ($enrollvar{$crs}{crosslistings} =~ m/,/) { |
if ($enrollvar{$crs}{crosslistings} =~ m/,/) { |
@crosslistings = split/,/,$enrollvar{$crs}{crosslistings} |
@crosslistings = split/,/,$enrollvar{$crs}{crosslistings}; |
} else { |
} else { |
@crosslistings = $enrollvar{$crs}{crosslistings}; |
@crosslistings = $enrollvar{$crs}{crosslistings}; |
} |
} |
|
my $crscode = $enrollvar{$crs}{coursecode}; |
|
my $crskey = $crs.':'.$crscode; |
|
@{$unclutteredsec{$crskey}} = (); |
|
@{$unclutteredlcsec{$crskey}} = (); |
foreach my $sec (@sections) { |
foreach my $sec (@sections) { |
if ($sec =~ m/^(\w+):(\w*)$/ ) { |
if ($sec =~ m/^(\w+):(\w*)$/ ) { |
my $course_id = $enrollvar{$crs}{coursecode}.$1; |
my $instsec = $1; |
my $gp = $2; |
my $gp = $2; |
if (!grep/^\Q$course_id\E$/,@{$affiliates{$crs}}) { |
unless (grep/^\Q$instsec\E$/,@{$unclutteredsec{$crskey}}) { |
push @{$affiliates{$crs}}, $course_id; |
push(@{$unclutteredsec{$crskey}},$instsec); |
$LC_code{$crs}{$course_id} = $gp; |
push(@{$unclutteredlcsec{$crskey}},$gp); |
} |
} |
} |
} |
} |
} |
Line 147
|
Line 156
|
} |
} |
} |
} |
} |
} |
|
my %formattedsec = &Apache::lonnet::auto_instsec_reformat($dom,'clutter',\%unclutteredsec); |
|
foreach my $crskey (keys(%formattedsec)) { |
|
my ($crs,$instcode) = split(/:/,$crskey); |
|
if ((ref($formattedsec{$crskey}) eq 'ARRAY') && (ref($unclutteredlcsec{$crskey}) eq 'ARRAY')) { |
|
for (my $i=0; $i<@{$formattedsec{$crskey}}; $i++) { |
|
my $course_id = $instcode.$formattedsec{$crskey}[$i]; |
|
unless (grep/^\Q$course_id\E$/,@{$affiliates{$crs}}) { |
|
push(@{$affiliates{$crs}},$course_id); |
|
$LC_code{$crs}{$course_id} = $unclutteredlcsec{$crskey}[$i]; |
|
} |
|
} |
|
} |
|
} |
my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',\%affiliates,\%reply,$dom); |
my $outcome = &Apache::lonnet::fetch_enrollment_query('automated',\%affiliates,\%reply,$dom); |
|
|
# Now go through classes and perform required enrollment changes. |
# Now go through classes and perform required enrollment changes. |
Line 167
|
Line 189
|
if ($enrollvar{$crs}{'autodropfailsafe'}) { |
if ($enrollvar{$crs}{'autodropfailsafe'}) { |
$failsafe = $enrollvar{$crs}{'autodropfailsafe'}; |
$failsafe = $enrollvar{$crs}{'autodropfailsafe'}; |
} |
} |
my ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$enrollvar{$crs}{autoadds},$enrollvar{$crs}{autodrops},$enrollvar{$crs}{startdate},$enrollvar{$crs}{enddate},$enrollvar{$crs}{authtype},$enrollvar{$crs}{autharg},$showcredits,$defaultcredits,$failsafe,$affiliates{$crs},$LC_code{$crs},\$logmsg,\$newusermsg,'automated'); |
my $failsafetype = $autofailsafetype; |
|
if ($enrollvar{$crs}{'autodropfailsafetype'}) { |
|
$failsafetype = $enrollvar{$crs}{'autodropfailsafetype'}; |
|
} |
|
my ($changecount,$response) = &LONCAPA::Enrollment::update_LC($dom,$crs,$enrollvar{$crs}{autoadds},$enrollvar{$crs}{autodrops},$enrollvar{$crs}{startdate},$enrollvar{$crs}{enddate},$enrollvar{$crs}{authtype},$enrollvar{$crs}{autharg},$showcredits,$defaultcredits,$failsafe,$failsafetype,$$affiliates{$crs},$LC_code{$crs},\$logmsg,\$newusermsg,'automated'); |
print $fh &mt('Messages start for [_1]',$crs)."\n"; |
print $fh &mt('Messages start for [_1]',$crs)."\n"; |
print $fh "$logmsg\n"; |
print $fh "$logmsg\n"; |
print $fh &mt('Messages end for [_1]',$crs)."\n"; |
print $fh &mt('Messages end for [_1]',$crs)."\n"; |