Skip to content

Commit

Permalink
Finally changed my mind about branchings.
Browse files Browse the repository at this point in the history
The bug identified in the previous commit was actually not
a bug. So I'm rolling back at the previous version of the
branching/preconditions algorithms.

However, it will be improved in the next commit.
  • Loading branch information
= committed Nov 15, 2015
1 parent ae0b8b6 commit 9d3bec7
Showing 1 changed file with 31 additions and 37 deletions.
68 changes: 31 additions & 37 deletions src/qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand Down

0 comments on commit 9d3bec7

Please sign in to comment.