MDL-79971 completion: Don't assume a completed activity is viewed

This commit is contained in:
Amaia Anabitarte
2024-06-28 10:14:46 +02:00
parent 5aef789ac6
commit de2adae485
2 changed files with 10 additions and 3 deletions
+4 -3
View File
@@ -1631,11 +1631,12 @@ class completion_info {
$data->coursemoduleid = $data->cmvcoursemoduleid;
$data->userid = $data->cmvuserid;
}
// When reseting all state in the completion, we need to keep current view state.
// We cannot assume the activity has been viewed, so we should check if there is any course_modules_viewed already.
$data->viewed = is_null($data->cmvuserid) ? 0 : 1;
unset($data->cmvcoursemoduleid);
unset($data->cmvuserid);
// When reseting all state in the completion, we need to keep current view state.
$data->viewed = 1;
}
return (array)$data;