From aafc25a901b578eebf4ec5ce5210298ad9764bf7 Mon Sep 17 00:00:00 2001 From: Maximilian Becker Date: Wed, 23 Feb 2022 11:07:51 +0100 Subject: [PATCH] Merge pull request #4027 from nhaagen/7/TA/21097 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(); }