From 5817dcf26f497e420b866b176e38b2377a14ff96 Mon Sep 17 00:00:00 2001 From: Noemie Ariste Date: Wed, 17 Jul 2024 14:23:44 +1200 Subject: [PATCH 1/2] Disable by default in courses with no recompletion config --- classes/recompletion_form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/recompletion_form.php b/classes/recompletion_form.php index 25893ad..c143fa5 100644 --- a/classes/recompletion_form.php +++ b/classes/recompletion_form.php @@ -64,7 +64,7 @@ public function definition() { self::RECOMPLETION_TYPE_ONDEMAND => get_string('recompletiontype:ondemand', 'local_recompletion'), self::RECOMPLETION_TYPE_SCHEDULE => get_string('recompletiontype:schedule', 'local_recompletion'), ]); - $mform->setDefault('recompletiontype', $config->recompletiontype ?? ''); + $mform->setDefault('recompletiontype', RECOMPLETION_TYPE_DISABLED); $mform->addHelpButton('recompletiontype', 'recompletiontype', 'local_recompletion'); $mform->addElement('checkbox', 'recompletionemailenable', get_string('recompletionemailenable', 'local_recompletion')); From 0ff76edf52bb40e8f2c21d00e02cae20bf0f7936 Mon Sep 17 00:00:00 2001 From: Noemie Ariste Date: Wed, 17 Jul 2024 14:42:52 +1200 Subject: [PATCH 2/2] Prevent user_reset from running when recompletion is not enabled in course --- classes/task/check_recompletion.php | 1 + 1 file changed, 1 insertion(+) diff --git a/classes/task/check_recompletion.php b/classes/task/check_recompletion.php index b092e1d..c841f91 100644 --- a/classes/task/check_recompletion.php +++ b/classes/task/check_recompletion.php @@ -259,6 +259,7 @@ public function reset_user($userid, $course, $config = null) { } if (empty($config->recompletiontype)) { $errors[] = get_string('recompletionnotenabledincourse', 'local_recompletion', $course->id); + return $errors; } $restrictions = local_recompletion_get_supported_restrictions();