--- loncom/enrollment/Enrollment.pm 2021/09/08 12:13:13 1.55 +++ loncom/enrollment/Enrollment.pm 2022/02/03 17:37:57 1.58 @@ -1,5 +1,5 @@ # Automated Enrollment manager -# $Id: Enrollment.pm,v 1.55 2021/09/08 12:13:13 raeburn Exp $ +# $Id: Enrollment.pm,v 1.58 2022/02/03 17:37:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,6 +25,7 @@ # package LONCAPA::Enrollment; +use lib '/home/httpd/lib/perl'; use Apache::loncoursedata; use Apache::lonnet; use Apache::loncommon(); @@ -35,14 +36,13 @@ use HTML::Parser; use LONCAPA::Configuration; use Math::Random; use Time::Local; -use lib '/home/httpd/lib/perl'; use strict; sub update_LC { my ($dom,$crs,$adds,$drops,$startdate,$enddate,$authtype,$autharg, - $showcredits,$defaultcredits,$autofailsafe,$classesref,$groupref, - $logmsg,$newusermsg,$context,$phototypes) = @_; + $showcredits,$defaultcredits,$autofailsafe,$failsafe,$classesref, + $groupref,$logmsg,$newusermsg,$context,$phototypes) = @_; # Get institutional code and title of this class my %courseinfo = (); &get_courseinfo($dom,$crs,\%courseinfo); @@ -452,11 +452,20 @@ sub update_LC { # Check enrollment count for institutional section of student to be dropped if ($$currlist{$uname}[$instidx]) { if (exists($classcount{$$currlist{$uname}[$instidx]})) { - if ($classcount{$$currlist{$uname}[$instidx]} == 0) { + if ($failsafe eq 'any') { if ($autofailsafe) { - push(@{$delaydrops{$$currlist{$uname}[$instidx]}},$uname); + push(@{$delaydrops{$$currlist{$uname}[$instidx]}},$uname); next; } + } else { + unless ($failsafe eq 'off') { + if ($classcount{$$currlist{$uname}[$instidx]} == 0) { + if ($autofailsafe) { + push(@{$delaydrops{$$currlist{$uname}[$instidx]}},$uname); + next; + } + } + } } } } @@ -479,7 +488,11 @@ sub update_LC { foreach my $class (keys(%delaydrops)) { if (ref($delaydrops{$class}) eq 'ARRAY') { if ($autofailsafe < scalar(@{$delaydrops{$class}})) { - $$logmsg .= &mt('The following students were not expired from the old section [_1] because the enrollment count retrieved for that institutional section was zero, and the number of students with roles to expire exceeded the failsafe threshold of [_2]:',$class,$autofailsafe); + if ($failsafe eq 'any') { + $$logmsg .= &mt('The following students were not expired from the old section [_1] because the number of students with roles to expire exceeded the failsafe threshold of [_2], set to apply when the enrollment retrieved for an institutional section is zero or greater:',$class,$autofailsafe); + } else { + $$logmsg .= &mt('The following students were not expired from the old section [_1] because the enrollment count retrieved for that institutional section was zero, and the number of students with roles to expire exceeded the failsafe threshold of [_2]:',$class,$autofailsafe); + } if ($context eq "updatenow") { $$logmsg .= '
'.join('
',@{$delaydrops{$class}}).$linefeed; } elsif ($context eq "automated") { @@ -566,7 +579,7 @@ sub create_newuser { my $pid = $args->{'pid'}; my $first = $args->{'first'}; my $middle = $args->{'middle'}; - my $last = $args->{'last'} ; + my $last = $args->{'last'}; my $gene = $args->{'gene'}; my $usec = $args->{'usec'}; my $end = $args->{'end'};