Trigger an external script on submission of quiz

Trigger an external script on submission of quiz

by Carl Brewer -
Number of replies: 3

G'day,

I've written a python script to generate a specific report out of the Moodle database for quiz attempts, and I need a way to trigger it from Moodle if possible.

I can run it from a command line, or a URL (I'd prefer a command line, but URL if necessary) - is there an easy-ish way to get moodle to run something like this when a quiz is completed (ie, when a candidate presses the "submit, yes, really, submit" button?  And pass some arguments?  I'd much rather this than run a cron job to check the database for recently completed quizzes, but if that's the only way, so be it.

Thank you!

Carl


Average of ratings: -
In reply to Carl Brewer

Re: Trigger an external script on submission of quiz

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Carl

As Tim says, Moodle has events so that would be the starting place. 

This plugin can register a url(I call it a webhook) with an event, and send the data from the event to the URL.


https://github.com/justinhunt/moodle-local_trigger

There might be a more direct way(writing a plugin would be one), but I think you could make this work