mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
89 stars 157 forks source link

518 Trigger created, updated and deleted events #546

Closed leonstr closed 1 year ago

leonstr commented 1 year ago

Add template_created, template_updated and template_deleted event classes, and trigger these as appropriate.

This is for issue #518. I think the main non-obvious changes are:

  1. edit.php line 204: Add if ($tid) {} so $template->save() isn't called after template::create() as I think it's is redundant in this scenario, and it prevents both created and updated events being triggered.
  2. template->copy_to_template() now takes the target instance as a parameter instead of just the ID. This is so that an event can be triggered for that target template.
  3. copy_to_template() uses context to determine if it's a site-wide template being copied (needing a created event), or a template being loaded at course level (needing an updated event). This feels a bit messy.
mdjnelson commented 1 year ago

Can you please rebase this and get all the tests passing, thanks. :)

mdjnelson commented 1 year ago

I am working on this now and adding some extra events and unit tests.

mdjnelson commented 1 year ago

Thanks. I ended up writing a fair few more events and wrote unit tests to ensure we aren't breaking anything. This took some time unfortunately which if I had known would not have started the work as there is a lot in the backlog. Oh well, it is done now. :)