I was recently sent a message concerning a 2009 post where I uploaded my PHP script that connects our Moodle with our Student Information System (SIS). We are a K-12 school with all classes represented by a Moodle Course. We use Moodle as our online gradebook for all classes and obviously for our LMS as well. The current script is running on 3.5+. We used a version of it in 1.7,1.8, and 1.9. It was rewritten for 3.0 and ran on 3.0, 3.1, and 3.2 before we went to 3.5. I am not sure if I had to make changes during those upgrades.
The SIS (Student Information System) runs a nightly download of a CSV file. This file includes all enrollments in all classes. The headers are in the example file attached called SISmoodle.csv. This file is set to reside in a folder called moodleimport inside the dataroot location.
This can be changed in line 88 of the php file. In our case this is an FTP folder that the file downloads into.
Line 88 $customfileLocation = "$CFG->dataroot/moodleimport/SISmoodle.csv";
The PHP file can be kept anywhere and run from a nightly cron job or manually by putting in the url in any browser. The location should correspond to the location in line 86 if you run it manually. I would change the name of the file (like it is a password) so no one tries to run it from their own browser. It won't really hurt anything, but it takes a while and will slow down your site if there are several thousand users in the file.
Line 86 $returnurl = new moodle_url('/autouploaduser.php');
Lastly, you need to change line 92 to match your email domain. The script assumes email addresses are username@$defaultdomain in the script. There are no emails in our csv file.
Line 92 $defaultdomain = "@yourschool.edu";
This has been invaluable for us. Although teachers have to remove students that drop, new students are in the course and groups as soon as they are input into the student system.
Hope that helps!