This is the first full day where I have enabled this functionality in our moodle instance.
I have synched moodle to an external enrollment DB (table). With the execution of a script, moodle goes to the external DB , grabs enrollment data , compares it against current enrollments and makes enrollment insertions in the appropriate moodle course.
The external DB is the Master - it drives the slave (moodle enrollments in courses).
The master DB enrollment table that moodle is synched to is simple, consisting of four columns of data per record.
1) index
2) username
3) coursename
4) role
The username, coursename and role are what is pushed or synched to moodle.
Testing the push and pull
Assertions
When an enrollment is removed from the master enrollment table, the enrollment is also removed from the moodle course, AFTER THE sync script is run.When an enrollment is added to the master enrollment table, the enrollment is also added to the moodle course, AFTER THE sync script is run.
If an enrollment for a user IS ALREADY IN THE COURSE, moodle will not add another enrollment of that type (External datbase).
A enrollment can be manually added with the same username and course (matching credentials). Because the enrollment method is different. One is manual, the other external database.
My customer will have to halt all manual enrollments - batching in of files directly to moodle. All enrollments will now come from the external database.
When an enrollment is removed from the master table, only the matching external database enrollment is removed from the moodle course. In other words, if a user has a manual enrollment enrolment method record in the same course, it wont be removed.
The same account can have more than one Enrolment methods in a course, as you see below.
The studentjames account has two Enrolment methods records, manual and external database.
The execution of the sync script occurs when
1) the user logs onto moodle2) the sync script is explicitly called from cron.php
Since I have enabled the external DB plugin, it automatically calls the sync.php whenever a user login into moodle. Neat, ensures the user is always seeing up to date enrollment information. But, at a bit of a cost. Tradeoffs. The convenience of accurate enrollment info upon each login is a little overhead in the form of calling the sync.php script every time someone logs in.
The sync script is configured in moodle at the Plugins|Enrollments|Manage - enroll plugins
The sync script is located in the moodle_path/enrol/database/cli/sync.php
I am calling the sync.php script via a Windows bat file like this:
c:\wamp\bin\php\php5.3.13\php.exe -f c:\moodle_path\enrol\database\cli\sync.php -a
I am calling the sync.php script via the moodle cron.php file, like this.
/*
james added this call to the sync_enrollments_genius.bat file. This file calls the file sync.php
which causes moodle to grab a fresh enrollment snapshot from the externally linked DB geniusintegration
cool huh?
4/24/14
*/
system("cmd /c c:/wamp/www/sync_enrollments_genius.bat");
// end james what has to call for DB synch
Content of cron.php when executing
A brief summary then watson!
- Add enrollment record(s) to Master - run sync - enrollment(s) added to moodle course(s)
- Remove enrollment record(s) from Master - run sync - enrollment(s) removed from moodle course(s)
- Sync script is run when the user logs in and when the script is explicitly called
- The script is explicitly called by the native moodle cron script or any time the windows bat file is called.


No comments:
Post a Comment