Skip to content

Commit

Permalink
Switch to next if target is EXIT
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleh Hutnikau committed Sep 22, 2015
1 parent f5f1697 commit 9fa58ea
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 9fa58ea

Please sign in to comment.