-
Bug
-
Resolution: Fixed
-
Major
-
3.9.10, 3.10.7, 3.11.3
-
MOODLE_310_STABLE, MOODLE_311_STABLE, MOODLE_39_STABLE
-
MOODLE_311_STABLE
-
MDL-72771_master -
So as reported in MDL-64868 (closed as inactive), there is a certain case that can complete break a quiz when you duplicate it. Although there was a specific step that ticket didn't have that is currently required to reproduce it.
- Have a topic that is visible, and one that is hidden
- In the visible category, create a quiz with activity completion set to Show activity as complete when conditions are met > Student must receive a grade to complete this activity. You don't need to add anything to the quiz/do anything with it.
- Duplicate the quiz
- Without reloading the page, move the duplicate quiz to the hidden category using the move arrow
- Now try to access new quiz.
I have confirmed on the latest 3.11.3+ that you will see:
Invalid course module ID
|
More information about this error
|
Debug info:
|
Error code: invalidcoursemodule
|
Stack trace:
|
* line 236 of /lib/modinfolib.php: moodle_exception thrown
|
* line 2677 of /lib/moodlelib.php: call to course_modinfo->get_cm()
|
* line 56 of /mod/quiz/view.php: call to require_login()
|
Basically the module no longer exists in a course_section record (and especially not one that matches its course_modules section value).
If you have enough debugging on, you can see that during the rest call to move the module, this happened:
Invalid course module ID
|
invalidcoursemodule
|
* line 236 of /lib/modinfolib.php: moodle_exception thrown
|
* line 1890 of /lib/modinfolib.php: call to course_modinfo->get_cm()
|
* line 1041 of /lib/completionlib.php: call to cm_info::create()
|
* line 623 of /lib/completionlib.php: call to completion_info->get_data()
|
* line 1434 of /lib/completionlib.php: call to completion_info->update_state()
|
* line 1203 of /lib/grade/grade_grade.php: call to completion_info->inform_grade_changed()
|
* line 367 of /lib/grade/grade_object.php: call to grade_grade->notify_changed()
|
* line 1033 of /lib/grade/grade_grade.php: call to grade_object->insert()
|
* line 653 of /lib/grade/grade_category.php: call to grade_grade->insert()
|
* line 567 of /lib/grade/grade_category.php: call to grade_category->aggregate_grades()
|
* line 809 of /lib/grade/grade_item.php: call to grade_category->generate_grades()
|
* line 1276 of /lib/gradelib.php: call to grade_item->regrade_final_grades()
|
* line 448 of /lib/gradelib.php: call to grade_regrade_final_grades()
|
* line 812 of /mod/quiz/lib.php: call to grade_get_grades()
|
* line 7917 of /lib/moodlelib.php: call to quiz_grade_item_update()
|
* line 915 of /course/lib.php: call to component_callback()
|
* line 1752 of /course/lib.php: call to set_coursemodule_visible()
|
* line 86 of /course/rest.php: call to moveto_module()
|
The root of the problems seems to be in course/lib.php::moveto_module(). The problem is that the function first removes the module from the section, which is now an invalid DB state, and then updates visibility, before finally placing it into the new section.
The important part is that you shouldn't call set_coursemodule_visible() while the DB is in an invalid state.