-
Notifications
You must be signed in to change notification settings - Fork 32
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
feat: make the first item consider testPart pre-conditions #367
feat: make the first item consider testPart pre-conditions #367
Conversation
@@ -601,10 +601,10 @@ public function testBranchUnknownTarget(): void | |||
|
|||
public function testBranchToAssessmentItemRefOutsideOfTestPart(): void | |||
{ | |||
$route = self::buildSimpleRoute(Route::class, 2, 1); | |||
$this->expectException(OutOfBoundsException::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These test case should not be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, instead of throwing an exception, we are ignoring branching rules and moving to the next item (like there are no branching rules)
$msg = 'Branchings to items outside of the current testPart is forbidden by the QTI 2.1 specification.'; | ||
throw new OutOfBoundsException($msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per $msg, branching to items outside of the current testPart (in case of source is an item or a section) is forbidden. So we should not allow it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But instead of throwing an exception, we just ignore such branch rules and going to the next item (like there are no invalid branch rules).
https://oat-sa.atlassian.net/browse/TR-5760 - ACs 9-14
the Branch Rule is ignored
@@ -1133,10 +1134,11 @@ public function branch($identifier): void | |||
if (isset($assessmentSectionIdentifierMap[$id])) { | |||
if ($assessmentSectionIdentifierMap[$id][0]->getTestPart() !== $this->current()->getTestPart()) { | |||
// From IMS QTI: | |||
// In case of an item or section, the target must refer to an item or section | |||
// in the same testPart [...] | |||
$msg = 'Branchings to assessmentSections outside of the current testPart is forbidden by the QTI 2.1 specification.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -200,6 +202,7 @@ protected function createRoute(AssessmentTest $test): Route | |||
// Do the same as for branch rules for pre conditions, except that they must be | |||
// attached on the first item of the route. | |||
$route->getFirstRouteItem()->addPreConditions($current->getPreConditions()); | |||
$route->getFirstRouteItem()->addPreConditions($testPart->getPreConditions()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preconditions treatment for testParts should be transferred to line 222-223. This will not work, as we are dealing with the assessmentSections of the tree.
testParts management is at line 222-223.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one I used a bit different approach now, so the routeItem retains the knowledge of which pre-conditions to use as it needs to respect testPart/section/item pre-conditions.
I've added it here https://github.com/oat-sa/qti-sdk/pull/367/files#diff-f33df5e2727b0618d5b89c14e69336ff58245c1453d97a797446bc2336d38cceR276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've also fixed an issue that allowed an item to be accessed in case 1 of the preconditions are met instead of all preconditions are met.
👉 85f9d10
cc: @julien-sebire
…s://github.com/oat-sa/qti-sdk into feat/rely-on-original-branch-rules-or-preconditions
…s-or-preconditions chore: rely on original branch rules instead of setting them to the last item
…rt, section, subsection, item
…s://github.com/oat-sa/qti-sdk into feat/TR-5381/add-preconditions-from-test-parts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- New code is covered by tests (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Acceptance criteria are respected
- Pull request title and description are meaningful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Pull request title and description are meaningful
- Pull request's target is not
master
- Target branch is correct
- Commits are following conventional commits
- Change log provided
- New code is covered by tests (if applicable)
- New code is respecting code style rules
- New code is respecting best practices
- New code is not subject to concurrency issues (if applicable)
- Feature is working correctly on my local machine (if applicable)
- Tests are running successfully (old and new ones) on my local machine (if applicable)
- Acceptance criteria are respected
- Kitchen links are not exposed in the description
…e used externally
da61af4
to
a5b719a
Compare
/** @var BranchRule $branchRule */ | ||
foreach ($branchRules as $branchRule) { | ||
$engine = new ExpressionEngine($branchRule->getExpression(), $this); | ||
$condition = $engine->process(); | ||
|
||
if ($condition !== null && $condition->getValue() === true) { | ||
$route->branch($branchRule->getTarget()); | ||
|
||
break 2; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should encapsulate this in a method rather than repeat it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private function evaluateBranchRules(BranchRuleCollection $branchRules): ?BranchRule
{
foreach ($branchRules as $branchRule) {
$engine = new ExpressionEngine($branchRule->getExpression(), $this);
$condition = $engine->process();
if ($condition !== null && $condition->getValue() === true) {
return $branchRule;
}
}
}
https://oat-sa.atlassian.net/browse/TR-5381
https://oat-sa.atlassian.net/browse/TR-5759
https://oat-sa.atlassian.net/browse/TR-5760
Goal
Related PRs