From 41d130163b5e3b3a31e028104a6d002e6ea32b78 Mon Sep 17 00:00:00 2001 From: bheyser Date: Fri, 21 Aug 2015 09:43:17 +0200 Subject: [PATCH] lok3 #10 --- .../Test/classes/class.ilTestOutputGUI.php | 3 +++ Modules/Test/classes/class.ilTestSequence.php | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php index 6cb5cd1df3be..048cd5446876 100755 --- a/Modules/Test/classes/class.ilTestOutputGUI.php +++ b/Modules/Test/classes/class.ilTestOutputGUI.php @@ -329,6 +329,9 @@ protected function redirectQuestionCmd() if( $this->testSequence->hasOptionalQuestions() ) { $this->adoptUserSolutionsFromPreviousPass(); + + $this->testSequence->reorderOptionalQuestionsToSequenceEnd(); + $this->testSequence->saveToDb(); } } diff --git a/Modules/Test/classes/class.ilTestSequence.php b/Modules/Test/classes/class.ilTestSequence.php index 357cb09753f1..dcd67720f236 100644 --- a/Modules/Test/classes/class.ilTestSequence.php +++ b/Modules/Test/classes/class.ilTestSequence.php @@ -717,6 +717,25 @@ public function clearOptionalQuestions() { $this->optionalQuestions = array(); } + + public function reorderOptionalQuestionsToSequenceEnd() + { + $optionalSequenceKeys = array(); + + foreach($this->sequencedata['sequence'] as $index => $sequenceKey) + { + if( $this->isQuestionOptional($this->getQuestionForSequence($sequenceKey)) ) + { + $optionalSequenceKeys[$index] = $sequenceKey; + unset($this->sequencedata['sequence'][$index]); + } + } + + foreach($optionalSequenceKeys as $index => $sequenceKey) + { + $this->sequencedata['sequence'][$index] = $sequenceKey; + } + } } ?>