When my customer said can we sync the enrollments with moodle, my brain insisted first on understanding the bigger picture before tackling the details. I must have used about 4 notebook pages trying to figure out what was talking to who and when....
Questions like,
- Who is synching with who?
- What exactly is synching?
- What part of the enrollment data is synching?
- Who will push data to who?
- How will moodle do this?
- Is moodle pulling or pushing?
- Do I need to make a new DB or table to push to in moodle?
- Did the user account have to exist in moodle?
- Did the course have to exist in moodle?
Edit 5/2/14 - My customer did not understand what I was asking and answered me *in-correctly. He verified that the record, account, was created in Genius, not moodle. Eventually, we sorted this out.
I got a message from another of my customers clients about this,
"Hi James, you don't have to wrote code to do the synching, moodle has internal functionality for synching the enrollments with another database. Im not an expert, but one other client we have said to set it up using the cron to run the following scripts
path_to_file\enrol_database_sync.php
path_to_file\auth_db_sync_users.php
"
Well, it was a start, but was mostly in-correct or in-complete, since those were files that used a much older version of moodle, I think 1.x. Neither of these files were involved in the solution.
EDIT - 5/2/14 - two weeks later and I was wrong about part of what I said here. We did also need to sync external DB Authentication. I am using Moodle 2.2, so the file names are a little different, but the concept is accurate.
Concepts that I had to get into my mental model
- The external DB is the Master
- Moodle pulls from the Master.
- The moodle pull from the master occurs when the sync.php file is executed.
- The moodle sync.php file should be called from cron.php - since cron.php should already be set up in your moodle instance.
- I could/should use a DOS .bat file to call the sync.php file.
- Have the cron.php script call the DOS .bat file.
- Moodle is the consumer of enrollment data coming from the external DB
- The external DB is rather simple, consisting of only two tables, of which only ONE is moodle interested in
- The table that moodle is interested in has only 4 columns (id, courseID, username and role).
- The course, user and role are the 3 bits of information that moodle needs to *sync to.
- Moodle will actually grab that data from the external DB and update itself.
- Moodle will initiate the grab by calling a specific core file called sync.php
- The sync.php file, for me, needed to be called at the command line.
- The sync.php file in my install is located at webroot/instance/enrol/database/cli.
- A windows .bat file is used to call the sync.php file from the command line.
- A trigger to call the bat file is necessary, so the cron.php script is a logical place.
- The sync.php script is automatically called when an account logs in.
Action 1 - cron.php execution
Action 2 - account logs into moodle.
Any idea how I would sync a database in a non enrollment situation? I want to flag either a database in moodle and have an external application look for it. If it was there, a download would get approved. Or preferably have moodle write a flag in the correct student record on an external myseql database. Any ideas how to do this?
ReplyDelete"The sync.php script is automatically called when an account logs in."
ReplyDeleteActually, this does not appear to be happening. Only the enrollments of the user logging in get updated. The mechanism is different from the sync.php.
Most ideal approach to Solve MySQL Max User Connection Error through MySQL Technical Support
ReplyDeleteThe MySQL database is both open source and simple to utilize yet the vast majority of the clients confronting issue when they execute embed as well as refresh of a large number of columns consistently and around then they need to confront this specialized hiccups. Well! We encourage you to tackle this issue through MySQL Remote Support or MySQL Remote Service. We give the help which flawlessly meets the specialized and operational administration desires. So rapidly take our help and investigate the best help with our specialists.
For More Info: https://cognegicsystems.com/
Contact Number: 1-800-450-8670
Email Address- info@cognegicsystems.com
Company’s Address- 507 Copper Square Drive Bethel Connecticut (USA) 06801
how to update username in external database?? i want to update user name in local but its not reflecting in external database. and username text field is not able access. please help me
ReplyDeleteNice Post!!
ReplyDeletePlease Look Here At - A healthy database is essential for your business's performance, uptime, and security. At RalanTech, we specialize in delivering comprehensive MySQL Database Health Check Service across the USA. Whether you're a startup or a large enterprise, our service ensures your MySQL infrastructure runs at peak efficiency.