[LON-CAPA-cvs] cvs: loncom /enrollment Autoenroll.pl
raeburn
raeburn@source.lon-capa.org
Thu, 19 Aug 2010 22:36:59 -0000
raeburn Thu Aug 19 22:36:59 2010 EDT
Modified files:
/loncom/enrollment Autoenroll.pl
Log:
- Protect regexp inside \Q\E.
- Simplified args in call to Enrollment::update_LC().
- use lonnet::coursedescription to retrieve course enrollment settings.
Index: loncom/enrollment/Autoenroll.pl
diff -u loncom/enrollment/Autoenroll.pl:1.31 loncom/enrollment/Autoenroll.pl:1.32
--- loncom/enrollment/Autoenroll.pl:1.31 Thu Jan 8 16:58:04 2009
+++ loncom/enrollment/Autoenroll.pl Thu Aug 19 22:36:59 2010
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#
#Automated Enrollment script
-# $Id: Autoenroll.pl,v 1.31 2009/01/08 16:58:04 raeburn Exp $
+# $Id: Autoenroll.pl,v 1.32 2010/08/19 22:36:59 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -78,11 +78,10 @@
my %args = (
one_time => 1,
);
- my %coursehash = &Apache::lonnet::coursedescription($key,\%args);
- my $crs = $coursehash{'num'};
- next if ($coursehash{'domain'} ne $dom);
# Get course settings
- my %settings = &Apache::lonnet::dump('environment',$dom,$crs);
+ my %settings = &Apache::lonnet::coursedescription($key,\%args);
+ my $crs = $settings{'num'};
+ next if ($settings{'domain'} ne $dom);
%{$enrollvar{$crs}} = ();
@{$affiliates{$crs}} = ();
%{$LC_code{$crs}} = ();
@@ -118,7 +117,7 @@
if ($sec =~ m/^(\w+):(\w*)$/ ) {
my $course_id = $enrollvar{$crs}{coursecode}.$1;
my $gp = $2;
- if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
+ if (!grep/^\Q$course_id\E$/,@{$affiliates{$crs}}) {
push @{$affiliates{$crs}}, $course_id;
$LC_code{$crs}{$course_id} = $gp;
}
@@ -128,7 +127,7 @@
if ($xlist =~ m/^([^:]+):(\w*)$/) {
my $course_id = $1;
my $gp = $2;
- if (!grep/^$course_id$/,@{$affiliates{$crs}}) {
+ if (!grep/^\Q$course_id\E$/,@{$affiliates{$crs}}) {
push @{$affiliates{$crs}}, $course_id;
$LC_code{$crs}{$course_id} = $gp;
}
@@ -149,7 +148,7 @@
if ($reply{$crs} > 0) {
if ( ($enrollvar{$crs}{autostart} < $timenow) && ( ($enrollvar{$crs}{autoend} > $timenow) || ($enrollvar{$crs}{autoend} == 0) ) ) {
if (($enrollvar{$crs}{autoadds} == 1) || ($enrollvar{$crs}{autodrops} == 1)) {
- 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},\@{$affiliates{$crs}},\%{$LC_code{$crs}},\$logmsg,\$newusermsg,'automated');
+ 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},$affiliates{$crs},$LC_code{$crs},\$logmsg,\$newusermsg,'automated');
print $fh &mt('Messages start for [_1]',$crs)."\n";
print $fh "$logmsg\n";
print $fh &mt('Messages end for [_1]',$crs)."\n";