# HG changeset patch # User Nicholas Jillings # Date 1484822862 0 # Node ID e3cf3c24149eee8ef37ff121002239489c81ae70 # Parent a33b66ca3baa30af09e6b1a65b5a0e27684c1b07# Parent 03a9a90717ed7b9906236e258f83770b8de5b3fb Including samediff into global label-maker (34b20b6) Merge branch 'master' into vnext # Conflicts: # interfaces/AB.js diff -r 03a9a90717ed -r e3cf3c24149e css/core.css --- a/css/core.css Thu Jan 19 10:37:30 2017 +0000 +++ b/css/core.css Thu Jan 19 10:47:42 2017 +0000 @@ -101,6 +101,12 @@ table.popup-option-list tr td { padding: 5px; } +div.survey-slider-text-holder { + display: flex; + flex-direction: row; + justify-content: space-between; + padding: 0px 15px; +} button#popup-proceed { bottom: 10px; right: 10px; @@ -245,3 +251,14 @@ padding: 0 5px; height: 290px; } + +/* Comment Boxes */ + +div.comment-slider-text-holder { + display: flex; + flex-direction: row; + justify-content: space-between; +} +div.comment-slider-text-holder span { + margin: 0px 5px; +} diff -r 03a9a90717ed -r e3cf3c24149e interfaces/AB.js --- a/interfaces/AB.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/AB.js Thu Jan 19 10:47:42 2017 +0000 @@ -316,7 +316,7 @@ if (this.parent.specification.parent.playOne || specification.playOne) { $('.comparator-button').text('Wait'); $('.comparator-button').attr("disabled", "true"); - $(this.playback).removeAttr("disabled"); + $(this.playback).css("disabled", "false"); } else { $('.comparator-button').text('Listen'); } @@ -351,6 +351,11 @@ this.comparators = []; this.selected = null; + var labelType = audioHolderObject.label; + if (labelType == "default") { + labelType = "capital"; + } + // First generate the Audio Objects for the Audio Engine for (var index = 0; index < audioHolderObject.audioElements.length; index++) { var element = audioHolderObject.audioElements[index]; @@ -359,33 +364,7 @@ var orNode = new interfaceContext.outsideReferenceDOM(audioObject, index, document.getElementById("outside-reference-holder")); audioObject.bindInterface(orNode); } else { - var label; - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "number": - label = "" + index; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - case "samediff": - console.log("index = " + index); - if(index == 0){ - label = "same"; - } - else if (index == 1){ - label = "different"; - } - else{ - label = ""; - } - break; - default: - label = String.fromCharCode(65 + index); - break; - } + var label = interfaceContext.getLabel(labelType, index, audioHolderObject.labelStart); var node = new this.comparatorBox(audioObject, index, label); audioObject.bindInterface(node); this.comparators.push(node); diff -r 03a9a90717ed -r e3cf3c24149e interfaces/ABX.js --- a/interfaces/ABX.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/ABX.js Thu Jan 19 10:47:42 2017 +0000 @@ -364,19 +364,10 @@ } var audioObject = audioEngineContext.newTrack(element); var label; - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "number": - label = "" + index; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - default: - label = String.fromCharCode(65 + index); - break; + if (index == 0) { + label = "A"; + } else { + label = "B"; } var node = new this.interfaceObject(audioObject, label); audioObject.bindInterface(node); diff -r 03a9a90717ed -r e3cf3c24149e interfaces/ape.js --- a/interfaces/ape.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/ape.js Thu Jan 19 10:47:42 2017 +0000 @@ -273,6 +273,10 @@ feedbackHolder.innerHTML = ""; sliderHolder.innerHTML = ""; + // Set labelType if default to number + if (audioHolderObject.label == "default" || audioHolderObject.label == "") { + audioHolderObject.label = "number"; + } // Set the page title if (typeof audioHolderObject.title == "string" && audioHolderObject.title.length > 0) { document.getElementById("test-title").textContent = audioHolderObject.title @@ -592,22 +596,8 @@ // Create a new slider object; this.parent = audioObject; this.trackSliderObjects = []; - this.label = null; + this.label = interfaceContext.getLabel(audioObject.specification.parent.label, index, audioObject.specification.parent.labelStart); this.playing = false; - switch (audioObject.specification.parent.label) { - case "letter": - this.label = String.fromCharCode(97 + index); - break; - case "capital": - this.label = String.fromCharCode(65 + index); - break; - case "none": - this.label = ""; - break; - default: - this.label = "" + (index + 1); - break; - } for (var i = 0; i < interfaceContext.interfaceSliders.length; i++) { var trackObj = interfaceContext.interfaceSliders[i].createSliderObject(audioObject, this.label); this.trackSliderObjects.push(trackObj); diff -r 03a9a90717ed -r e3cf3c24149e interfaces/discrete.js --- a/interfaces/discrete.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/discrete.js Thu Jan 19 10:47:42 2017 +0000 @@ -150,7 +150,11 @@ // Find all the audioElements from the audioHolder var index = 0; var interfaceScales = testState.currentStateMap.interfaces[0].scales; - $(page.audioElements).each(function (index, element) { + var labelType = page.label; + if (labelType == "default") { + labelType = "number"; + } + $(page.audioElements).each(function (pageIndex, element) { // Find URL of track // In this jQuery loop, variable 'this' holds the current audioElement. @@ -161,20 +165,7 @@ audioObject.bindInterface(orNode); } else { // Create a slider per track - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - case "capital": - label = String.fromCharCode(65 + index); - break; - default: - label = "" + index; - break; - } + var label = interfaceContext.getLabel(labelType, index, page.labelStart); var sliderObj = new discreteObject(audioObject, label, interfaceScales); sliderBox.appendChild(sliderObj.holder); audioObject.bindInterface(sliderObj); diff -r 03a9a90717ed -r e3cf3c24149e interfaces/horizontal-sliders.js --- a/interfaces/horizontal-sliders.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/horizontal-sliders.js Thu Jan 19 10:47:42 2017 +0000 @@ -154,7 +154,11 @@ // Find all the audioElements from the audioHolder var index = 0; - $(page.audioElements).each(function (index, element) { + var labelType = page.label; + if (labelType == "default") { + labelType = "number"; + } + $(page.audioElements).each(function (pageIndex, element) { // Find URL of track // In this jQuery loop, variable 'this' holds the current audioElement. @@ -165,20 +169,7 @@ audioObject.bindInterface(orNode); } else { // Create a slider per track - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - case "capital": - label = String.fromCharCode(65 + index); - break; - default: - label = "" + index; - break; - } + var label = interfaceContext.getLabel(labelType, index, page.labelStart); var sliderObj = new sliderObject(audioObject, label); if (typeof page.initialPosition === "number") { diff -r 03a9a90717ed -r e3cf3c24149e interfaces/interfaces.json --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/interfaces/interfaces.json Thu Jan 19 10:47:42 2017 +0000 @@ -0,0 +1,35 @@ +{ + "interfaces": [ + { + "name": "APE", + "scripts": ["interfaces/ape.js"], + "css": ["interfaces/ape.css"] + }, + { + "name": "MUSHRA", + "scripts": ["interfaces/mushra.js"], + "css": ["interfaces/mushra.css"] + }, + { + "name": "horizontal", + "scripts": ["interfaces/horizontal-sliders.js"], + "css": ["interfaces/horizontal-sliders.css"] + }, { + "name": "discrete", + "scripts": ["interfaces/discrete.js"], + "css": ["interfaces/discrete.css"] + }, { + "name": "AB", + "scripts": ["interfaces/AB.js"], + "css": ["interfaces/AB.css"] + }, { + "name": "ABX", + "scripts": ["interfaces/ABX.js"], + "css": ["interfaces/ABX.css"] + }, { + "name": "timeline", + "scripts": ["interfaces/timeline.js"], + "css": ["interfaces/timeline.css"] + } + ] +} diff -r 03a9a90717ed -r e3cf3c24149e interfaces/mushra.css --- a/interfaces/mushra.css Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/mushra.css Thu Jan 19 10:47:42 2017 +0000 @@ -7,43 +7,52 @@ /* Set the background colour (note US English spelling) to grey*/ background-color: #ddd } + div.pageTitle { width: auto; height: 20px; margin: 10px 0px; } + div.pageTitle span { font-size: 1.5em; } + button { /* Specify any button structure or style */ min-width: 20px; background-color: #ddd } + div#slider-holder { height: inherit; position: absolute; left: 0px; z-index: 3; } + div#scale-holder { height: inherit; position: absolute; left: 0px; z-index: 2; } + div#scale-text-holder { position: relative; width: 100px; float: left; } + div.scale-text { position: absolute; } + canvas#scale-canvas { position: relative; float: left; } + div.track-slider { float: left; width: 94px; @@ -53,22 +62,27 @@ padding: 2px; margin-left: 50px; } + div#outside-reference-holder { display: flex; align-content: center; justify-content: center; margin-bottom: 5px; } + button.outside-reference { position: inherit; margin: 0px 5px; } + div.track-slider-playing { background-color: #FFDDDD; } + input.track-slider-range { margin: 2px 0px; } + input[type=range][orient=vertical] { writing-mode: bt-lr; /* IE */ @@ -78,6 +92,7 @@ padding: 0 5px; color: rgb(255, 144, 144); } + input[type=range]::-webkit-slider-runnable-track { width: 8px; cursor: pointer; @@ -85,6 +100,7 @@ border-radius: 4px; border: 1px solid #000; } + input[type=range]::-moz-range-track { width: 8px; cursor: pointer; @@ -92,41 +108,79 @@ border-radius: 4px; border: 1px solid #000; } + input[type=range]::-ms-track { cursor: pointer; background: #fff; border-radius: 4px; border: 1px solid #000; } + input.track-slider-not-moved[type=range]::-webkit-slider-runnable-track { background: #aaa; } + input.track-slider-not-moved[type=range]::-moz-range-track { background: #aaa; } + input[type=range]::-moz-range-thumb { margin-left: -7px; cursor: pointer; margin-top: -1px; box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d; } + input[type=range]::-webkit-slider-thumb { cursor: pointer; margin-top: -1px; margin-left: -4px; } + input[type=range]::-ms-thumb { cursor: pointer; margin-top: -1px; margin-left: -4px; } + input[type=range]::-ms-tooltip { visibility: hidden; } + +input.track-slider-range-disabled {} + +input.track-slider-range-disabled[type=range]::-webkit-slider-runnable-track { + cursor: not-allowed; +} + +input.track-slider-range-disabled[type=range]::-moz-range-track { + cursor: not-allowed; +} + +input.track-slider-range-disabled[type=range]::-ms-track { + cursor: not-allowed; +} + +input.track-slider-range-disabled[type=range]::-moz-range-thumb { + cursor: not-allowed; + background-color: #888; +} + +input.track-slider-range-disabled[type=range]::-webkit-slider-thumb { + cursor: not-allowed; + background-color: #888; +} + +input.track-slider-range-disabled[type=range]::-ms-thumb { + cursor: not-allowed; + background-color: #888; +} + div#page-count { float: left; margin: 0px 5px; } + div#master-volume-holder { position: absolute; top: 10px; diff -r 03a9a90717ed -r e3cf3c24149e interfaces/mushra.js --- a/interfaces/mushra.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/mushra.js Thu Jan 19 10:47:42 2017 +0000 @@ -155,7 +155,12 @@ // Find all the audioElements from the audioHolder var index = 0; - $(audioHolderObject.audioElements).each(function (index, element) { + var interfaceScales = testState.currentStateMap.interfaces[0].scales; + var labelType = audioHolderObject.label; + if (labelType == "default") { + labelType = "number"; + } + $(audioHolderObject.audioElements).each(function (pageIndex, element) { // Find URL of track // In this jQuery loop, variable 'this' holds the current audioElement. @@ -166,20 +171,7 @@ audioObject.bindInterface(orNode); } else { // Create a slider per track - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - case "capital": - label = String.fromCharCode(65 + index); - break; - default: - label = "" + index; - break; - } + var label = interfaceContext.getLabel(labelType, index, audioHolderObject.labelStart); var sliderObj = new sliderObject(audioObject, label); if (typeof audioHolderObject.initialPosition === "number") { @@ -197,6 +189,13 @@ }); + if (testState.currentStateMap.restrictMovement) { + $(".track-slider-range").addClass("track-slider-range-disabled"); + $(".track-slider-range").each(function (i, e) { + e.disabled = true + }); + } + var interfaceOptions = specification.interfaces.options.concat(interfaceObj.options); for (var option of interfaceOptions) { @@ -245,6 +244,7 @@ function sliderObject(audioObject, label) { // Constructs the slider object. We use the HTML5 slider object + var page = testState.currentStateMap; this.parent = audioObject; this.holder = document.createElement('div'); this.title = document.createElement('span'); @@ -310,6 +310,7 @@ return node; }; this.startPlayback = function () { + var self = this; // Called when playback has begun this.play.setAttribute("playstate", "playing"); $(".track-slider").removeClass('track-slider-playing'); @@ -319,12 +320,32 @@ $(outsideReference).removeClass('track-slider-playing'); } this.play.textContent = "Stop"; + if (page.restrictMovement) { + if (page.loop) { + $(this.slider).removeClass("track-slider-range-disabled"); + this.slider.removeAttribute("disabled"); + } else { + $(".track-slider-range").addClass("track-slider-range-disabled"); + $(this.slider).removeClass("track-slider-range-disabled"); + $(".track-slider-range").each(function (i, m) { + if (m == self.slider) { + m.removeAttribute("disabled"); + } else { + m.setAttribute("disabled", "true"); + } + }); + } + } }; this.stopPlayback = function () { // Called when playback has stopped. This gets called even if playback never started! this.play.setAttribute("playstate", "ready"); $(this.holder).removeClass('track-slider-playing'); this.play.textContent = "Play"; + if (page.restrictMovement && page.loop) { + $(this.slider).addClass("track-slider-range-disabled"); + this.slider.setAttribute("disabled", "true"); + } }; this.getValue = function () { return this.slider.value; diff -r 03a9a90717ed -r e3cf3c24149e interfaces/timeline.js --- a/interfaces/timeline.js Thu Jan 19 10:37:30 2017 +0000 +++ b/interfaces/timeline.js Thu Jan 19 10:47:42 2017 +0000 @@ -106,27 +106,19 @@ if (interfaceObj.commentBoxPrefix != undefined) { commentBoxPrefix = interfaceObj.commentBoxPrefix; } - - $(page.audioElements).each(function (index, element) { + var index = 0; + var interfaceScales = testState.currentStateMap.interfaces[0].scales; + var labelType = page.label; + if (labelType == "default") { + labelType = "number"; + } + $(page.audioElements).each(function (pageIndex, element) { var audioObject = audioEngineContext.newTrack(element); if (page.audioElements.type == 'outside-reference') { var refNode = interfaceContext.outsideReferenceDOM(audioObject, index, outsideReferenceHolder); audioObject.bindInterface(orNode); } else { - switch (audioObject.specification.parent.label) { - case "none": - label = ""; - break; - case "letter": - label = String.fromCharCode(97 + index); - break; - case "capital": - label = String.fromCharCode(65 + index); - break; - default: - label = "" + index; - break; - } + var label = interfaceContext.getLabel(labelType, index, page.labelStart); var node = new interfaceObject(audioObject, label); content.appendChild(node.DOM); @@ -506,7 +498,7 @@ break; } if (checkState == false) { - canContinue == false; + canContinue = false; } } if (!canContinue) { diff -r 03a9a90717ed -r e3cf3c24149e js/core.js --- a/js/core.js Thu Jan 19 10:37:30 2017 +0000 +++ b/js/core.js Thu Jan 19 10:47:42 2017 +0000 @@ -331,98 +331,40 @@ } } - // Detect the interface to use and load the relevant javascripts. - var interfaceJS = document.createElement('script'); - interfaceJS.setAttribute("type", "text/javascript"); - switch (specification.interface) { - case "APE": - interfaceJS.setAttribute("src", "interfaces/ape.js"); - - // APE comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/ape.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - - case "MUSHRA": - interfaceJS.setAttribute("src", "interfaces/mushra.js"); - - // MUSHRA comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/mushra.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - - case "AB": - interfaceJS.setAttribute("src", "interfaces/AB.js"); - - // AB comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/AB.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - - case "ABX": - interfaceJS.setAttribute("src", "interfaces/ABX.js"); - - // AB comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/ABX.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - - case "Bipolar": - case "ACR": - case "DCR": - case "CCR": - case "ABC": - // Above enumerate to horizontal sliders - interfaceJS.setAttribute("src", "interfaces/horizontal-sliders.js"); - - // horizontal-sliders comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/horizontal-sliders.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - case "discrete": - case "likert": - // Above enumerate to horizontal discrete radios - interfaceJS.setAttribute("src", "interfaces/discrete.js"); - - // horizontal-sliders comes with a css file - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/discrete.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; - case "timeline": - interfaceJS.setAttribute("src", "interfaces/timeline.js"); - var css = document.createElement('link'); - css.rel = 'stylesheet'; - css.type = 'text/css'; - css.href = 'interfaces/timeline.css'; - - document.getElementsByTagName("head")[0].appendChild(css); - break; + var getInterfaces = new XMLHttpRequest(); + getInterfaces.open("GET", "interfaces/interfaces.json"); + getInterfaces.onerror = function (e) { + throw (e); } - document.getElementsByTagName("head")[0].appendChild(interfaceJS); + getInterfaces.onload = function () { + if (getInterfaces.status !== 200) { + throw (new Error(getInterfaces.status)); + } + // Get the current interface + var name = specification.interface, + head = document.getElementsByTagName("head")[0], + data = JSON.parse(getInterfaces.responseText), + interfaceObject = data.interfaces.find(function (e) { + return e.name == name; + }); + if (!interfaceObject) { + throw ("Cannot load desired interface"); + } + interfaceObject.scripts.forEach(function (v) { + var script = document.createElement("script"); + script.setAttribute("type", "text/javascript"); + script.setAttribute("src", v); + head.appendChild(script); + }); + interfaceObject.css.forEach(function (v) { + var css = document.createElement("link"); + css.setAttribute("rel", "stylesheet"); + css.setAttribute("type", "text/css"); + css.setAttribute("href", v); + head.appendChild(css); + }); + } + getInterfaces.send(); if (gReturnURL != undefined) { console.log("returnURL Overide from " + specification.returnURL + " to " + gReturnURL); @@ -799,13 +741,13 @@ } else if (node.specification.type == 'number') { var input = document.createElement('input'); input.type = 'textarea'; - if (node.min != null) { + if (node.specification.min != null) { input.min = node.specification.min; } - if (node.max != null) { + if (node.specification.max != null) { input.max = node.specification.max; } - if (node.step != null) { + if (node.specification.step != null) { input.step = node.specification.step; } if (node.response != undefined) { @@ -823,6 +765,30 @@ iframe.className = "youtube"; iframe.src = node.specification.url; this.popupResponse.appendChild(iframe); + } else if (node.specification.type == "slider") { + var hold = document.createElement('div'); + var input = document.createElement('input'); + input.type = 'range'; + input.style.width = "90%"; + if (node.specification.min != null) { + input.min = node.specification.min; + } + if (node.specification.max != null) { + input.max = node.specification.max; + } + if (node.response != undefined) { + input.value = node.response; + } + hold.className = "survey-slider-text-holder"; + var minText = document.createElement('span'); + var maxText = document.createElement('span'); + minText.textContent = node.specification.leftText; + maxText.textContent = node.specification.rightText; + hold.appendChild(minText); + hold.appendChild(maxText); + this.popupResponse.appendChild(input); + this.popupResponse.appendChild(hold); + this.popupResponse.style.textAlign = "center"; } if (this.currentIndex + 1 == this.popupOptions.length) { if (this.node.location == "pre") { @@ -922,6 +888,33 @@ console.log("Checkbox: " + node.specification.statement); var inputs = this.popupResponse.getElementsByTagName('input'); node.response = []; + var numChecked = 0; + for (var i = 0; i < node.specification.options.length; i++) { + if (inputs[i].checked) { + numChecked++; + } + } + if (node.specification.min != undefined) { + if (node.specification.max == undefined) { + if (numChecked < node.specification.min) { + var msg = "You must select at least " + node.specification.min + " option"; + if (node.specification.min > 1) { + msg += "s"; + } + interfaceContext.lightbox.post("Error", msg); + return; + } + } else { + if (numChecked < node.specification.min || numChecked > node.specification.max) { + if (node.specification.min == node.specification.max) { + interfaceContext.lightbox.post("Error", "You must only select " + node.specification.min); + } else { + interfaceContext.lightbox.post("Error", "You must select between " + node.specification.min + " and " + node.specification.max); + } + return; + } + } + } for (var i = 0; i < node.specification.options.length; i++) { node.response.push({ name: node.specification.options[i].name, @@ -1080,6 +1073,49 @@ break; } } + } else if (node.specification.type == 'slider') { + var input = this.popupContent.getElementsByTagName('input')[0]; + node.response = input.value; + for (var condition of node.specification.conditions) { + var pass = false; + switch (condition.check) { + case "contains": + console.log("Survey Element of type 'number' cannot interpret contains conditions. IGNORING"); + break; + case "greaterThan": + if (node.response > Number(condition.value)) { + pass = true; + } + break; + case "lessThan": + if (node.response < Number(condition.value)) { + pass = true; + } + break; + case "equals": + if (node.response == condition.value) { + pass = true; + } + break; + } + var jumpID; + if (pass) { + jumpID = condition.jumpToOnPass; + } else { + jumpID = condition.jumpToOnFail; + } + if (jumpID != undefined) { + var index = this.popupOptions.findIndex(function (item, index, element) { + if (item.specification.id == jumpID) { + return true; + } else { + return false; + } + }, this); + this.currentIndex = index - 1; + break; + } + } } this.currentIndex++; if (this.currentIndex < this.popupOptions.length) { @@ -1394,10 +1430,8 @@ this.buffers = []; this.bufferObj = function () { - this.url = null; + var urls = []; this.buffer = null; - this.xmlRequest = new XMLHttpRequest(); - this.xmlRequest.parent = this; this.users = []; this.progress = 0; this.status = 0; @@ -1412,30 +1446,77 @@ } } }; - this.getMedia = function (url) { - this.url = url; - this.xmlRequest.open('GET', this.url, true); - this.xmlRequest.responseType = 'arraybuffer'; + this.setUrls = function (obj) { + // Obj must be an array of pairs: + // [{sampleRate, url}] + var localFs = audioContext.sampleRate, + list = [], + i; + for (i = 0; i < obj.length; i++) { + if (obj[i].sampleRate == localFs) { + list.push(obj.splice(i, 1)[0]); + } + } + list = list.concat(obj); + urls = list; + }; + this.hasUrl = function (checkUrl) { + var l = urls.length, + i; + for (i = 0; i < l; i++) { + if (urls[i].url == checkUrl) { + return true; + } + } + return false; + } + this.getMedia = function () { + var self = this; + var currentUrlIndex = 0; - var bufferObj = this; + function get(fqurl) { + return new Promise(function (resolve, reject) { + var req = new XMLHttpRequest(); + req.open('GET', fqurl, true); + req.responseType = 'arraybuffer'; + req.onload = function () { + if (req.status == 200) { + resolve(req.response); + } + }; + req.onerror = function () { + reject(new Error(req.statusText)); + }; + + req.addEventListener("progress", progressCallback.bind(self)); + req.send(); + }); + } + + function getNextURL() { + currentUrlIndex++; + var self = this; + if (currentUrlIndex >= urls.length) { + processError(); + } else { + return get(urls[currentUrlIndex].url).then(processAudio.bind(self)).catch(getNextURL.bind(self)); + } + } // Create callback to decode the data asynchronously - this.xmlRequest.onloadend = function () { - // Use inbuilt WAVE decoder first - if (this.status == -1) { - return; - } - var waveObj = new WAVE(); - audioContext.decodeAudioData(bufferObj.xmlRequest.response, function (decodedData) { - bufferObj.buffer = decodedData; - bufferObj.status = 2; - calculateLoudness(bufferObj, "I"); + function processAudio(response) { + var self = this; + return audioContext.decodeAudioData(response, function (decodedData) { + self.buffer = decodedData; + self.status = 2; + calculateLoudness(self, "I"); + return true; }, function (e) { var waveObj = new WAVE(); - if (waveObj.open(bufferObj.xmlRequest.response) == 0) { - bufferObj.buffer = audioContext.createBuffer(waveObj.num_channels, waveObj.num_samples, waveObj.sample_rate); + if (waveObj.open(response) == 0) { + self.buffer = audioContext.createBuffer(waveObj.num_channels, waveObj.num_samples, waveObj.sample_rate); for (var c = 0; c < waveObj.num_channels; c++) { - var buffer_ptr = bufferObj.buffer.getChannelData(c); + var buffer_ptr = self.buffer.getChannelData(c); for (var n = 0; n < waveObj.num_samples; n++) { buffer_ptr[n] = waveObj.decoded_data[c][n]; } @@ -1443,41 +1524,44 @@ delete waveObj; } - if (bufferObj.buffer != undefined) { - bufferObj.status = 2; - calculateLoudness(bufferObj, "I"); + if (self.buffer != undefined) { + self.status = 2; + calculateLoudness(self, "I"); + return true; } + return false; }); - }; + } // Create callback for any error in loading - this.xmlRequest.onerror = function () { - this.parent.status = -1; - for (var i = 0; i < this.parent.users.length; i++) { - this.parent.users[i].state = -1; - if (this.parent.users[i].interfaceDOM != null) { - this.parent.users[i].bufferLoaded(this); + function processError() { + this.status = -1; + for (var i = 0; i < this.users.length; i++) { + this.users[i].state = -1; + if (this.users[i].interfaceDOM != null) { + this.users[i].bufferLoaded(this); } } - interfaceContext.lightbox.post("Error", "Could not load resource " + this.parent.url); + interfaceContext.lightbox.post("Error", "Could not load resource " + urls[currentUrlIndex].url); } - this.progress = 0; - this.progressCallback = function (event) { + function progressCallback(event) { if (event.lengthComputable) { - this.parent.progress = event.loaded / event.total; - for (var i = 0; i < this.parent.users.length; i++) { - if (this.parent.users[i].interfaceDOM != null) { - if (typeof this.parent.users[i].interfaceDOM.updateLoading === "function") { - this.parent.users[i].interfaceDOM.updateLoading(this.parent.progress * 100); + this.progress = event.loaded / event.total; + for (var i = 0; i < this.users.length; i++) { + if (this.users[i].interfaceDOM != null) { + if (typeof this.users[i].interfaceDOM.updateLoading === "function") { + this.users[i].interfaceDOM.updateLoading(this.progress * 100); } } } } }; - this.xmlRequest.addEventListener("progress", this.progressCallback); + + this.progress = 0; this.status = 1; - this.xmlRequest.send(); + currentUrlIndex = 0; + get(urls[0].url).then(processAudio.bind(self)).catch(getNextURL.bind(self)); }; this.registerAudioObject = function (audioObject) { @@ -1554,14 +1638,25 @@ var URL = page.hostURL + element.url; var buffer = null; for (var buffObj of this.buffers) { - if (URL == buffObj.url) { + if (buffObj.hasUrl(URL)) { buffer = buffObj; break; } } if (buffer == null) { buffer = new this.bufferObj(); - buffer.getMedia(URL); + var urls = [{ + url: URL, + sampleRate: element.sampleRate + }]; + element.alternatives.forEach(function (e) { + urls.push({ + url: e.url, + sampleRate: e.sampleRate + }); + }); + buffer.setUrls(urls); + buffer.getMedia(); this.buffers.push(buffer); } } @@ -1631,7 +1726,7 @@ var URL = testState.currentStateMap.hostURL + element.url; var buffer = null; for (var i = 0; i < this.buffers.length; i++) { - if (URL == this.buffers[i].url) { + if (this.buffers[i].hasUrl(URL)) { buffer = this.buffers[i]; break; } @@ -1694,21 +1789,20 @@ }; this.setSynchronousLoop = function () { - // Pads the signals so they are all exactly the same length - // Get the length of the longest signal. - var length = 0; + // Pads the signals so they are all exactly the same duration + // Get the duration of the longest signal. + var duration = 0; var maxId; for (var i = 0; i < this.audioObjects.length; i++) { - if (length < this.audioObjects[i].buffer.buffer.length) { - length = this.audioObjects[i].buffer.buffer.length; + if (duration < this.audioObjects[i].buffer.buffer.duration) { + duration = this.audioObjects[i].buffer.buffer.duration; maxId = i; } } // Extract the audio and zero-pad for (var ao of this.audioObjects) { - var lengthDiff = length - ao.buffer.buffer.length; - if (lengthDiff > 0) { - ao.buffer.buffer = ao.buffer.copyBuffer(0, samplesToSeconds(lengthDiff, ao.buffer.buffer.sampleRate)); + if (ao.buffer.buffer.duration !== duration) { + ao.buffer.buffer = ao.buffer.copyBuffer(0, duration - ao.buffer.buffer.duration); } } }; @@ -2603,6 +2697,63 @@ this.resize(); }; + this.sliderBox = function (commentQuestion) { + this.specification = commentQuestion; + this.holder = document.createElement("div"); + this.holder.className = 'comment-div'; + this.string = document.createElement("span"); + this.string.innerHTML = commentQuestion.statement; + this.slider = document.createElement("input"); + this.slider.type = "range"; + this.slider.min = commentQuestion.min; + this.slider.max = commentQuestion.max; + this.slider.step = commentQuestion.step; + this.slider.value = commentQuestion.value; + var br = document.createElement('br'); + + var textHolder = document.createElement("div"); + textHolder.className = "comment-slider-text-holder"; + + this.leftText = document.createElement("span"); + this.leftText.textContent = commentQuestion.leftText; + this.rightText = document.createElement("span"); + this.rightText.textContent = commentQuestion.rightText; + textHolder.appendChild(this.leftText); + textHolder.appendChild(this.rightText); + + this.holder.appendChild(this.string); + this.holder.appendChild(br); + this.holder.appendChild(this.slider); + this.holder.appendChild(textHolder); + + this.exportXMLDOM = function (storePoint) { + var root = storePoint.parent.document.createElement('comment'); + root.id = this.specification.id; + root.setAttribute('type', this.specification.type); + console.log("Question: " + this.string.textContent); + console.log("Response: " + this.slider.value); + var question = storePoint.parent.document.createElement('question'); + question.textContent = this.string.textContent; + var response = storePoint.parent.document.createElement('response'); + response.textContent = this.slider.value; + root.appendChild(question); + root.appendChild(response); + storePoint.XMLDOM.appendChild(root); + return root; + }; + this.resize = function () { + var boxwidth = (window.innerWidth - 100) / 2; + if (boxwidth >= 600) { + boxwidth = 600; + } else if (boxwidth < 400) { + boxwidth = 400; + } + this.holder.style.width = boxwidth + "px"; + this.slider.style.width = boxwidth - 24 + "px"; + }; + this.resize(); + }; + this.createCommentQuestion = function (element) { var node; if (element.type == 'question') { @@ -2611,6 +2762,8 @@ node = new this.radioBox(element); } else if (element.type == 'checkbox') { node = new this.checkboxBox(element); + } else if (element.type == 'slider') { + node = new this.sliderBox(element); } this.commentQuestions.push(node); return node; @@ -2886,8 +3039,8 @@ obj.input.value = obj.gain.gain.value; obj.input.setAttribute('orient', 'vertical'); obj.input.type = "range"; - obj.input.min = -6; - obj.input.max = 6; + obj.input.min = -12; + obj.input.max = 0; obj.input.step = 0.25; if (f0 != 1000) { obj.input.value = (Math.random() * 12) - 6; @@ -3102,6 +3255,79 @@ node.textContent = errorMessage; testState.currentStore.XMLDOM.appendChild(node); }; + + this.getLabel = function (labelType, index, labelStart) { + /* + Get the correct label based on type, index and offset + */ + + function calculateLabel(labelType, index, offset) { + if (labelType == "none") { + return ""; + } + switch (labelType) { + case "letter": + return String.fromCharCode((index + offset) % 26 + 97); + case "capital": + return String.fromCharCode((index + offset) % 26 + 65); + case "samediff": + if (index == 0) { + return "Same"; + } else if (index == 1) { + return "Difference"; + } else { + return ""; + } + case "number": + return String(index + offset); + default: + return ""; + } + } + + if (typeof labelStart !== "string" || labelStart.length == 0) { + labelStart = String.fromCharCode(0); + } + + switch (labelType) { + case "letter": + labelStart = labelStart.charCodeAt(0); + if (labelStart < 97 || labelStart > 122) { + labelStart = 97; + } + labelStart -= 97; + break; + case "capital": + labelStart = labelStart.charCodeAt(0); + if (labelStart < 65 || labelStart > 90) { + labelStart = 65; + } + labelStart -= 65; + break; + case "number": + labelStart = Number(labelStart); + if (!isFinite(labelStart)) { + labelStart = 1; + } + break; + case "none": + default: + labelStart = 0; + } + if (typeof index == "number") { + return calculateLabel(labelType, index, labelStart); + } else if (index.length && index.length > 0) { + var a = [], + l = index.length, + i; + for (i = 0; i < l; i++) { + a[i] = calculateLabel(labelType, index[i], labelStart); + } + return a; + } else { + throw ("Invalid arguments"); + } + } } function Storage() { @@ -3257,14 +3483,17 @@ switch (node.specification.type) { case "number": case "question": + case "slider": var child = this.parent.document.createElement('response'); child.textContent = node.response; surveyresult.appendChild(child); break; case "radio": var child = this.parent.document.createElement('response'); - child.setAttribute('name', node.response.name); - child.textContent = node.response.text; + if (node.response !== null) { + child.setAttribute('name', node.response.name); + child.textContent = node.response.text; + } surveyresult.appendChild(child); break; case "checkbox": diff -r 03a9a90717ed -r e3cf3c24149e js/specification.js --- a/js/specification.js Thu Jan 19 10:37:30 2017 +0000 +++ b/js/specification.js Thu Jan 19 10:47:42 2017 +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++) { @@ -257,8 +278,7 @@ }; this.exportXML = function (doc) { - var node = doc.createElement('surveyentry'); - node.setAttribute('type', this.type); + var node = doc.createElement('survey' + this.type); var statement = doc.createElement('statement'); statement.textContent = this.statement; node.appendChild(statement); @@ -275,6 +295,16 @@ } switch (this.type) { case "checkbox": + if (this.min != undefined) { + node.setAttribute("min", this.min); + } else { + node.setAttribute("min", "0"); + } + if (this.max != undefined) { + node.setAttribute("max", this.max); + } else { + node.setAttribute("max", "undefined"); + } case "radio": for (var i = 0; i < this.options.length; i++) { var option = this.options[i]; @@ -283,6 +313,7 @@ optionNode.textContent = option.text; node.appendChild(optionNode); } + break; case "number": if (this.min != undefined) { node.setAttribute("min", this.min); @@ -290,6 +321,7 @@ if (this.max != undefined) { node.setAttribute("max", this.max); } + break; case "question": if (this.boxsize != undefined) { node.setAttribute("boxsize", this.boxsize); @@ -297,6 +329,29 @@ if (this.mandatory != undefined) { node.setAttribute("mandatory", this.mandatory); } + break; + case "video": + if (this.mandatory != undefined) { + node.setAttribute("mandatory", this.mandatory); + } + case "youtube": + if (this.url != undefined) { + node.setAttribute("url", this.url); + } + break; + case "slider": + node.setAttribute("min", this.min); + node.setAttribute("max", this.max); + if (this.leftText) { + var minText = doc.createElement("minText"); + minText.textContent = this.leftText; + node.appendChild(minText); + } + if (this.rightText) { + var maxText = doc.createElement("maxText"); + maxText.textContent = this.rightText; + node.appendChild(maxText); + } default: break; } @@ -319,11 +374,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"); @@ -459,10 +515,12 @@ this.outsideReference = null; this.loudness = null; this.label = null; + this.labelStart = ""; this.preTest = null; this.postTest = null; this.interfaces = []; this.playOne = null; + this.restrictMovement = null; this.commentBoxPrefix = "Comment on track"; this.audioElements = []; this.commentQuestions = []; @@ -539,11 +597,15 @@ } // Now decode the commentquestions - var commentQuestions = xml.getElementsByTagName('commentquestion'); - for (var i = 0; i < commentQuestions.length; i++) { - var node = new this.commentQuestionNode(this.specification); - node.decode(parent, commentQuestions[i]); - this.commentQuestions.push(node); + var cqNode = xml.getElementsByTagName('commentquestions'); + if (cqNode.length != 0) { + cqNode = cqNode[0]; + var commentQuestions = cqNode.children; + for (var i = 0; i < commentQuestions.length; i++) { + var node = new this.commentQuestionNode(this.specification); + node.decode(parent, commentQuestions[i]); + this.commentQuestions.push(node); + } } }; @@ -589,26 +651,85 @@ this.id = null; this.name = undefined; this.type = undefined; - this.options = []; this.statement = undefined; this.schema = specification.schema.getAllElementsByName('commentquestion')[0]; this.decode = function (parent, xml) { this.id = xml.id; this.name = xml.getAttribute('name'); - this.type = xml.getAttribute('type'); + switch (xml.nodeName) { + case "commentradio": + this.type = "radio"; + this.options = []; + break; + case "commentcheckbox": + this.type = "checkbox"; + this.options = []; + break; + case "commentslider": + this.type = "slider"; + this.min = undefined; + this.max = undefined; + this.step = undefined; + break; + case "commentquestion": + default: + this.type = "question"; + break; + } this.statement = xml.getElementsByTagName('statement')[0].textContent; - var optNodes = xml.getElementsByTagName('option'); - for (var i = 0; i < optNodes.length; i++) { - var optNode = optNodes[i]; - this.options.push({ - name: optNode.getAttribute('name'), - text: optNode.textContent - }); + if (this.type == "radio" || this.type == "checkbox") { + var optNodes = xml.getElementsByTagName('option'); + for (var i = 0; i < optNodes.length; i++) { + var optNode = optNodes[i]; + this.options.push({ + name: optNode.getAttribute('name'), + text: optNode.textContent + }); + } + } + if (this.type == "slider") { + this.min = Number(xml.getAttribute("min")); + this.max = Number(xml.getAttribute("max")); + this.step = Number(xml.getAttribute("step")); + if (this.step == undefined) { + this.step = 1; + } + this.value = Number(xml.getAttribute("value")); + if (this.value == undefined) { + this.value = min; + } + this.leftText = xml.getElementsByTagName("minText"); + if (this.leftText && this.leftText.length > 0) { + this.leftText = this.leftText[0].textContent; + } else { + this.leftText = ""; + } + this.rightText = xml.getElementsByTagName("maxText"); + if (this.rightText && this.rightText.length > 0) { + this.rightText = this.rightText[0].textContent; + } else { + this.rightText = ""; + } } }; this.encode = function (root) { - var node = root.createElement("commentquestion"); + var node; + switch (this.type) { + case "radio": + node = root.createElement("commentradio"); + break; + case "checkbox": + node = root.createElement("commentcheckbox"); + break; + case "slider": + node = root.createElement("commentslider"); + break; + case "question": + default: + node = root.createElement("commentquestion"); + break; + } node.id = this.id; node.setAttribute("type", this.type); if (this.name != undefined) { @@ -617,11 +738,33 @@ var statement = root.createElement("statement"); statement.textContent = this.statement; node.appendChild(statement); - for (var option of this.options) { - var child = root.createElement("option"); - child.setAttribute("name", option.name); - child.textContent = option.text; - node.appendChild(child); + if (this.type == "radio" || this.type == "checkbox") { + for (var option of this.options) { + var child = root.createElement("option"); + child.setAttribute("name", option.name); + child.textContent = option.text; + node.appendChild(child); + } + } + if (this.type == "slider") { + node.setAttribute("min", this.min); + node.setAttribute("max", this.max); + if (this.step !== 1) { + node.setAttribute("step", this.step); + } + if (this.value !== this.min) { + node.setAttribute("value", this.value); + } + if (this.leftText.length > 0) { + var leftText = root.createElement("minText"); + leftText.textContent = this.leftText; + node.appendChild(leftText); + } + if (this.rightText.length > 0) { + var rightText = root.createElement("maxText"); + rightText.textContent = this.rightText; + node.appendChild(rightText); + } } return node; }; @@ -639,6 +782,8 @@ this.label = null; this.startTime = undefined; this.stopTime = undefined; + this.sampleRate = undefined; + this.alternatives = []; this.schema = specification.schema.getAllElementsByName('audioelement')[0];; this.parent = null; this.decode = function (parent, xml) { @@ -658,6 +803,17 @@ break; } } + // Get the alternative nodes + var child = xml.firstElementChild; + while (child) { + if (child.nodeName == "alternative") { + this.alternatives.push({ + 'url': child.getAttribute("url"), + 'sampleRate': child.getAttribute("sampleRate") + }); + } + child = child.nextElementSibling; + } }; this.encode = function (root) { @@ -672,6 +828,12 @@ eval("AENode.setAttribute('" + name + "',this." + name + ")"); } } + this.alternatives.forEach(function (alt) { + var node = root.createElement("alternative"); + node.setAttribute("url", alt.url); + node.setAttribute("sampleRate", alt.sampleRate); + AENode.appendChild(node); + }); return AENode; }; }; diff -r 03a9a90717ed -r e3cf3c24149e python/generate_report.py --- a/python/generate_report.py Thu Jan 19 10:37:30 2017 +0000 +++ b/python/generate_report.py Thu Jan 19 10:47:42 2017 +0000 @@ -120,9 +120,10 @@ # generate images for later use if render_figures: - subprocess.call("python timeline_view_movement.py '"+folder_name+"'", shell=True) - subprocess.call("python score_parser.py '"+folder_name+"'", shell=True) - subprocess.call("python score_plot.py '"+folder_name+"ratings/'", shell=True) + script_path = os.path.dirname(os.path.realpath(__file__)) # where is generate_report.py? + subprocess.call("python " +script_path+"/timeline_view_movement.py '"+folder_name+"'", shell=True) + subprocess.call("python " +script_path+"/score_parser.py '"+folder_name+"'", shell=True) + subprocess.call("python " +script_path+"/score_plot.py '"+folder_name+"ratings/'", shell=True) # make array of text and array of dates body_array = [] diff -r 03a9a90717ed -r e3cf3c24149e python/timeline_view_movement.py --- a/python/timeline_view_movement.py Thu Jan 19 10:37:30 2017 +0000 +++ b/python/timeline_view_movement.py Thu Jan 19 10:47:42 2017 +0000 @@ -124,9 +124,10 @@ stop_times_global = [] listen_events = audioelement.findall("./metric/metricresult/[@name='elementListenTracker']/event") for event in listen_events: - # get testtime: start and stop - start_times_global.append(float(event.find('testtime').get('start')))#-time_offset) - stop_times_global.append(float(event.find('testtime').get('stop')))#-time_offset) + if event.find('testtime') is not None: + # get testtime: start and stop + start_times_global.append(float(event.find('testtime').get('start')))#-time_offset) + stop_times_global.append(float(event.find('testtime').get('stop')))#-time_offset) # display fragment name at start plt.text(0,initial_position+0.02,audio_id,color=colormap[increment%len(colormap)]) #,rotation=45 @@ -289,12 +290,35 @@ plt.ylabel('Rating') # default plt.ylim(0, 1) # rating between 0 and 1 - # TO DO: - # Y axis title and tick labels as specified in 'setup' for corresponding page + # Y axis title and tick labels as specified in 'setup' + # for corresponding page + page_setup = root.find("./waet/page[@id='"+page_name+"']") + # 'ref' of page is 'id' in page setup + # Different plots for different axes + interfaces = page_setup.findall("./interface") + interface_title = interfaces[0].find("./title") + scales = interfaces[0].findall("./scales") # get first interface by default + scalelabels = scales[0].findall("./scalelabel") # get first scale by default + + labelpos = [] # array of scalelabel positions + labelstr = [] # array of strings at labels + for scalelabel in scalelabels: + labelpos.append(float(scalelabel.get('position'))/100.0) + labelstr.append(scalelabel.text) + + # use interface name as Y axis label + if interface_title is not None: + plt.ylabel(interface_title.text) + else: + plt.ylabel('Rating') # default + + if len(labelpos): + plt.yticks(labelpos, labelstr) #plt.show() # uncomment to show plot; comment when just saving #exit() + # save as PDF plt.savefig(timeline_folder+subject_id+"-"+page_name+".pdf", bbox_inches='tight') plt.close() diff -r 03a9a90717ed -r e3cf3c24149e test_create/attributes.json --- a/test_create/attributes.json Thu Jan 19 10:37:30 2017 +0000 +++ b/test_create/attributes.json Thu Jan 19 10:47:42 2017 +0000 @@ -27,5 +27,9 @@ "postSilence": "Post Silence", "poolSize": "Pool Size", "alwaysInclude": "Always Include", - "crossFade": "Cross Fade" + "crossFade": "Cross Fade", + "check": "Check", + "value": "Value", + "jumpToOnPass": "Jump To ID On Pass", + "jumpToOnFail": "Jump To ID On Fail" } diff -r 03a9a90717ed -r e3cf3c24149e test_create/test_core.js --- a/test_create/test_core.js Thu Jan 19 10:37:30 2017 +0000 +++ b/test_create/test_core.js Thu Jan 19 10:47:42 2017 +0000 @@ -975,7 +975,7 @@ handleEvent: function (event) { this.parent.scaleRoot.scales = []; var protoScale = interfaceSpecs.getAllElementsByTagName('scaledefinitions')[0].getAllElementsByName(event.currentTarget.value)[0]; - var protoMarkers = protoScale.getElementsByTagName("scale"); + var protoMarkers = protoScale.getElementsByTagName("scalelabel"); for (var i = 0; i < protoMarkers.length; i++) { var marker = { position: protoMarkers[i].getAttribute("position"), @@ -992,6 +992,22 @@ optionHolder.className = 'node'; optionHolder.id = 'popup-option-holder'; this.content.appendChild(optionHolder); + this.addMarker = { + root: document.createElement("button"), + parent: this, + handleEvent: function () { + var marker = { + position: 0, + text: "text" + }; + this.parent.scaleRoot.scales.push(marker); + var markerNode = new this.parent.buildMarkerNode(this.parent, marker); + document.getElementById("popup-option-holder").appendChild(markerNode.root); + this.parent.markerNodes.push(markerNode); + } + }; + this.addMarker.root.textContent = "Add Marker"; + this.addMarker.root.addEventListener("click", this.addMarker); this.generate = function (scaleRoot, parent) { this.scaleRoot = scaleRoot; this.parent = parent; @@ -1007,23 +1023,6 @@ selectOption.textContent = scaleName; this.preset.input.appendChild(selectOption); } - - this.addMarker = { - root: document.createElement("button"), - parent: this, - handleEvent: function () { - var marker = { - position: 0, - text: "text" - }; - this.parent.scaleRoot.scales.push(marker); - var markerNode = new this.parent.buildMarkerNode(this.parent, marker); - document.getElementById("popup-option-holder").appendChild(markerNode.root); - this.parent.markerNodes.push(markerNode); - } - }; - this.addMarker.root.textContent = "Add Marker"; - this.addMarker.root.addEventListener("click", this.addMarker); this.content.appendChild(this.addMarker.root); // Create Marker List diff -r 03a9a90717ed -r e3cf3c24149e tests/examples/APE_example.xml --- a/tests/examples/APE_example.xml Thu Jan 19 10:37:30 2017 +0000 +++ b/tests/examples/APE_example.xml Thu Jan 19 10:47:42 2017 +0000 @@ -6,7 +6,7 @@ Please enter your name. - + Please select with which activities you have any experience (example checkbox question) @@ -111,24 +111,26 @@ - - What is your general experience with numbers? - - - Please enter your overall preference - - - - - - - - Please describe the overall character - - - - - + + + What is your general experience with numbers? + + + Please enter your overall preference + + + + + + + + Please describe the overall character + + + + + + Example of an 'APE' style interface with hidden anchor 'zero' (which needs to be below 20%), looping of the samples, randomisation of marker labels, mandatory moving of every sample, and a forced scale usage of at least 25%-75%. diff -r 03a9a90717ed -r e3cf3c24149e tests/examples/mushra_example.xml --- a/tests/examples/mushra_example.xml Thu Jan 19 10:37:30 2017 +0000 +++ b/tests/examples/mushra_example.xml Thu Jan 19 10:47:42 2017 +0000 @@ -53,7 +53,7 @@ - + Comment on fragment @@ -82,7 +82,7 @@ - + Comment on fragment Example Test Question @@ -101,24 +101,26 @@ - - What is your general experience with numbers? - - - Please enter your overall preference - - - - - - - - Please describe the overall character - - - - - + + + What is your general experience with numbers? + + + Please enter your overall preference + + + + + + + + Please describe the overall character + + + + + + Example of a 'MUSHRA' style interface with hidden anchor 'zero' (which needs to be below 20%), looping of the samples, randomisation of marker labels, mandatory moving of every sample, and a forced scale usage of at least 25%-75%. diff -r 03a9a90717ed -r e3cf3c24149e xml/test-schema.xsd --- a/xml/test-schema.xsd Thu Jan 19 10:37:30 2017 +0000 +++ b/xml/test-schema.xsd Thu Jan 19 10:47:42 2017 +0000 @@ -75,7 +75,7 @@ - + @@ -97,11 +97,13 @@ + + @@ -162,6 +164,20 @@ + + + + + + + + + + + + + + @@ -203,13 +219,31 @@ + + + + + + + - + + + + + + + + + + + + - + @@ -222,22 +256,202 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -250,23 +464,7 @@ - - - - - - - - - - - - - - - - - + @@ -299,7 +497,15 @@ - + + + + + + + + +