diff --git a/src/qtism/runtime/tests/AssessmentTestSession.php b/src/qtism/runtime/tests/AssessmentTestSession.php index 44cc069c7..2b0cb6bd4 100644 --- a/src/qtism/runtime/tests/AssessmentTestSession.php +++ b/src/qtism/runtime/tests/AssessmentTestSession.php @@ -2157,42 +2157,42 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions $route = $this->getRoute(); $stop = false; - // Branchings? - if ($ignoreBranchings === false && $this->getCurrentNavigationMode() === NavigationMode::LINEAR && count($route->current()->getBranchRules()) > 0) { - - $branchRules = $route->current()->getBranchRules(); - for ($i = 0; $i < count($branchRules); $i++) { - $engine = new ExpressionEngine($branchRules[$i]->getExpression(), $this); - $condition = $engine->process(); - if ($condition !== null && $condition->getValue() === true) { - - $target = $branchRules[$i]->getTarget(); - - 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()); - } + while ($route->valid() === true && $stop === false) { - break; + // Branchings? + if ($ignoreBranchings === false && $this->getCurrentNavigationMode() === NavigationMode::LINEAR && count($route->current()->getBranchRules()) > 0) { + + $branchRules = $route->current()->getBranchRules(); + for ($i = 0; $i < count($branchRules); $i++) { + $engine = new ExpressionEngine($branchRules[$i]->getExpression(), $this); + $condition = $engine->process(); + if ($condition !== null && $condition->getValue() === true) { + + $target = $branchRules[$i]->getTarget(); + + 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()); + } + + break; + } } - } - if ($i >= count($branchRules)) { - // No branch rule returned true. Simple move next. + if ($i >= count($branchRules)) { + // No branch rule returned true. Simple move next. + $route->next(); + } + } else { $route->next(); } - } else { - $route->next(); - } - - while ($route->valid() === true && $stop === false) { // Preconditions on target? if ($ignorePreConditions === false && $route->valid() === true) { @@ -2209,12 +2209,6 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions break; } } - - if ($i >= count($preConditions)) { - // No preConditions returned true, we have to move next - // and fine a new item to be presented. - $route->next(); - } } else { $stop = true; }