I recently moved a Moodle 3.6.7 site to a new server and noticed errors popping up in the cron. Errors that relate to overdue quiz attempts. Here's the error I'm receiving:
Processing module function quiz_cron ...
Looking for quiz overdue quiz attempts...
Notice: Trying to get property of non-object in /var/www/moodle/mod/quiz/attemptlib.php on line 93 Error while processing attempt 1473 at 17 quiz: Coding error detected, it must be fixed by a programmer: Invalid context id specified context::instance_by_id() #0 /var/www/moodle/question/engine/questionusage.php(923): context::instance_by_id('0', 0) #1 /var/www/moodle/question/engine/datalib.php(484): question_usage_by_activity::load_from_records(Object(pgsql_native_moodle_recordset), '2973') #2 /var/www/moodle/question/engine/lib.php(84): question_engine_data_mapper->load_questions_usage_by_activity('2973') #3 /var/www/moodle/mod/quiz/attemptlib.php(588): question_engine::load_questions_usage_by_activity('2973') #4 /var/www/moodle/mod/quiz/cronlib.php(78): quiz_attempt->__construct(Object(stdClass), Object(stdClass), false, Object(stdClass)) #5 /var/www/moodle/mod/quiz/lib.php(598): mod_quiz_overdue_attempt_updater->update_overdue_attempts(1579126336, 1579126276) #6 /var/www/moodle/lib/classes/task/legacy_plugin_cron_task.php(93): quiz_cron() #7 /var/www/moodle/lib/cronlib.php(105): core\task\legacy_plugin_cron_task->execute() #8 /var/www/moodle/lib/cronlib.php(67): cron_run_inner_scheduled_task(Object(core\task\legacy_plugin_cron_task)) #9 /var/www/moodle/admin/cron.php(81): cron_run() #10 {main}The error repeats a few times with different id numbers on lines #1-3. It doesn't seem to be affecting anything in the site's performance but I'd still like to see 0 error messages if possible. I don't want this to cause other issues in the future.
Any idea what would causing this and how to fix it? Would the only fix be to get into the SQL and remove the attempt straight out of the database?
Currently I'm thinking something like "DELETE FROM mdl_quiz_attempts WHERE id = 2973;" (rough idea of the sql command I'd write) but don't want to miss something and cause more damage to the site if I've missed something.
Thanks for your time,
Rob