-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
3.5.7, 3.6.6, 3.8
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_38_STABLE
-
MDL-66884_master
-
When creating a custom activity module, a "mod_form.php" file is required, which will be used as form to create or edit instances of said activity module. In this form, just before adding the submit and cancel buttons, there is the next function call:
$this->standard_coursemodule_elements() |
Which, as its own name says, loads the standard module elements (settings).
Now, for the problem that i've stumbled upon to. It seems like, if you want to have your activity module form without standard mod options and delete that line while having the course completion enabled, it will promp a Moodle exception (see screenshot ahead).
Following the error trace, I've run into the following chunk of code (on /course/moodleform_mod.php, function "definition_after_data"):
$mform->getElement('completionunlocked')->setValue(1) |
It does this twice: when nobody has completed the module yet or well when somebody has pressed the button to unlock the completion.
This could be easily solved surrounding those two lines with a statement that checks if "completionunlocked" field exists in the form.
I've already tried it several activity modules and it doesn't seems to have any weird behaviour, so I'll try to pull request it.