Skip to content

Commit

Permalink
Merge pull request #322 from oat-sa/hotfix/AUT-2713/check-max-when-ma…
Browse files Browse the repository at this point in the history
…x-equal-min-to-september

hotfix/AUT-2713 Choice interaction - Incorrect amount of choices are allowed to be selected if maxChoices = minChoices
  • Loading branch information
bziondik authored Oct 10, 2022
2 parents 00fedda + 138a587 commit cc01441
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-item-runner-qti",
"version": "1.4.1",
"version": "1.4.2",
"displayName": "TAO Item Runner QTI",
"description": "TAO QTI Item Runner modules",
"files": [
Expand Down
19 changes: 17 additions & 2 deletions src/qtiCommonRenderer/renderers/interactions/ChoiceInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,25 @@ const _setInstructions = function _setInstructions(interaction) {
} else if (min > 1 && min === max) {
// Multiple Choice: 5. Constraint: Other constraints -> minChoices ≠ Disabled / maxChoices ≠ Disabled -> “You need to select {minChoices = maxChoices value} choices.“
msg = __('You need to select %s choices', min);
instructionMgr.appendInstruction(interaction, msg, function () {
instructionMgr.appendInstruction(interaction, msg, function (data) {
if (_getRawResponse(interaction).length === min) {
this.setLevel('success');
} else {
} else if (_getRawResponse(interaction).length >= max) {
this.setMessage(__('Maximum choices reached'));
this.update({
level: 'warning',
timeout: 2000,
start: function () {
if (data && data.choice) {
highlightInvalidInput(data.choice);
}
},
stop: function () {
this.setLevel('info');
}
});
this.setState('fulfilled');
} else {
this.reset();
}
});
Expand Down

0 comments on commit cc01441

Please sign in to comment.