Skip to content

Commit

Permalink
Merge pull request #382 from oat-sa/release-19.2.1
Browse files Browse the repository at this point in the history
Release 19.2.1
  • Loading branch information
gabrielfs7 authored Dec 13, 2023
2 parents e3fba84 + 37b52f5 commit 8224abf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/qtism/data/rules/BranchRuleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@
*/
class BranchRuleCollection extends QtiComponentCollection
{

/** @var bool */
private $allowNonLinearNavigationMode = false;

public function isNonLinearNavigationModeAllowed(): bool
{
return $this->allowNonLinearNavigationMode;
}

public function allowNonLinearNavigationMode(): void
{
$this->allowNonLinearNavigationMode = true;
}

/**
* Check if a given $value is an instance of BranchRule.
*
Expand Down
6 changes: 5 additions & 1 deletion src/qtism/runtime/tests/AssessmentTestSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -2412,7 +2412,11 @@ protected function nextRouteItem($ignoreBranchings = false, $ignorePreConditions
$numberOfBranchRules = $branchRules->count();

// Branchings?
if ($ignoreBranchings === false && $numberOfBranchRules > 0 && $this->mustApplyBranchRules() === true) {
if (
$ignoreBranchings === false &&
$numberOfBranchRules > 0 &&
($this->mustApplyBranchRules() || $branchRules->isNonLinearNavigationModeAllowed())
) {
for ($i = 0; $i < $numberOfBranchRules; $i++) {
$engine = new ExpressionEngine($branchRules[$i]->getExpression(), $this);
$condition = $engine->process();
Expand Down
5 changes: 4 additions & 1 deletion src/qtism/runtime/tests/RouteItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ public function getEffectiveBranchRules(): BranchRuleCollection
} while ($parentSection = $parentSection->getParent());

// Return branching rules from the Test Part level
return $this->getTestPart()->getBranchRules();
$branchingRules = $this->getTestPart()->getBranchRules();
$branchingRules->allowNonLinearNavigationMode();

return $branchingRules;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -305,5 +305,17 @@ public function testBranchingRules(): void
$this->assertEquals('testPart-5', $session->getCurrentTestPart()->getIdentifier());
$this->assertEquals('assessmentSection-8', $session->getCurrentAssessmentSection()->getIdentifier());
$this->assertEquals('item-11', $session->getCurrentAssessmentItemRef()->getIdentifier());

$session->moveNext();

$this->assertEquals('testPart-6', $session->getCurrentTestPart()->getIdentifier());
$this->assertEquals('assessmentSection-9', $session->getCurrentAssessmentSection()->getIdentifier());
$this->assertEquals('item-12', $session->getCurrentAssessmentItemRef()->getIdentifier());

$session->moveNext();

$this->assertEquals('testPart-8', $session->getCurrentTestPart()->getIdentifier());
$this->assertEquals('assessmentSection-11', $session->getCurrentAssessmentSection()->getIdentifier());
$this->assertEquals('item-14', $session->getCurrentAssessmentItemRef()->getIdentifier());
}
}
23 changes: 20 additions & 3 deletions test/samples/custom/runtime/branchings/branching_rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,35 @@
<assessmentItemRef identifier="item-11" href="./item-11.xml" timeDependent="false">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
<testPart identifier="testPart-6" navigationMode="nonlinear" submissionMode="individual">
<branchRule target="testPart-8">
<baseValue baseType="boolean">true</baseValue>
</branchRule>
<assessmentSection identifier="assessmentSection-9" title="Section" visible="true">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
<assessmentItemRef identifier="item-12" href="./item-12.xml" timeDependent="false">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
<!-- Will be skipped -->
<testPart identifier="testPart-7" navigationMode="nonlinear" submissionMode="individual">
<assessmentSection identifier="assessmentSection-10" title="Section" visible="true">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
<assessmentItemRef identifier="item-13" href="./item-13.xml" timeDependent="false">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
<!-- Jump from testPart-6 -->
<testPart identifier="testPart-8" navigationMode="nonlinear" submissionMode="individual">
<assessmentSection identifier="assessmentSection-11" title="Section" visible="true">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
<assessmentItemRef identifier="item-14" href="./item-14.xml" timeDependent="false">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
</assessmentItemRef>
<assessmentItemRef identifier="item-15" required="false" fixed="false" href="./item-15.xml" timeDependent="false">
<itemSessionControl maxAttempts="0" allowComment="false" validateResponses="false"/>
</assessmentItemRef>
</assessmentSection>
</testPart>
<outcomeProcessing/>
Expand Down

0 comments on commit 8224abf

Please sign in to comment.