tao-test/app/taoQtiItem/views/js/qtiCreator/model/interactions/AssociateInteraction.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2022-08-29 20:14:13 +02:00
define([
'jquery',
'lodash',
'taoQtiItem/qtiCreator/model/mixin/editable',
'taoQtiItem/qtiCreator/model/mixin/editableInteraction',
'taoQtiItem/qtiItem/core/interactions/AssociateInteraction',
'taoQtiItem/qtiCreator/model/choices/SimpleAssociableChoice'
], function($, _, editable, editableInteraction, Interaction, Choice){
var methods = {};
_.extend(methods, editable);
_.extend(methods, editableInteraction);
_.extend(methods, {
getDefaultAttributes : function(){
return {
'shuffle' : false,
'maxAssociations' : 0,
'minAssociations' : 0
};
},
afterCreate : function(){
this.createChoice();
this.createChoice();
this.createResponse({
baseType:'pair',
cardinality:'multiple'
});
},
createChoice : function(){
var choice = new Choice();
this.addChoice(choice);
var rank = _.size(this.getChoices());
choice
.body('choice' + ' #' + rank)
.buildIdentifier('choice');
if(this.getRenderer()){
choice.setRenderer(this.getRenderer());
}
$(document).trigger('choiceCreated.qti-widget', {'choice' : choice, 'interaction' : this});
return choice;
}
});
return Interaction.extend(methods);
});