Error when submitting a quiz

Error when submitting a quiz

by Mike Huntsman -
Number of replies: 9
After upgrading, my students keep getting this message after completing a quiz and submitting.


An error occurred while processing your responses (Invalid course module ID). Click continue to return to the page you were on and try again


Any help? Thanks.

Average of ratings: -
In reply to Mike Huntsman

Re: Error when submitting a quiz

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moving to Quiz forum.... but I suggest switching on Debugging and doing it again. You should get a much fuller error message. 

In reply to Mike Huntsman

Re: Error when submitting a quiz

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Was this quiz imported or copied from another quiz?

In reply to Emma Richardson

Re: Error when submitting a quiz

by Mike Huntsman -

I'm not sure of your question. I made the quiz out of my database of questions and posted it as an activity . 

In reply to Mike Huntsman

Re: Error when submitting a quiz

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

I would try recreating it maybe - sounds like something maybe corrupted during the upgrade.

In reply to Mike Huntsman

Re: Error when submitting a quiz

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The odd thing about that message is that it is not very specifically linked to the inner workings of the quiz. The course-module ID is the generic identifier that Moodle uses to indentify courses. Every activity has one. At some point, the user must be getting redirected to a URL that contains the wrong cmid, but I can't think how that would happen.

If you could temporarily set Debugging to DEVELOPER level, then the error message would include a full stack trace, which might give more clues.


In reply to Tim Hunt

Re: Error when submitting a quiz

by Stanislav Shap -

Hey Tim,

I was having the same problem so I followed your advice and turned developer debugging mode on.

Here is the full report:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Notice: Trying to get property of non-object in /home1/shortcx0/public_html/main/lib/grade/grade_item.php on line 2499


An error occurred while processing your responses (Invalid course module ID (SELECT id,course FROM {course_modules} WHERE id IS NULL [array egg])). Click continue to return to the page you were on and try again.


Debug info: SELECT id,course FROM {course_modules} WHERE id IS NULL
[array (
)]
Error code: errorprocessingresponses


Stack trace:

  • line 2240 of /mod/quiz/attemptlib.php: moodle_exception thrown
  • line 89 of /mod/quiz/processattempt.php: call to quiz_attempt->process_attempt()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I also noticed that when I tried submitting the Quiz on an account that was already enrolled into the course before we upgraded to Moodle 3.6.2 the error did not occur. Because of this, I do not think the course could be corrupted.

Any help would be appreciated!

In reply to Stanislav Shap

Re: Error when submitting a quiz

by Stanislav Shap -

UPDATE:

Ok, so I have tried changing all of the possible settings I could change within the assignment where the error occurred, and still cannot find a reason why some assignments are getting this error and some not.

Although, this error has magically just "disappeared" and the only significant reason I see why is the fact that the account has been enrolled into the course for 12 hours now. I don't know if the 12 hours is just a coincidence but it is suspicious.

I tested it again and any new accounts I create still get the same error message. Even when I created a brand new assignment from scratch, the same error shows up.


Could time be effecting this error?

In reply to Stanislav Shap

Re: Error when submitting a quiz

by Stanislav Shap -
UPDATE #2


Ok, I solved the problem. I don't know if was having the same problem as the OP but I had a deleted/hidden assignment still floating around in the same grade book category as the non-working assignments were in. Once I moved the assignments into a new category it resolved the problem.

Average of ratings: Useful (1)
In reply to Stanislav Shap

Re: Error when submitting a quiz

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Good detective work. I am glad you have solved it.

However, it might be worth reporting this to the Tracker. The code where the original error came from was new in Moodle 3.6: https://github.com/moodle/moodle/blame/master/lib/grade/grade_item.php#L2496. That is related to MDL-27520, so it may be that something in that change is not working robustly on upgraded Moodle sites. It would be worth reporting that.

(I don't know anything about those changes myself. I just found this from the git history.)


Average of ratings: Useful (1)