MDL-52206 core: Add completion criteria to course_modules

This commit is contained in:
Peter 2019-12-04 10:14:31 +08:00 committed by Peter Dias
parent 663137748e
commit 90acd8d381
19 changed files with 113 additions and 17 deletions

View file

@ -711,7 +711,16 @@ class completion_info {
// Check grade
if (!is_null($cminfo->completiongradeitemnumber)) {
$newstate = $this->get_grade_completion($cminfo, $userid);
if ($newstate == COMPLETION_INCOMPLETE) {
if ($cm->completionpassgrade) {
// If we are asking to use pass grade completion but haven't set it,
// then default to COMPLETION_COMPLETE_PASS.
if ($newstate == COMPLETION_COMPLETE) {
return COMPLETION_COMPLETE_PASS;
} else if ($newstate != COMPLETION_COMPLETE_PASS) {
// Mark as incomplete if there is no grade provided or the grade has failed.
$newstate = COMPLETION_INCOMPLETE;
}
} else if ($newstate == COMPLETION_INCOMPLETE) {
return COMPLETION_INCOMPLETE;
}
}