本文整理汇总了TypeScript中entcore._.shuffle方法的典型用法代码示例。如果您正苦于以下问题:TypeScript _.shuffle方法的具体用法?TypeScript _.shuffle怎么用?TypeScript _.shuffle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entcore._
的用法示例。
在下文中一共展示了_.shuffle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
}, function () {
scope.grainCopy.grain_copy_data.custom_copy_data = new CustomData(scope.grainCopy.grain_copy_data.custom_copy_data);
scope.customData = scope.grainCopy.grain_copy_data.custom_copy_data;
//shuffle
if (scope.customData.answersType === 'list') {
_.forEach(scope.customData.zones, function (zone) {
var tmp = _.clone(zone.options);
var secureLoop = 0;
if (tmp && tmp.length > 1) {
while (zone.options[0] === tmp[0]) {
zone.options = _.shuffle(zone.options);
if (secureLoop === 5) return false;
secureLoop++;
}
}
});
} else if (scope.customData.answersType === 'drag') {
var tmp = _.clone(scope.customData.options);
var secureLoop = 0;
if (tmp && tmp.length > 1) {
while (scope.customData.options[0] === tmp[0] && !(secureLoop === 5)) {
scope.customData.options = _.shuffle(scope.customData.options);
secureLoop++;
}
}
scope.dragOptions = [];
var i=0;
_.forEach(scope.customData.options, function (option) {
scope.dragOptions.push({id:i,option:option});
i++;
});
//case of several fillZone in the same subject
scope.usedAnswers = [];
// init usedAnswers
if (scope.customData.zones) {
_.forEach(scope.customData.zones, function (zone) {
if (zone.answer) {
for (let option of scope.dragOptions) {
if (option.option === zone.answer && option.zoneId === undefined) {
option.zoneId = zone.id;
scope.usedAnswers.push(option);
break;
}
}
}
});
}
}
});