Skip to content

Commit

Permalink
Merge pull request #297 from oat-sa/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
m-lagarde authored Aug 4, 2021
2 parents 99b522a + 859b2cc commit 8af0f5d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ class AssessmentTestSession extends State
*/
private $config = 0;

/**
* Whether or not allowing jump in any case.
*
* If enabled, jumps will be allowed even if the current navigation mode is linear.
*
* @var bool
*/
private $alwaysAllowJumps = false;

/**
* Create a new AssessmentTestSession object.
*
Expand Down Expand Up @@ -668,6 +677,18 @@ public function mustTrackPath()
return (bool)($this->getConfig() & self::PATH_TRACKING);
}

/**
* Set whether or not to always allow jumps.
*
* When turned on, jumps will be allowed even if the current navigation mode is linear.
*
* @param bool $alwaysAllowJumps
*/
public function setAlwaysAllowJumps($alwaysAllowJumps)
{
$this->alwaysAllowJumps = $alwaysAllowJumps;
}

/**
* Know whether or not to always allow jumps.
*
Expand All @@ -677,7 +698,7 @@ public function mustTrackPath()
*/
public function mustAlwaysAllowJumps()
{
return (bool)($this->getConfig() & self::ALWAYS_ALLOW_JUMPS);
return $this->alwaysAllowJumps || (bool)($this->getConfig() & self::ALWAYS_ALLOW_JUMPS);
}

/**
Expand Down
7 changes: 7 additions & 0 deletions test/qtismtest/runtime/tests/AssessmentTestSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,13 @@ public function testAlwaysAllowJumps()

$assessmentTestSession->jumpTo(1);
$this::assertEquals(1, $assessmentTestSession->getRoute()->getPosition());

$assessmentTestSession = self::instantiate(self::samplesDir() . 'custom/runtime/linear_5_items.xml', false);
$assessmentTestSession->setAlwaysAllowJumps(true);
$assessmentTestSession->beginTestSession();

$assessmentTestSession->jumpTo(1);
$this::assertEquals(1, $assessmentTestSession->getRoute()->getPosition());
}

public function testSetSessionIdEmptyString()
Expand Down

0 comments on commit 8af0f5d

Please sign in to comment.