Invalid course module ID

Invalid course module ID

by Kai Niethammer -
Number of replies: 3
in a specific course: when I try to add a new quiz activity I get the error message Invalid course ID.
The quiz does not get created.

the debug mode reveals this additional information:

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 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 541 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 1209 of /mod/quiz/lib.php: call to quiz_grade_item_update()
  • line 103 of /mod/quiz/lib.php: call to quiz_after_add_or_update()
  • line 128 of /course/modlib.php: call to quiz_add_instance()
  • line 168 of /course/modedit.php: call to add_moduleinfo()
The same error message gets displayed when I change activity completion criteria for an exiting H5P activity. However this time the changes get recognized and saved.

In this case the debug details are a bit different:

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 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 541 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 378 of /course/modlib.php: call to grade_regrade_final_grades()
  • line 666 of /course/modlib.php: call to edit_module_post_actions()
  • line 166 of /course/modedit.php: call to update_moduleinfo()
When I add a quiz to a different course in the same system it works as desired. Seems to be an issue of the course.

We are on Moodle 3.11.4 (Build: 20211108)

Any ideas where this comes from?


Average of ratings: -
In reply to Kai Niethammer

Re: Invalid course module ID

by Arnold Lamont -

Any progress with this error?   I am encountering the exact same error when trying to create a new Quiz in a course. 

In my case this is a recent development  as my backup of the course of 68 days ago does not have this error.

I am running Moodle 3.11.4+  (Build 20211126)

In reply to Kai Niethammer

Re: Invalid course module ID

by Randy Thornton -
There have been a number of issues related to course module errors in 3.11 and 4.0. Please take a look at the information in this Tracker and also perhaps the related trackers that it refers to. Perhaps one of those scenarios is the same as your situation.
In reply to Randy Thornton

Re: Invalid course module ID

by Arnold Lamont -
Thank you for the response Randy.

This morning my moodle functions perfectly without the issue of Module ID that I had yesterday. I made no changes.
But for now, I am fine again.

Best wishes