From de08af9e4a84d4b4083b66090bf67674354aa2b9 Mon Sep 17 00:00:00 2001 From: Michael Hawkins Date: Thu, 29 Apr 2021 13:08:50 +0800 Subject: [PATCH] MDL-71189 mod_quiz: Update completion rule descriptions method Allow for conditions that are not set, consistent with other modules. They will usually always be set in practice, but best to handle it, which also helps with unit testing. --- mod/quiz/classes/completion/custom_completion.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/quiz/classes/completion/custom_completion.php b/mod/quiz/classes/completion/custom_completion.php index 4c4085920fc..f8716043fc7 100644 --- a/mod/quiz/classes/completion/custom_completion.php +++ b/mod/quiz/classes/completion/custom_completion.php @@ -145,9 +145,9 @@ class custom_completion extends activity_custom_completion { * @return array */ public function get_custom_rule_descriptions(): array { - $minattempts = $this->cm->customdata['customcompletionrules']['completionminattempts']; + $minattempts = $this->cm->customdata['customcompletionrules']['completionminattempts'] ?? 0; - $completionpassorattempts = $this->cm->customdata['customcompletionrules']['completionpassorattemptsexhausted']; + $completionpassorattempts = $this->cm->customdata['customcompletionrules']['completionpassorattemptsexhausted'] ?? []; if (!empty($completionpassorattempts['completionattemptsexhausted'])) { $passorallattemptslabel = get_string('completiondetail:passorexhaust', 'mod_quiz'); } else { -- 2.11.4.GIT