# HG changeset patch # User Nicholas Jillings # Date 1477930104 0 # Node ID 224842b28bf203e5edaabcddf73ac7ba85101d68 # Parent 01df891a3390537013d83724ff700b87c72eb1cd Completed merge of current spec with new nodes. Working example in AB_example. Gives console warnings. diff -r 01df891a3390 -r 224842b28bf2 js/specification.js --- a/js/specification.js Mon Oct 31 15:42:37 2016 +0000 +++ b/js/specification.js Mon Oct 31 16:08:24 2016 +0000 @@ -195,7 +195,7 @@ this.OptionNode = function (specification) { this.type = undefined; - this.schema = specification.schema.getAllElementsByName('surveyentry')[0]; + this.schema = undefined; this.id = undefined; this.name = undefined; this.mandatory = undefined; @@ -208,6 +208,7 @@ this.conditions = []; this.decode = function (parent, child) { + this.schema = specification.schema.getAllElementsByName(child.nodeName)[0]; var attributeMap = this.schema.getAllElementsByTagName('xs:attribute'); for (var i in attributeMap) { if (isNaN(Number(i)) == true) { @@ -226,6 +227,15 @@ break; } } + if (child.nodeName == 'surveyentry') { + console.log("NOTE - Use of is now deprecated. Whilst these will still work, newer nodes and tighter error checking will not be enforced"); + console.log("Please use the newer, type specifc nodes"); + if (!this.type) { + throw ("Type not specified"); + } + } else { + this.type = child.nodeName.split('survey')[1]; + } this.statement = child.getElementsByTagName('statement')[0].textContent; if (this.type == "checkbox" || this.type == "radio") { var children = child.getElementsByTagName('option'); @@ -242,6 +252,17 @@ }); } } + } else if (this.type == "slider") { + this.leftText = ""; + this.rightText = ""; + var minText = child.getElementsByTagName("minText"); + var maxText = child.getElementsByTagName("maxText"); + if (minText.length > 0) { + this.leftText = minText[0].textContent; + } + if (maxText.length > 0) { + this.rightText = maxText[0].textContent; + } } var conditionElements = child.getElementsByTagName("conditional"); for (var i = 0; i < conditionElements.length; i++) { @@ -341,11 +362,12 @@ } else if (this.location == 'after') { this.location = 'post'; } - var children = xml.getAllElementsByTagName('surveyentry'); - for (var i = 0; i < children.length; i++) { + var child = xml.firstElementChild + while (child) { var node = new this.OptionNode(this.specification); - node.decode(parent, children[i]); + node.decode(parent, child); this.options.push(node); + child = child.nextElementSibling; } if (this.options.length == 0) { console.log("Empty survey node"); diff -r 01df891a3390 -r 224842b28bf2 tests/examples/AB_example.xml --- a/tests/examples/AB_example.xml Mon Oct 31 15:42:37 2016 +0000 +++ b/tests/examples/AB_example.xml Mon Oct 31 16:08:24 2016 +0000 @@ -2,20 +2,20 @@ - + Please enter your name. - - + + Please select with which activities you have any experience (example checkbox question) - - + + This is an example of an 'AB'-style test, with two pages, using the test stimuli in 'example_eval/'. - +