A course cannot be deleted if you create an Assignment activity and hide the whole module afterwards. I'm not sure if this happens only with Assignment, but I have tested with Quiz & Feedback and there was no errors.
Might be related to
MDL-64878 but this is still a problem in the latest 3.6.3+.
Steps to reproduce
1. Create a new course.
2. Go to the course and add a new Assignment activity.
3. Go to Site administration > Plugins > Activity modules > Manage activities and hide the Assignment module. Confirm that the module line is greyed out.
4. Go to Site administration > Courses > Manage courses and categories and try to delete the course you created in step 1.
The course is deleted.
The course is not deleted and an error is thrown.
Error: Invalid course module ID
Error code: invalidcoursemodule
line 236 of /lib/modinfolib.php: moodle_exception thrown
line 1684 of /mod/assign/locallib.php: call to course_modinfo->get_cm()
line 1617 of /mod/assign/locallib.php: call to assign->get_course_module()
line 569 of /mod/assign/submission/onlinetext/locallib.php: call to assign->get_instance()
line 753 of /mod/assign/locallib.php: call to assign_submission_onlinetext->delete_instance()
line 56 of /mod/assign/lib.php: call to assign->delete_instance()
line 5109 of /lib/moodlelib.php: call to assign_delete_instance()
line 4980 of /lib/moodlelib.php: call to remove_course_contents()
line 67 of /course/delete.php: call to delete_course()