diff --git a/package-lock.json b/package-lock.json index ff51eb6d..1f71e7f7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@oat-sa/tao-item-runner-qti", - "version": "2.3.4", + "version": "2.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@oat-sa/tao-item-runner-qti", - "version": "2.3.4", + "version": "2.4.0", "license": "GPL-2.0", "devDependencies": { "@oat-sa/browserslist-config-tao": "^1.0.1", diff --git a/package.json b/package.json index 6acda581..4ecd1f13 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-item-runner-qti", - "version": "2.3.4", + "version": "2.4.0", "displayName": "TAO Item Runner QTI", "description": "TAO QTI Item Runner modules", "files": [ diff --git a/src/qtiCommonRenderer/renderers/interactions/OrderInteraction.js b/src/qtiCommonRenderer/renderers/interactions/OrderInteraction.js index 249763f2..60672bbb 100644 --- a/src/qtiCommonRenderer/renderers/interactions/OrderInteraction.js +++ b/src/qtiCommonRenderer/renderers/interactions/OrderInteraction.js @@ -101,19 +101,31 @@ const _setInstructions = function (interaction) { }; const resetResponse = function (interaction) { + const isSingleOrder = interaction.attr('order') === 'single'; const $container = containerHelper.get(interaction); const initialOrder = _.keys(interaction.getChoices()); - const $choiceArea = $('.choice-area', $container).append($('.result-area>li', $container)); - const $choices = $choiceArea.children('.qti-choice'); + const $resultArea = $('.result-area', $container); + const $resultItems = $('.result-area>li', $container); $container.find('.qti-choice.active').each(function deactivateChoice() { interactUtils.tapOn(this); }); - $choices.detach().sort(function (choice1, choice2) { - return _.indexOf(initialOrder, $(choice1).data('serial')) - _.indexOf(initialOrder, $(choice2).data('serial')); - }); - $choiceArea.prepend($choices); + if (isSingleOrder) { + // if it's a single order interaction, sort the items in result-area in initial order + $resultItems.detach().sort(function (item1, item2) { + return _.indexOf(initialOrder, $(item1).data('serial')) - _.indexOf(initialOrder, $(item2).data('serial')); + }); + $resultArea.empty(); + $resultArea.append($resultItems); + } else { + const $choiceArea = $('.choice-area', $container).append($('.result-area>li', $container)); + const $choices = $choiceArea.children('.qti-choice'); + $choices.detach().sort(function (choice1, choice2) { + return _.indexOf(initialOrder, $(choice1).data('serial')) - _.indexOf(initialOrder, $(choice2).data('serial')); + }); + $choiceArea.prepend($choices); + } }; /** @@ -134,11 +146,18 @@ const render = function (interaction) { choiceSelector = `${$choiceArea.selector} >li:not(.deactivated)`, resultSelector = `${$resultArea.selector} >li`, $dragContainer = $container.find('.drag-container'), + isSingleOrder = interaction.attr('order') === 'single', orientation = interaction.attr('orientation') && orientationSelectionEnabled ? interaction.attr('orientation') : 'vertical'; + if (isSingleOrder) { + const $choices = $choiceArea.children('.qti-choice'); + $container.addClass('test-preview'); + $resultArea.append($choices); + } + let $activeChoice = null, scaleX, scaleY, @@ -554,13 +573,16 @@ const setResponse = function (interaction, response) { const $container = containerHelper.get(interaction); const $choiceArea = $('.choice-area', $container); const $resultArea = $('.result-area', $container); + const isSingleOrder = interaction.attr('order') === 'single'; if (response === null || _.isEmpty(response)) { resetResponse(interaction); } else { try { _.forEach(pciResponse.unserialize(response, interaction), function (identifier) { - $resultArea.append($choiceArea.find(`[data-identifier="${identifier}"]`)); + $resultArea.append( + (isSingleOrder ? $resultArea : $choiceArea).find(`[data-identifier="${identifier}"]`) + ); }); } catch (e) { throw new Error(`wrong response format in argument : ${e}`); diff --git a/src/qtiCommonRenderer/tpl/interactions/orderInteraction.tpl b/src/qtiCommonRenderer/tpl/interactions/orderInteraction.tpl index 9943f844..7106b366 100755 --- a/src/qtiCommonRenderer/tpl/interactions/orderInteraction.tpl +++ b/src/qtiCommonRenderer/tpl/interactions/orderInteraction.tpl @@ -1,4 +1,4 @@ -