[LON-CAPA-cvs] cvs: loncom /enrollment localenroll.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Mon, 08 Dec 2003 16:00:15 -0000
raeburn Mon Dec 8 11:00:15 2003 EDT
Modified files:
/loncom/enrollment localenroll.pm
Log:
Modified to support enrollment from crosslisted classes.
Index: loncom/enrollment/localenroll.pm
diff -u loncom/enrollment/localenroll.pm:1.1 loncom/enrollment/localenroll.pm:1.2
--- loncom/enrollment/localenroll.pm:1.1 Fri Dec 5 12:03:05 2003
+++ loncom/enrollment/localenroll.pm Mon Dec 8 11:00:15 2003
@@ -19,8 +19,8 @@
if (defined $dbh) {
$dbflag = 1;
foreach my $crs (sort keys %{$affiliatesref}) {
- my $xmlfile = $$configvars{'lonDaemons'}."/tmp/".$dom."_".$crs."_classlist.xml";
- $$replyref{$crs} = &write_class_data ($dbh,$xmlfile,\@{$$affiliatesref{$crs}});
+ my $xmlstem = $$configvars{'lonDaemons'}."/tmp/".$dom."_".$crs."_";
+ $$replyref{$crs} = &write_class_data ($dbh,$xmlstem,\@{$$affiliatesref{$crs}});
}
$dbh->disconnect;
}
@@ -28,15 +28,17 @@
}
sub write_class_data {
- my ($dbh,$xmlfile,$coursesref) = @_;
+ my ($dbh,$xmlstem,$coursesref) = @_;
my $stucount = 0;
- open(FILE, ">$xmlfile");
- print FILE qq|<?xml version="1.0" encoding="UTF-8"?>
+ foreach my $class (@{$coursesref}) {
+ if ($class =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)(\d{3})$/) {
+ my $xmlfile = $xmlstem.$class."_classlist.xml";
+ open(FILE, ">$xmlfile");
+ print FILE qq|<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE text>
<students>
|;
- foreach my $class (@{$coursesref}) {
- if ($class =~ m/^([suf]s\d{2})(\w{2,3})(\d{3,4}\w?)(\d{3})$/) {
+
my $sth = $dbh->prepare("SELECT Pid,Pilot_Id,Student_Name FROM LONCAPA_ClassList WHERE Term_Code = '$1' AND Subj_Code = '$2' AND Crse_Code = '$3' AND Sctn_Code = '$4' ORDER BY Student_Name");
$sth->execute();
while ( my($pid,$pilot,$name) = $sth->fetchrow_array ) {
@@ -76,10 +78,10 @@
# If authentication, password, startdate or enddate are blank, the default for the course is used. These defaults can be modified using the Automated Enrollment Manager.
}
$sth->finish;
+ print FILE qq|</students>|;
+ close(FILE);
}
}
- print FILE qq|</students>|;
- close(FILE);
return $stucount;
}