diff --git a/src/qtism/runtime/tests/AssessmentTestSession.php b/src/qtism/runtime/tests/AssessmentTestSession.php index 0f7d85577..a4910c56e 100644 --- a/src/qtism/runtime/tests/AssessmentTestSession.php +++ b/src/qtism/runtime/tests/AssessmentTestSession.php @@ -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. * @@ -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. * @@ -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); } /** diff --git a/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php b/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php index 94a021039..1686ed38d 100644 --- a/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php +++ b/test/qtismtest/runtime/tests/AssessmentTestSessionTest.php @@ -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()