From 22fb9365b5e861514b1c5748244ae928be0c8a67 Mon Sep 17 00:00:00 2001 From: Magdalena Holczik Date: Thu, 11 Jan 2024 10:23:34 +0100 Subject: [PATCH] fix inf checks --- .../teststrategy/preselect_task/addscalestandarderror.php | 7 +++++-- classes/teststrategy/preselect_task/mayberemovescale.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/classes/teststrategy/preselect_task/addscalestandarderror.php b/classes/teststrategy/preselect_task/addscalestandarderror.php index 47fb4e8b8..627ccbee4 100644 --- a/classes/teststrategy/preselect_task/addscalestandarderror.php +++ b/classes/teststrategy/preselect_task/addscalestandarderror.php @@ -181,14 +181,17 @@ protected function getplayedquestionsperscale(): array { * @return array */ protected function getnumberofremainingquestionsperscale(): array { + $maxattemptsperscale = $this->context['max_attempts_per_scale'] === -1 + ? INF + : $this->context['max_attempts_per_scale']; $pq = $this->getplayedquestionsperscale(); $catscales = $this->get_with_child_scales($this->context['catscaleid']); foreach ($catscales as $scaleid) { if (!array_key_exists($scaleid, $pq)) { - $remainingperscale[$scaleid] = $this->context['max_attempts_per_scale']; + $remainingperscale[$scaleid] = $maxattemptsperscale; continue; } - $remainingperscale[$scaleid] = $this->context['max_attempts_per_scale'] - count($pq[$scaleid]); + $remainingperscale[$scaleid] = $maxattemptsperscale - count($pq[$scaleid]); } return $remainingperscale; } diff --git a/classes/teststrategy/preselect_task/mayberemovescale.php b/classes/teststrategy/preselect_task/mayberemovescale.php index d6098dcf5..40ebb600b 100644 --- a/classes/teststrategy/preselect_task/mayberemovescale.php +++ b/classes/teststrategy/preselect_task/mayberemovescale.php @@ -62,7 +62,7 @@ public function run(array &$context, callable $next): result { ); } - if ($context['max_attempts_per_scale'] == 0) { + if ($context['max_attempts_per_scale'] == -1) { return $next($context); }