tao-test/app/taoQtiItem/views/js/qtiCreator/model/helper/response.js

23 lines
729 B
JavaScript
Raw Normal View History

2022-08-29 20:14:13 +02:00
define(['lodash'], function(_){
"use strict";
return {
removeChoice : function(response, choice){
var escapedIdentifier = choice.id().replace(/([.-])/g, '\\$1'),
regex = new RegExp('([^a-z_\-\d\.]*)(' + escapedIdentifier + ')([^a-z_\-\d\.]*)');
_.remove(response.correctResponse, function(entry){
return entry.match(regex);
});
var mapEntries = {};
_.forIn(response.mapEntries, function(value, mapKey){
if(!mapKey.match(regex)){
mapEntries[mapKey] = value;
}
});
response.mapEntries = mapEntries;
}
};
});