diff --git a/ajax.php b/ajax.php index b5b454de..28a3ac71 100644 --- a/ajax.php +++ b/ajax.php @@ -54,4 +54,7 @@ $element->posx = $value->posx; $element->posy = $value->posy; $DB->update_record('customcert_elements', $element); + \mod_customcert\event\element_updated::create_from_id($element->id, $template)->trigger(); } + +\mod_customcert\event\template_updated::create_from_template($template)->trigger(); diff --git a/classes/event/element_updated.php b/classes/event/element_updated.php index b323cd97..ae2b58a5 100644 --- a/classes/event/element_updated.php +++ b/classes/event/element_updated.php @@ -87,6 +87,23 @@ public static function create_from_element(\mod_customcert\element $element): el return self::create($data); } + /** + * Create instance of event for the specified element. + * + * @param int $elementid ID of the element. + * @param \mod_customcert\template $template Template containing the above + * element. + * @return element_updated + */ + public static function create_from_id(int $elementid, \mod_customcert\template $template): element_updated { + $data = [ + 'contextid' => $template->get_contextid(), + 'objectid' => $elementid, + ]; + + return self::create($data); + } + /** * Returns relevant URL. * @return \moodle_url