Can not find data record in database table context. in Moodle 2.9.2+

Can not find data record in database table context. in Moodle 2.9.2+

by Bob Martens -
Number of replies: 0

We have a certain course which is getting these errors on certain quizzes:

"Can not find data record in database table context."

The resulting page is also incomplete, it is missing the header on the HTML page.

Turning on debugging, these are the error message that we get:

Quiz A, attempting quiz:

Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => '8795',
)]
Error code: invalidrecord
Stack trace:
* line 1453 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
* line 1429 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
* line 5412 of /lib/accesslib.php: call to moodle_database->get_record()
* line 1318 of /lib/questionlib.php: call to context::instance_by_id()
* line 1001 of /mod/quiz/attemptlib.php: call to question_has_capability_on()
* line 1464 of /mod/quiz/attemptlib.php: call to quiz_attempt->get_display_options_with_edit_link()
* line 1448 of /mod/quiz/attemptlib.php: call to quiz_attempt->render_question_helper()
* line 476 of /mod/quiz/renderer.php: call to quiz_attempt->render_question()
* line 436 of /mod/quiz/renderer.php: call to mod_quiz_renderer->attempt_form()
* line 148 of /mod/quiz/attempt.php: call to mod_quiz_renderer->attempt_page()

Quiz A, viewing student attempt:

Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => '8795',
)]
Error code: invalidrecord
Stack trace:
* line 1453 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
* line 1429 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
* line 5412 of /lib/accesslib.php: call to moodle_database->get_record()
* line 1318 of /lib/questionlib.php: call to context::instance_by_id()
* line 1001 of /mod/quiz/attemptlib.php: call to question_has_capability_on()
* line 1464 of /mod/quiz/attemptlib.php: call to quiz_attempt->get_display_options_with_edit_link()
* line 1448 of /mod/quiz/attemptlib.php: call to quiz_attempt->render_question_helper()
* line 186 of /mod/quiz/renderer.php: call to quiz_attempt->render_question()
* line 56 of /mod/quiz/renderer.php: call to mod_quiz_renderer->questions()
* line 259 of /mod/quiz/review.php: call to mod_quiz_renderer->review_page()

Quiz B, attempt

Debug info: SELECT * FROM {context} WHERE id = ?
[array (
0 => '8795',
)]
Error code: invalidrecord
Stack trace:
* line 1453 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
* line 1429 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
* line 5412 of /lib/accesslib.php: call to moodle_database->get_record()
* line 1318 of /lib/questionlib.php: call to context::instance_by_id()
* line 1001 of /mod/quiz/attemptlib.php: call to question_has_capability_on()
* line 1464 of /mod/quiz/attemptlib.php: call to quiz_attempt->get_display_options_with_edit_link()
* line 1448 of /mod/quiz/attemptlib.php: call to quiz_attempt->render_question_helper()
* line 476 of /mod/quiz/renderer.php: call to quiz_attempt->render_question()
* line 436 of /mod/quiz/renderer.php: call to mod_quiz_renderer->attempt_form()
* line 148 of /mod/quiz/attempt.php: call to mod_quiz_renderer->attempt_page()

Looking at the database itself, I find no mention of a context within mdl_context with that ID number. Any help to track down what might be going on would be greatly appreciated.

Average of ratings: -