--- loncom/enrollment/Enrollment.pm 2013/08/14 00:38:50 1.46 +++ loncom/enrollment/Enrollment.pm 2016/06/03 01:22:36 1.48 @@ -1,5 +1,5 @@ # Automated Enrollment manager -# $Id: Enrollment.pm,v 1.46 2013/08/14 00:38:50 raeburn Exp $ +# $Id: Enrollment.pm,v 1.48 2016/06/03 01:22:36 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,6 +61,7 @@ sub update_LC { my @activestudents = (); my @excludedstudents = (); my $currlist; + my $now = time; foreach my $uname (keys %{$roster} ) { if ($uname =~ m/^(.+):$dom$/) { if ($$roster{$uname}[$status] eq "Active") { @@ -196,9 +197,11 @@ sub update_LC { } } -# Explicitly allow access to creation/modification of students if called as an automated process. +# Explicitly allow access to creation/modification of students and group membership changes +# when called as an automated process. if ($context eq 'automated') { $env{'allowed.cst'}='F'; + $env{'allowed.mdg'}='F'; } # Compare IDs with existing LON-CAPA enrollment for this class @@ -339,6 +342,7 @@ sub update_LC { my ($auth,$authparam,$first,$middle,$last,$gene,$usec,$end,$start,$emailaddr,$pid,$emailenc,$credithours); &prepare_add($authtype,$autharg,$enddate,$startdate,\@stuinfo,\%place,\$dom,\$uname,\$auth,\$authparam,\$first,\$middle,\$last,\$gene,\$usec,\$end,\$start,\$emailaddr,\$pid,\$emailenc); # Check for existing account in this LON-CAPA domain for this username + next if (($end) && ($end < $now)); my $uhome=&Apache::lonnet::homeserver($uname,$dom); if ($uhome eq 'no_host') { # User does not exist my $args = {'auth' => $auth, @@ -444,9 +448,11 @@ sub update_LC { } } -# Terminated explictly allowed access to student creation/modification +# Terminated explictly allowed access to student creation/modification +# and group membership changes if ($context eq 'automated') { delete($env{'allowed.cst'}); + delete($env{'allowed.mdg'}); } if ($enrollcount > 0) { if ($context eq "updatenow") { @@ -651,7 +657,7 @@ sub prepare_add { $$start = $$stuinfo[ $$place{'startdate'} ]; $$emailaddr = $$stuinfo[ $$place{'email'} ]; $$pid = $$stuinfo[ $$place{'studentID'} ]; - + # remove non alphanumeric values from section $$usec =~ s/\W//g;