@oat-sa/tao-test-runner-qti
Version:
TAO Test Runner QTI implementation
119 lines (106 loc) • 4.98 kB
JavaScript
define(['lodash', 'ui/component', 'handlebars', 'lib/handlebars/helpers'], function (_, componentFactory, Handlebars, Helpers0) { 'use strict';
_ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
componentFactory = componentFactory && Object.prototype.hasOwnProperty.call(componentFactory, 'default') ? componentFactory['default'] : componentFactory;
Handlebars = Handlebars && Object.prototype.hasOwnProperty.call(Handlebars, 'default') ? Handlebars['default'] : Handlebars;
Helpers0 = Helpers0 && Object.prototype.hasOwnProperty.call(Helpers0, 'default') ? Helpers0['default'] : Helpers0;
if (!Helpers0.__initialized) {
Helpers0(Handlebars);
Helpers0.__initialized = true;
}
var Template = Handlebars.template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, helper, functionType="function", escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = "", stack1, helper;
buffer += "class=\"";
if (helper = helpers.className) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.className); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
+ "\"\n ";
return buffer;
}
function program3(depth0,data) {
var buffer = "", stack1;
buffer += "\n aria-"
+ escapeExpression(((stack1 = (data == null || data === false ? data : data.key)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "=\""
+ escapeExpression((typeof depth0 === functionType ? depth0.apply(depth0) : depth0))
+ "\"\n ";
return buffer;
}
buffer += "<li\n ";
stack1 = helpers['if'].call(depth0, (depth0 && depth0.className), {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += " data-control=\"";
if (helper = helpers.control) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.control); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
+ "\"\n ";
stack1 = helpers.each.call(depth0, (depth0 && depth0.aria), {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n>\n ";
if (helper = helpers.text) { stack1 = helper.call(depth0, {hash:{},data:data}); }
else { helper = (depth0 && depth0.text); stack1 = typeof helper === functionType ? helper.call(depth0, {hash:{},data:data}) : helper; }
buffer += escapeExpression(stack1)
+ "\n</li>\n";
return buffer;
});
function textTpl(data, options, asString) {
var html = Template(data, options);
return (asString || true) ? html : $(html);
}
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2017 (original work) Open Assessment Technologies SA;
*/
var textComponentApi = {
/**
* Initialise text
* @returns {String}
*/
initText: function initText() {
this.id = this.config.control;
},
/**
* Get the type of the component
*/
getType: function getType() {
return 'text';
},
/**
* Get the item Id
* @returns {String}
*/
getId: function getId() {
return this.id;
}
};
/**
* The text factory
*/
function textComponentFactory(specs, defaults) {
var textComponent;
specs = _.defaults(specs || {}, textComponentApi);
textComponent = componentFactory(specs, defaults).setTemplate(textTpl).on('init', function () {
this.initText();
}).on('render', function () {
this.disable(); // always render disabled first
});
return textComponent;
}
return textComponentFactory;
});