edit_module_post_actions() called *after* events raised

edit_module_post_actions() called *after* events raised

by Michael Hughes -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

I'm trying to understand why edit_module_post_actions() is called after events have been raised and documented: 

 * Common create/update module module actions that need to be processed as soon as a module is created/updaded.
 * For example:create grade parent category, add outcomes, rebuild caches, regrade, save plagiarism settings...
 * Please note this api does not trigger events as of MOODLE 2.6. Please trigger events before calling this api.

The update_moduleinfo() function raises the \code\event\course_module_updated event and then calls edit_module_post_actions(), which then passes the information to things like outcomes, grade book and plagiarism plugins.

The effect is that a plagiarism plugin's settings get saved after the event, which means if there it it needs to know when a modules is updated (e.g. the user turns Turnitin ON from it being OFF) by hooking in to the course_module_updated event, the event handler will have out dated plagiarism plugin information, as the plagiarism plugin has not yet saved the new values!

Average of ratings: -
In reply to Michael Hughes

Re: edit_module_post_actions() called *after* events raised

by Dan Poltawski -

I think I'd regard this is a bug, it looks like the code was just matching the old add_to_log call being fired before this happened.