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!