External Database Enrollment sync on course access?

External Database Enrollment sync on course access?

by Lee Howard -
Number of replies: 3
The docs say that the enrollments are synced when the user logs in.  I have a seperate system that handles registration and user authentication is linked with a custom auth plugin.  I would like to be able to add enrollments to a table for use by the External Database Enrollment plugin, and have those enrollments created in moodle when the user accesses the course. The user may already be logged in to moodle when the external enrollment table is updated.  Question is. . will the enrollment be added when the user tries to access the course or do I have to do something to sync the enrollment before linking them to it?


Thanks!

Average of ratings: -
In reply to Lee Howard

Re: External Database Enrollment sync on course access?

by Matt Wolf -

Thanks for posting this Lee. I have the same issue. I am using Magento as my external enrollment and a quasi single sign in using jFusion.

I am in a situation where I have to ask users to log out and back in to view their courses. 

If anyone knows of a solution to this, please post. 

In reply to Lee Howard

Re: External Database Enrollment sync on course access?

by Mathew Gancarz -
Picture of Core developers

Only way other than log in I am ware of is the sync script:

https://docs.moodle.org/28/en/External_database_enrolment#Synchronization_script

We have a cron job that runs it on an hourly basis, but there's nothing that prevents you from running it manually as needed. I wouldn't set it to run very frequently though, as the time it runs will scale with your number of users and courses (and the cpu speed of the machine running it and the network connection to your db and your db speed). Ours takes about a minute to run.

In reply to Mathew Gancarz

Re: External Database Enrollment sync on course access?

by Matt Wolf -

Thanks Mathew. We had that running every 5 minutes to solve our problem, but this causes a problem after the nightly backup where the jobs would be queued up on top of each other overwhelming our server. We switched it to every hour and it has been fine.

The other solution we have tinkered with is calling it from the order confirmation page in Magento, which if it executed quickly enough would solve our issue. However, our preference would be just to update the enrollments for the one user instead of running the full sync script.

Any suggestions? Wonder how difficult it would be to write a custom script that does this?