General help

Call external URL on course completion

 
Picture of Jairo Portela
Call external URL on course completion
 

Good morning everyone,

One of the things we would like to achieve with Moodle is that it should call an external URL when a student passes a course or a quiz, is this possible?

Any hints will be appreciated.

Thanks!


 
Average of ratings: -
Picture of Howard Miller
Re: Call external URL on course completion
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

An external URL to do what?

Regardless, I think it would require some coding. I have a similar system to notify our HR system when staff complete courses. It's a matter of trapping the completion event. However, in the real world it can get tricky. What happens if the external system is down (for example)?

 
Average of ratings: -
Picture of Jairo Portela
Re: Call external URL on course completion
 

That's exactly what we need, inform an external system that a course was completed.

I am not a PHP developer but I would appreciate seeing some of the code you wrote in that plugin.

And as you said, if the system is down there is got to be a contingency but it is supposed to be available most of the time since it is hosted in a cloud.

Thanks!

 
Average of ratings: -
Picture of Howard Miller
Re: Call external URL on course completion
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Help yourself, but do consider that this isn't very robust. A new/improved version is in the works - https://github.com/universityofglasgow/moodle/tree/gu33/local/corehr

This uses SOAP to call the external system but that could just be replaced by some curl calls. 

The Cloud == "somebody else's computer". They still break... I know this. big grin

 
Average of ratings: Useful (1)
Picture of Jairo Portela
Re: Call external URL on course completion
 

Thanks a lot for sharing the code Howard. I have another question about course completion event, is this event only raised by a Cron? I configured a course with one quiz and allowing users to mark as complete by themselves but the course_complete event is not raised even if the user marks the course as complete or passes the quiz...or at least I can't see it in the logs, any suggestions?


Thanks!

 
Average of ratings: -
Picture of Howard Miller
Re: Call external URL on course completion
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Yes - completion is raised by cron. It actually takes a minimum of two task runs from an activity completing to the course completing. So, it's far from instantaneous even if you run your cron every minute (as recommended). 

 
Average of ratings: Useful (1)
Floyd Saner - Tail of the Dragon, U.S. 129, NC
Re: Call external URL on course completion
Particularly helpful Moodlers

I agree with Howard - you will likely need to do some programming or create a plugin. Is there something you want to display after a student passes a course or a quiz?  You can always create a label (or any other activity, such as URL) that will display only when certain conditions (restrictions) are met.

Floyd 

 
Average of ratings: -