Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 19.2.1 #382

Merged
merged 6 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading