-
Bug
-
Resolution: Not a bug
-
Minor
-
None
-
4.5.2
-
None
-
MOODLE_405_STABLE
The 'check_mark_completion' cron task appears to have a code error.
When no records are returned to '$lmsviewed' it has the value 'false'.
When the code tries to use property 'timecreated' on '$lmsviewed' it throws an error since '$lmsviewed' is a boolean not an object.
Line 94
//Check viewed and mark it.
$lmsviewed = $DB->get_record('course_modules_viewed',
['coursemoduleid'=>$cm->id, 'userid'=>$gcrecord->userid]);
if (empty($lmsviewed)) {
$newviewed = new \stdClass();
if (isset($gcrecord->timemodified) && $gcrecord->timemodified > 0) {
//Set timemodified from goone completion table.
$lmsviewed->timecreated = $gcrecord->timemodified;
} else {
//Set timemodified as current timestamp as correct timemodified date not found.
$lmsviewed->timecreated = time();
}
$newviewed->timecreated = time();
$newviewed->coursemoduleid = $cm->id;
$newviewed->userid = $gcrecord->userid;
$DB->insert_record('course_modules_viewed', $lmsviewed);
goone_set_completion($cm, $gcrecord->userid, '', "completed");
}