From feb95ba84633181833be10bfbe7078ba45ea1829 Mon Sep 17 00:00:00 2001 From: Markus Date: Tue, 3 Dec 2024 19:05:53 +0100 Subject: [PATCH] fix: only apply completiongradeitemnumber modification to elements completed via a grade --- .../upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php b/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php index 0c8910a..dd24a01 100644 --- a/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php +++ b/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php @@ -134,8 +134,12 @@ public function set_completion_to_auto(stdClass $cm_info, bool $view): void { $this->moodle_core_repository->update_course_module_record($cm_info->id, [ 'completion' => 2, 'completionpassgrade' => $view ? 0 : 1, - 'completionview' => $view ? 1 : 0, - 'completiongradeitemnumber' => 0 + 'completionview' => $view ? 1 : 0 ]); + if (!$view) { + $this->moodle_core_repository->update_course_module_record($cm_info->id, [ + 'completiongradeitemnumber' => 0 + ]); + } } } \ No newline at end of file