MDL-81749 core_completion: Let custom rules to return failed state

This commit is contained in:
Amaia Anabitarte
2024-06-05 15:55:49 +02:00
parent 11a2641a13
commit 49ec843b18
6 changed files with 85 additions and 14 deletions
+5 -6
View File
@@ -714,16 +714,15 @@ class completion_info {
$completionstate = $this->get_core_completion_state($cminfo, $userid);
if (plugin_supports('mod', $cminfo->modname, FEATURE_COMPLETION_HAS_RULES)) {
$response = true;
$cmcompletionclass = activity_custom_completion::get_cm_completion_class($cminfo->modname);
if ($cmcompletionclass) {
/** @var activity_custom_completion $cmcompletion */
$cmcompletion = new $cmcompletionclass($cminfo, $userid, $completionstate);
$response = $cmcompletion->get_overall_completion_state() != COMPLETION_INCOMPLETE;
}
if (!$response) {
return COMPLETION_INCOMPLETE;
$customstate = $cmcompletion->get_overall_completion_state();
if ($customstate == COMPLETION_INCOMPLETE) {
return $customstate;
}
$completionstate[] = $customstate;
}
}