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.
This commit is contained in:
Michael Hawkins
2021-05-03 13:42:23 +08:00
parent 70b16bb87c
commit de08af9e4a
@@ -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 {