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

[AUT-3940] Fix: Single order interaction, moving from order to data-order. #2617

Merged
merged 17 commits into from
Nov 22, 2024
Merged
2 changes: 1 addition & 1 deletion views/js/loader/qtiLoader.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItem.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItem.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItemRunner.es5.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItemRunner.es5.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItemRunner.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoQtiItemRunner.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/qtiCreator/model/interactions/OrderInteraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ define([
};
},
afterCreate : function(){
this.attr('order', 'single')
this.attr('data-order', 'single');
this.createChoice();
this.createChoice();
this.createChoice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@ define([
'taoQtiItem/qtiCreator/widgets/states/Correct',
'taoQtiItem/qtiCommonRenderer/renderers/interactions/OrderInteraction',
'taoQtiItem/qtiCommonRenderer/helpers/instructions/instructionManager',
'lodash',
'i18n'
], function(stateFactory, Correct, commonRenderer, instructionMgr, _, __){

var InlineChoiceInteractionStateCorrect = stateFactory.create(Correct, function(){

_createResponseWidget(this.widget);

}, function(){

_destroyResponseWidget(this.widget);

});
var _createResponseWidget = function(widget){

var interaction = widget.element,
response = interaction.getResponseDeclaration(),
correctResponse = _.values(response.getCorrect());
], function(stateFactory, Correct, commonRenderer, instructionMgr, __){

const InlineChoiceInteractionStateCorrect = stateFactory.create(
Correct,
function () {
_createResponseWidget(this.widget);
},
function () {
_destroyResponseWidget(this.widget);
}
);

const _createResponseWidget = widget => {

const interaction = widget.element;
const response = interaction.getResponseDeclaration();
const correctResponse = response.getCorrect() ? Object.values(response.getCorrect()) : [];
instructionMgr.appendInstruction(
widget.element,
interaction.attr('order') === 'single'
interaction.attr('data-order') === 'single'
? __('Please define the correct order.')
: __('Please define the correct order in the box to the right.')
);
Expand All @@ -36,27 +35,22 @@ define([
response.setCorrect(_unformatResponse(data.response));
});
};

var _destroyResponseWidget = function(widget){

widget.$container.off('responseChange.qti-widget');

const _destroyResponseWidget = widget => {
widget.$container.off('responseChange.qti-widget');
commonRenderer.resetResponse(widget.element);

commonRenderer.destroy(widget.element);
};

var _formatResponse = function(response){
return {list : {identifier : response}};
};

var _unformatResponse = function(formatedResponse){
var res = [];
const _formatResponse = response => ({ list : { identifier : response } });

const _unformatResponse = function(formatedResponse){
let res = [];
if(formatedResponse.list && formatedResponse.list.identifier){
res = formatedResponse.list.identifier;
}
return res;
};

return InlineChoiceInteractionStateCorrect;
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ define([
'services/features',
'ui/liststyler'
], function (
_,
stateFactory,
Question,
formElement,
minMaxComponentFactory,
_,
stateFactory,
Question,
formElement,
minMaxComponentFactory,
formTpl,
sizeAdapter,
features
Expand All @@ -54,7 +54,11 @@ define([
var $iconRemove = this.widget.$container.find('.icon-remove-from-selection');
let minMaxComponent = null;

const order = interaction.attr('order');
const order = interaction.attr('data-order') || interaction.attr('order'); // legacy attr support
// legacy attr remove
if (interaction.attr('order')) {
interaction.removeAttr('order');
}
const isSingleOrder = order === 'single';
const minValue = interaction.attr('minChoices')
? _.parseInt(interaction.attr('minChoices'))
Expand All @@ -79,17 +83,17 @@ define([
});
});
};

const deleteMinMaxComponent = () => {
$form.find('.min-max-panel').hide();
if (minMaxComponent) {
minMaxComponent.destroy();
minMaxComponent = null;
}
};
const makeSignleOrder = () => {
interaction.attr('order', 'single');

const makeSingleOrder = () => {
interaction.attr('data-order', 'single');
interaction.attr('minChoices', 0);
interaction.attr('maxChoices', 0);
$interaction.addClass('qti-single');
Expand All @@ -103,7 +107,7 @@ define([
}

const makeSortOrder = () => {
interaction.attr('order', 'sort');
interaction.attr('data-order', 'sort');
$interaction.removeClass('qti-single');
createMinMaxComponent();
}
Expand All @@ -117,7 +121,7 @@ define([
orientation: features.isVisible('taoQtiItem/creator/interaction/order/property/orientation')
}
}));
isSingleOrder ? makeSignleOrder() : makeSortOrder();
isSingleOrder ? makeSingleOrder() : makeSortOrder();

formElement.initWidget($form);

Expand Down Expand Up @@ -151,7 +155,7 @@ define([

// data change for order
callbacks.order = function (interaction, value) {
value === 'sort' ? makeSortOrder() : makeSignleOrder();
value === 'sort' ? makeSortOrder() : makeSingleOrder();
};

formElement.setChangeCallbacks($form, interaction, callbacks);
Expand Down
8 changes: 4 additions & 4 deletions views/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 views/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
},
"dependencies": {
"@oat-sa/tao-item-runner": "^1.0.0",
"@oat-sa/tao-item-runner-qti": "^2.5.1"
"@oat-sa/tao-item-runner-qti": "^2.5.2"
}
}
Loading