We have seen a few sites with databases in a weird state that prevents users from deleting their courses. All of them have a grade item that stops deletion. While we are not yet sure how the databases get in this weird state, it seems to me that busted grade_items preventing a course from being deleted in of itself might be considered a bug.
To reproduce on a fresh install:
- Create a course and add a scorm activity
- Delete the record that shows up in the mdl_scorm table
- Browse to "Site administration" > "Courses" > "Manage courses and categories"
- Attempt to delete the course you just made
- You should see an invalid module id error
This happens because the get_context method in grade_item.php makes a call to get_fast_modinfo without doing any checks to see if the instances array contains the key it is searching for: