Hi there thanks for the reply!
Here's what I did immediately before the problem and the error trace. I'm using the latest version of Moodle 3.7.1 (Build 20190708)
I only have this problem on the completion report for a single course. (This course was prepared from scratch as a new course over the past week). The completion report was working perfectly with data contained from about 8 people who had tested the course. We realized there was an issue with one of the completion requirements and had to change them. In doing so we had to unlock and clear the completion data in order to change the completion setting. We did that... but when I went to look at the new completion report (after running the cron to recreate the completion data) we hit the error that displays the following:
Notice: Trying to get property 'id' of non-object in /home/forge/solearn.ca/completion/criteria/completion_criteria_course.php on line 138
Can't find data record in
database table course.
More information about this error
×Debug info: SELECT id,category FROM {course} WHERE id IS NULL
[array (
)]
Error code: invalidrecord
×Stack trace:
line 1546 of /lib/dml/moodle_database.php: dml_missing_record_exception thrown
line 1522 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 6818 of /lib/accesslib.php: call to moodle_database->get_record()
line 138 of /completion/criteria/completion_criteria_course.php: call to context_course::instance()
line 409 of /report/completion/index.php: call to completion_criteria_course->get_title_detailed()
As you can see the stack trace is exactly what the
OP experienced in his error as well. I've tried the following things to rectify the situation:
We've tested other courses and they are all showing the completion report as normal... the activity report renders perfectly as well so we can see that
activities are completing. Near as I can tell is that unlocking the completion data removed a record that the report is looking for. But we can't figure out how to recreate that record.
1. Running the cron over and over, and then specifically running the tasks that deal with cleanup... all of the cron jobs are completing succesfully in the log...
2. Tried turning off completion (both activity completion and the course completion settings) and then reenabling them in the hopes that whatever record its looking for would recreate and it did not do so.
3. Tried duplicating the course by backing it up and restoring it as a new course. The new course encounters the same error.
That's all I have at the moment. Any help would be monumentally appreciated.
Cheers,
James