@oat-sa/tao-item-runner-qti
Version:
TAO QTI Item Runner modules
38 lines (30 loc) • 1.11 kB
JavaScript
define(['lodash', 'jquery'], function (_, $) { 'use strict';
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
$ = $ && Object.prototype.hasOwnProperty.call($, 'default') ? $['default'] : $;
var rendererConfigHelper = {};
rendererConfigHelper.getOptionsFromArguments = function (args) {
var options = {
data: {},
placeholder: null,
subclass: '',
renderer: null
};
_.forEach(args, function (arg) {
if (arg) {
if (arg.isRenderer) {
options.renderer = arg;
} else if (arg instanceof $ && arg.length) {
options.placeholder = arg;
} else if (_.isString(arg)) {
options.subclass = arg;
} else if (_.isPlainObject(arg)) {
options.data = arg;
} else {
console.log('invalid arg', arg, args);
}
}
});
return options;
};
return rendererConfigHelper;
});