--- loncom/enrollment/localenroll.pm 2003/12/05 17:03:05 1.1 +++ loncom/enrollment/localenroll.pm 2003/12/08 16:00:15 1.2 @@ -19,8 +19,8 @@ sub fetch_enrollment { 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 fetch_enrollment { } sub write_class_data { - my ($dbh,$xmlfile,$coursesref) = @_; + my ($dbh,$xmlstem,$coursesref) = @_; my $stucount = 0; - open(FILE, ">$xmlfile"); - print FILE qq| + 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| |; - 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 @@ sub write_class_data { # 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||; + close(FILE); } } - print FILE qq||; - close(FILE); return $stucount; }