From 693e9736dca2b157a126d7e3ff63c4f2b88407b9 Mon Sep 17 00:00:00 2001 From: Nils Haagen Date: Fri, 11 Feb 2022 11:43:37 +0100 Subject: [PATCH] TA: 21997, do not (auto)save over max passes. --- Modules/Test/classes/class.ilTestOutputGUI.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php index a1a82875a6fc..eca487454872 100755 --- a/Modules/Test/classes/class.ilTestOutputGUI.php +++ b/Modules/Test/classes/class.ilTestOutputGUI.php @@ -619,6 +619,16 @@ public function saveQuestionSolution($authorized = true, $force = false) return false; } } + + /* + #21097 - exceed maximum passes + this is a battle of conditions; e.g. ilTestPlayerAbstractGUI::autosaveOnTimeLimitCmd forces saving of results. + However, if an admin has finished the pass in the meantime, a new pass should not be created. + */ + if ($force && $this->isNrOfTriesReached()) { + $force = false; + } + // save question solution if ($this->canSaveResult() || $force) { // but only if the ending time is not reached @@ -655,7 +665,7 @@ public function saveQuestionSolution($authorized = true, $force = false) } } - if ($this->saveResult == false || (!$questionOBJ->validateSolutionSubmit() && $questionOBJ->savePartial()) ) { + if ($this->saveResult == false || (!$questionOBJ->validateSolutionSubmit() && $questionOBJ->savePartial())) { $this->ctrl->setParameter($this, "save_error", "1"); $_SESSION["previouspost"] = $_POST; } @@ -678,7 +688,7 @@ protected function showInstantResponseCmd() } $this->testSequence->setQuestionChecked($questionId); $this->testSequence->saveToDb(); - } else if ($this->object->isForceInstantFeedbackEnabled()) { + } elseif ($this->object->isForceInstantFeedbackEnabled()) { $this->testSequence->setQuestionChecked($questionId); $this->testSequence->saveToDb(); }