Event when a quiz was removed

Event when a quiz was removed

by Mateus Brito -
Number of replies: 4
Hello

I am developing a plugin that notifies a system when a certain event occurs, for example, when a course is removed, through the '\core\event\course_deleted', the plugin I created performs a specific function, however I was unable to identify an event that occurs when a resource (quiz, chat, forum ...) is removed, I tested the event course_content_deleted but was also not triggered when a quiz or chat was removed.

Can anyone tell me if there is an event that is triggered when an activity is deleted, or if it is possible for me to add this via plugin? I believe that in this case I could only do it via a plugin if I added a specific interface for an activity to be removed, which is not what I want.
Average of ratings: -
In reply to Mateus Brito

Re: Event when a quiz was removed

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In reply to Davo Smith

Re: Event when a quiz was removed

by Mateus Brito -
Hi, thanks for the suggestion.

I had already tested the \core\event\course_module_deleted function and it is not called when a quiz or chat is removed. For safety, I took the test again after your answer, but the event did not occur after deleting a chat or quiz.

Actually your answer makes a lot of sense to me, in the plugin we also monitor the event when an activity is updated and the event \core\event\course_module_updated works perfectly for this, but event \core\event\course_module_deleted is not called on removal.
In reply to Mateus Brito

Re: Event when a quiz was removed

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I can confirm that course_module_deleted does work properly, but note that if you have the course recycle bin enabled for the site (which it is by default), then the activity is not actually deleted until the next time the cron process runs (as the recycle bin needs time to make a backup of the activity, before it deletes it, which could slow the UI down if it happened immediately).

If you disable the recycle bin, then the activity is deleted immediately (and, hence, the event is also triggered immediately).
Average of ratings: Useful (1)
In reply to Davo Smith

Re: Event when a quiz was removed

by Mateus Brito -
Thanks for your reply. I didn't know about the recycle bin feature, I disabled it and it worked as expected. Thank you very much smile