--- loncom/interface/lonpopulate.pm 2005/09/14 21:25:52 1.25
+++ loncom/interface/lonpopulate.pm 2005/11/04 21:34:05 1.31
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.25 2005/09/14 21:25:52 raeburn Exp $
+# $Id: lonpopulate.pm,v 1.31 2005/11/04 21:34:05 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -485,15 +485,11 @@ ENDTWO
ENDTWO
} elsif ($action eq "notify") {
- my @notified = ();
- if ($enrollvar{notifylist} =~ m/,/) {
- @notified = split/,/,$enrollvar{notifylist};
- } else {
- @notified = $enrollvar{notifylist};
- }
+ my $notifycount = 0;
+ my @notified = split(/,/,$enrollvar{notifylist});
my $notifycount = 0;
foreach (@notified) {
- unless ($_ eq '') { $notifycount ++; }
+ unless ($_ eq '') { $notifycount ++; }
}
my $noteset = '';
if ($notifycount) {
@@ -540,8 +536,8 @@ ENDTWO
my @roleinfo = split/:/,$_;
if ($roleinfo[0] eq 'cc') {
unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
- my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
- if ($active_cc eq 'ok') {
+ my $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
+ if ($active_cc eq 'active') {
push @ccs, "$roleinfo[1]\@$roleinfo[2]";
$pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
@@ -638,11 +634,9 @@ ENDTWO
");
} elsif ($action eq "crosslist") {
- my @xlists = ();
- if ($enrollvar{crosslistings} =~ m/,/) {
- @xlists = split/,/,$enrollvar{crosslistings};
- } elsif ($enrollvar{crosslistings} ne '') {
- $xlists[0] = $enrollvar{crosslistings};
+ my @xlists;
+ if ($enrollvar{crosslistings} ne '') {
+ @xlists = split(/,/,$enrollvar{crosslistings});
}
my $cross_str = @xlists;
$r->print("
@@ -671,7 +665,7 @@ ENDTWO
for (my $i=0; $i<@xlists; $i++) {
my $xl = ' ';
my $gp = ' ';
- if ($xlists[$i] =~ /(\w+):?(.*)$/) {
+ if ($xlists[$i] =~ /^([^:]+):?(.*)$/) {
$xl = $1;
$gp = $2;
}
@@ -723,14 +717,9 @@ ENDTWO
} elsif ($action eq "sections") {
my @sections = ();
@sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
- my @storedsections = ();
+ my @storedsections = split(/,/,$enrollvar{sectionnums});
my @currsections = ();
my %sec_id = ();
- if ($enrollvar{sectionnums} =~ m/,/) {
- @storedsections = split/,/,$enrollvar{sectionnums};
- } else {
- $storedsections[0] = $enrollvar{sectionnums};
- }
foreach (@storedsections) {
if ($_ =~ m/^(\w+):(\w*)$/) {
push @currsections, $1;
@@ -1488,18 +1477,13 @@ sub print_notify_response {
my %settings = &Apache::lonnet::get('environment',['internal.notifylist','internal.coursecode'],$dom,$crs);
my $notifylist = $settings{'internal.notifylist'};
my $coursecode = $settings{'internal.coursecode'};
- my @currpeople = ();
+ my @currpeople = split(/,/,$notifylist);
my $notify = 0;
my @people = ();
my $peoplestr = "";
my $response = "";
my $noprocess = 0;
- if ($notifylist =~ m/,/) {
- @currpeople = split/,/,$notifylist;
- } else {
- $currpeople[0] = $notifylist;
- }
my $currcount = 0;
foreach (@currpeople) {
unless ($_ eq '') { $currcount ++; }
@@ -1574,10 +1558,8 @@ sub print_crosslistings_menu () {
my $xliststr = '';
my $response = '';
my $coursecode = $settings{'internal.coursecode'};
- if ($settings{'internal.crosslistings'} =~ m/,/) {
- @currxlists = split/,/,$settings{'internal.crosslistings'};
- } elsif ($settings{'internal.crosslistings'} ne '') {
- $currxlists[0] = $settings{'internal.crosslistings'};
+ if ($settings{'internal.crosslistings'} ne '') {
+ @currxlists = split(/,/,$settings{'internal.crosslistings'});
}
if (@currxlists > 0) {
@@ -1600,11 +1582,8 @@ sub print_crosslistings_menu () {
}
}
- if ($crosscount > 1) {
- $xliststr = join(",",@xlists);
- } else {
- $xliststr = $xlists[0];
- }
+ $xliststr = join(",",@xlists);
+
my %cenv = ('internal.crosslistings' => $xliststr);
my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
if ($reply !~ /^ok$/) {
@@ -1682,10 +1661,8 @@ sub print_crosslistings_response () {
my $warning = '';
my $warn_prefix = '';
- if ($xliststr =~ m/,/) {
- @allxlists = split/,/,$xliststr;
- } else {
- unless ($xliststr eq '') { $allxlists[0] = $xliststr; }
+ if ($xliststr ne '') {
+ @allxlists = split(/,/,$xliststr);
}
if ( exists($env{'form.numcross'}) ) {
@@ -1717,11 +1694,8 @@ sub print_crosslistings_response () {
if (@xlists > 0 ) {
unless ($xliststr eq '') { $xliststr .= ","; }
- if (@xlists > 1) {
- $xliststr .= join(",",@xlists);
- } else {
- $xliststr .= $xlists[0];
- }
+ $xliststr .= join(",",@xlists);
+
my %cenv = ('internal.crosslistings' => $xliststr);
my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
if ($reply !~ /^ok$/) {
@@ -1736,12 +1710,7 @@ sub print_crosslistings_response () {
}
} else {
if ($xliststr =~ m/:/) {
- my @oldxlists = ();
- if ($xliststr =~ m/,/) {
- @oldxlists = split/,/,$xliststr;
- } else {
- $oldxlists[0] = $xliststr;
- }
+ my @oldxlists = (split/,/,$xliststr);
$response .= "Although no new crosslistings were added, the courses listed below continue to be crosslisted with your LON-CAPA course.