# HG changeset patch # User Nicholas Jillings # Date 1492779831 -3600 # Node ID 2fc62a50d593f48163f59edac85a4078abb16b21 # Parent e31b3e1716f11a69c517de2e4aa84f9f17f025da #145. Added minWait to all elements. Specify the amount of time to wait in seconds. diff -r e31b3e1716f1 -r 2fc62a50d593 js/core.js --- a/js/core.js Fri Apr 21 13:44:21 2017 +0100 +++ b/js/core.js Fri Apr 21 14:03:51 2017 +0100 @@ -553,6 +553,7 @@ this.currentIndex = null; this.node = null; this.store = null; + var lastNodeStart = undefined; $(window).keypress(function (e) { if (e.keyCode == 13 && popup.popup.style.visibility == 'visible') { console.log(e); @@ -1048,6 +1049,7 @@ var node = this.popupOptions[this.currentIndex], converter = new showdown.Converter(), p = new DOMParser(); + lastNodeStart = new Date(); this.popupResponse.innerHTML = ""; this.popupTitle.innerHTML = ""; this.popupTitle.appendChild(p.parseFromString(converter.makeHtml(node.specification.statement), "text/html").getElementsByTagName("body")[0].firstElementChild); @@ -1110,7 +1112,12 @@ return; } var node = this.popupOptions[this.currentIndex], - pass = true; + pass = true, + timeDelta = (new Date() - lastNodeStart)/1000.0; + if (timeDelta < node.specification.minWait) { + interfaceContext.lightbox.post("Error", "Not enough time has elapsed, please wait "+(node.specification.minWait-timeDelta).toFixed(0)+" seconds"); + return; + } if (node.specification.type == 'question') { // Must extract the question data pass = processQuestion.call(this, node); diff -r e31b3e1716f1 -r 2fc62a50d593 js/specification.js --- a/js/specification.js Fri Apr 21 13:44:21 2017 +0100 +++ b/js/specification.js Fri Apr 21 14:03:51 2017 +0100 @@ -223,6 +223,7 @@ this.options = []; this.min = undefined; this.max = undefined; + this.minWait = undefined; this.step = undefined; this.conditions = []; diff -r e31b3e1716f1 -r 2fc62a50d593 tests/examples/AB_example.xml --- a/tests/examples/AB_example.xml Fri Apr 21 13:44:21 2017 +0100 +++ b/tests/examples/AB_example.xml Fri Apr 21 14:03:51 2017 +0100 @@ -2,38 +2,38 @@ - + 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/'. The 'playOne' configuration option means a fragment has to be finished playing before another fragment can be auditioned. - + - + Please enter your location. (example mandatory text question) - - + + Please enter your age (example non-mandatory number question) - - + + Please rate this interface (example radio button question) - - + + Thank you for taking this listening test. Please click 'submit' and your results will appear in the 'saves/' folder. - + testTimer @@ -61,14 +61,14 @@ - + A two way comparison using randomised element order, automatic loudness and synchronised looping. - + - + Please enter the genre. - + @@ -84,14 +84,14 @@ - + A 7 way comparison using randomised element order and synchronised looping. - + - + Please enter the genre. - + diff -r e31b3e1716f1 -r 2fc62a50d593 xml/test-schema.xsd --- a/xml/test-schema.xsd Fri Apr 21 13:44:21 2017 +0100 +++ b/xml/test-schema.xsd Fri Apr 21 14:03:51 2017 +0100 @@ -28,6 +28,8 @@ + + @@ -332,6 +334,7 @@ + @@ -365,6 +368,7 @@ + @@ -386,6 +390,7 @@ + @@ -409,6 +414,7 @@ + @@ -424,6 +430,7 @@ + @@ -435,6 +442,7 @@ + @@ -445,6 +453,7 @@ +