[LON-CAPA-admin] Re: Automatic enrollmet

Stuart Peter Raeburn raeburn at msu.edu
Tue Oct 12 14:41:17 EDT 2004


Guy, 

fetch_enrollment was built to accommodate real-time updates of the xml 
files, i.e., when localenroll::fetch_enrollment() is called the idea was 
that it would contact the institutional data source to retrieve the latest 
data and populate the xml files.  The xml files are temporary and are 
deleted once the updates are complete. 

Currently, the return value from localenroll::fetch_enrollment is only used 
when the routine is called by a course coordinator via ENRL -> Automated 
Enrollment -> Update roster now.  When the routine is called by 
/home/httpd/perl/Autoenroll.pl as a nightly cron, the return value is  
logged, but does not influence the execution of the script (this may change, 
and a return value of 0 or 1 is required for future compatibility).  
Currently the decision on whether to perform auto-enrollment in a single 
course is only made if registered students are retrieved for the course from 
your institutional data (see comments about the replyhash below). 

If you write an external script to generate the student xml files you should 
store the xml files somewhere other than /home/httpd/perl/tmp/, and modify 
localenroll::fetch_enrollment() to copy files from your chosen "permanent" 
storage location to /home/httpd/perl/tmp/.  I am working under the 
assumption that your external script will run from a cron entry, and is not 
intended to be run on demand by a Course Coordinator.  If the external 
script can be run on demand to get the latest data from your instutional 
source then you should include a call to it within your customized version 
of localenroll::fetch_enrollment(). 

You must also include a number > 0 in the replyhash %{$replyref} for each of 
the keys of the hash (the keys are the course IDs), for which you want a 
check to determine whether auto-enrollment should occur.  The intent is that 
the value of $$replyref{$crs} should be set to the total number of 
registered students retrieved from the data source for all of the class 
sections affiliated with the courseID. 

As described in the commentary for localenroll: 

# The purpose of the %reply hash is to detect cases where the institutional
# enrollment is 0 (most likely due to a problem with the data source).
# In such a case, the LON-CAPA course roster is left unchanged (i.e., no
# students are expired, even if automated drops is enabled.) 

# If there were 10 students in fs03nop590001, 5 students in fs03nop59o601,
# 8 students in fs03nop590602, and 2 students in fs03ost580002,
# then $$reply{'43551dedcd43febmsul1'} = 25 

The stub version of fetch_enrollment() included with LON-CAPA 

sub fetch_enrollment {
   my ($dom,$affiliatesref,$replyref) = @_;
   foreach my $crs (sort keys %{$affiliatesref}) {
       $$replyref{$crs} = 0;
   }
   my $okflag = 0;
   return $okflag;
} 

At MSU customized is as follows: 

sub fetch_enrollment {
 my ($dom,$affiliatesref,$replyref) = @_;
 my ($dbh,$dbflag) = &connect_DB();
 if ($dbflag) {
    foreach my $crs (sort keys %{$affiliatesref}) {
        my $xmlstem =  $$configvars{'lonDaemons'}."/tmp/".$dom."_".$crs."_";
        my $pilotcount = 0;
        my $blankcount = 1;
        my $maxtries = 5;
        my $numtries = 0;
        while ( ($numtries < $maxtries) && ($blankcount > 0) ) {
            ($pilotcount,$blankcount) = &write_class_data 
($dbh,$xmlstem,\@{$$affiliatesref{$crs}});
            $numtries ++;
        }
        $$replyref{$crs} = $pilotcount;
    }
    &disconnect_DB($dbh);
 }
 return $dbflag;
} 

where &connect_DB connects to an MS-SQL database, and &write_class_data 
sends an SQL query to the database, retrieves the data, counts the number of 
retrieved records and writes the temporary xml files. 

Stuart Raeburn
MSU LON-CAPA support/development 


Guy Ashkenazi writes: 

> If I use an external script to generate the student list xml files in
> /home/httpd/perl/tmp/ , and have fetch_enrollment always return 1, will the
> automatic enrollment work? 
> 
>     Guy. 
> 
> _______________________________________________
> LON-CAPA-admin mailing list
> LON-CAPA-admin at mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-admin 
> 
 





More information about the LON-CAPA-admin mailing list