Moodle version: 3.0.2
I should make this suggestion as a Moodle Tracker issue. But, new user signup there is currently disabled. So, I mention in here before I forget.
The mod_scorm_mod_form class ( vide moodle\mod\scorm\mod_form.php ) derives from the moodleform_mod class ( vide moodle\course\moodleform_mod.php ). mod_scorm_mod_form overrides the set_data() function, and does the following.
- Make some changes to the given $defaultvalues.
- Call data_preprocessing(), which is an override of the parent's data_preprocessing() but does not call the parent function.
- Call parent::set_data().
However, in the parent moodleform_mod::set_data(), data_preprocessing() is also called.
This results in mod_scorm_mod_form::data_preprocessing() being called twice. I think that this is unnecessary, and I suggest the following changes.
- Do not call data_preprocessing() in mod_scorm_mod_form::set_data().
- The rest of what mod_scorm_mod_form::set_data() does is make changes to the given $defaultvalues. Thus, it could be moved to mod_scorm_mod_form::data_preprocessing.
- That leaves mod_scorm_mod_form::set_data() with nothing to do. Thus, it can be eliminated.
Another result of the current code is that the parent moodleform_mod::data_preprocessing() is never called. There could be a good reason why it should not be called when editing a SCORM activity. But if not, then I additionally suggest the following changes.
- In mod_scorm_mod_form::data_preprocessing(), call parent::data_preprocessing(), likely at the beginning of the function.