From 9fa58ea4d314e1e05f8efd395b6b662a63f92c4f Mon Sep 17 00:00:00 2001 From: Aleh Hutnikau Date: Tue, 22 Sep 2015 19:30:40 +0300 Subject: [PATCH] Switch to next if target is EXIT --- qtism/runtime/tests/AssessmentTestSession.php | 46 ++++++++----------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/qtism/runtime/tests/AssessmentTestSession.php b/qtism/runtime/tests/AssessmentTestSession.php index 980b3fc39..ae6378ef4 100644 --- a/qtism/runtime/tests/AssessmentTestSession.php +++ b/qtism/runtime/tests/AssessmentTestSession.php @@ -1585,9 +1585,11 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions $this->endTestSession(); } else if ($target === 'EXIT_TESTPART') { + $route->next(); $this->moveNextTestPart(); } else if ($target === 'EXIT_SECTION') { + $route->next(); $this->moveNextAssessmentSection(); } else { @@ -1653,49 +1655,39 @@ public function moveNextTestPart() { $route = $this->getRoute(); $from = $route->current(); - if ($route->isLast() === true) { - $this->endTestSession(); - } else { - $route->next(); - while ($route->valid() === true && $route->current()->getTestPart() === $from->getTestPart()) { - $this->nextRouteItem(); - } - - if ($this->isRunning() === true) { - $this->interactWithItemSession(); - } + while ($route->valid() === true && $route->current()->getTestPart() === $from->getTestPart()) { + $this->nextRouteItem(); + } + + if ($this->isRunning() === true) { + $this->interactWithItemSession(); } } - + /** * Set the position in the Route at the very next assessmentSection in the route sequence. - * + * * * If there is no assessmentSection left in the flow, the test session ends gracefully. * * If there are still pending responses, they are processed. - * + * * @throws AssessmentTestSessionException If the test is not running. */ public function moveNextAssessmentSection() { - + if ($this->isRunning() === false) { $msg = "Cannot move to the next assessmentSection while the state of the test session is INITIAL or CLOSED."; throw new AssessmentTestSessionException($msg, AssessmentTestSessionException::STATE_VIOLATION); } - + $route = $this->getRoute(); $from = $route->current(); - if ($route->isLast() === true) { - $this->endTestSession(); - } else { - $route->next(); - while ($route->valid() === true && $route->current()->getAssessmentSection() === $from->getAssessmentSection()) { - $this->nextRouteItem(); - } - - if ($this->isRunning() === true) { - $this->interactWithItemSession(); - } + while ($route->valid() === true && $route->current()->getAssessmentSection() === $from->getAssessmentSection()) { + $this->nextRouteItem(); + } + + if ($this->isRunning() === true) { + $this->interactWithItemSession(); } }