diff --git a/src/qtism/runtime/tests/AssessmentTestSession.php b/src/qtism/runtime/tests/AssessmentTestSession.php index 2b0cb6bd4..126051b50 100644 --- a/src/qtism/runtime/tests/AssessmentTestSession.php +++ b/src/qtism/runtime/tests/AssessmentTestSession.php @@ -2173,10 +2173,8 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions if ($target === 'EXIT_TEST') { $this->endTestSession(); } elseif ($target === 'EXIT_TESTPART') { - $route->next(); $this->moveNextTestPart(); } elseif ($target === 'EXIT_SECTION') { - $route->next(); $this->moveNextAssessmentSection(); } else { $route->branch($branchRules[$i]->getTarget()); @@ -2240,11 +2238,7 @@ protected function moveNextTestPart() $from = $route->current(); while ($route->valid() === true && $route->current()->getTestPart() === $from->getTestPart()) { - $this->nextRouteItem(); - } - - if ($this->isRunning() === true) { - $this->interactWithItemSession(); + $route->next(); } } @@ -2267,11 +2261,7 @@ protected function moveNextAssessmentSection() $from = $route->current(); while ($route->valid() === true && $route->current()->getAssessmentSection() === $from->getAssessmentSection()) { - $this->nextRouteItem(); - } - - if ($this->isRunning() === true) { - $this->interactWithItemSession(); + $route->next(); } } diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php index c642d14be..63427a0d8 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionExitTest.php @@ -55,6 +55,25 @@ public function testExitSectionEndOfTest() { $this->assertEquals(false, $itemSessions); } + public function testExitSectionFromEndOfSection() { + $url = self::samplesDir() . 'custom/runtime/exits/exitsectionfromendofsection.xml'; + $testSession = self::instantiate($url); + + $testSession->beginTestSession(); + + // If we get correct to the first question, we will EXIT_SECTION. We should + // be then redirected to next S02 section (Q02). + $testSession->beginAttempt(); + $testSession->endAttempt(new State(array(new ResponseVariable('RESPONSE', Cardinality::SINGLE, BaseType::IDENTIFIER, new QtiIdentifier('ChoiceA'))))); + + // We should be at section S02, item Q02. + $testSession->moveNext(); + + $this->assertEquals('Q02', $testSession->getCurrentAssessmentItemRef()->getIdentifier()); + $testSession->moveNext(); + $this->assertEquals(AssessmentTestSessionState::CLOSED, $testSession->getState()); + } + public function testExitSectionPreconditionsEndOfTest() { $url = self::samplesDir() . 'custom/runtime/exits/exitsectionpreconditions.xml'; $testSession = self::instantiate($url); diff --git a/test/samples/custom/runtime/exits/exitsectionfromendofsection.xml b/test/samples/custom/runtime/exits/exitsectionfromendofsection.xml new file mode 100644 index 000000000..520f1ee66 --- /dev/null +++ b/test/samples/custom/runtime/exits/exitsectionfromendofsection.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + 0 + + + + + ChoiceA + + + + + 0 + + + + + + + + + + + ChoiceB + + + + + 0 + + + + + + +