I have an observer that responds to the course completed event. Which sends data to an external application.
But if the connection fails, I want Moodle to reattempt.
I tried returning false from the observer function and throwing an error, but the function is never called again. Is it possible to do this?
This is for Moodle 3.0.10.
In local/myplugin/db/events.php
$observers = array(
array(
'eventname' => '\core\event\course_completed',
'callback' => 'local_myplugin_observer::course_completed',
),
);
In local/myplugin/classes/observer.php
class local_myplugin_observer {
/**
* Triggered when 'course_completed' event is triggered.
*
* @param \core\event\course_completed $event
* @return bool
*/
public static function course_completed(\core\event\course_completed $event) {
if (not able to connect to external system) {
// Tried return false;
// Tried throw new Exception('local_myplugin: not able to connect so will retry);
}
// Otherwise everything worked.
return true;
}