Mercurial > hg > webaudioevaluationtool
changeset 2774:2fc62a50d593
#145. Added minWait to all <surveyx> elements. Specify the amount of time to wait in seconds.
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Fri, 21 Apr 2017 14:03:51 +0100 |
parents | e31b3e1716f1 |
children | 87d71c41c174 |
files | js/core.js js/specification.js tests/examples/AB_example.xml xml/test-schema.xsd |
diffstat | 4 files changed, 40 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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 = [];
--- 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 @@ <waet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test-schema.xsd"> <setup interface="AB" projectReturn="save.php" randomiseOrder='true' poolSize="2" loudness="-23" playOne="true"> <survey location="before"> - <surveyentry type="question" id="sessionId" mandatory="true"> + <surveyquestion id="sessionId" mandatory="true"> <statement>Please enter your name.</statement> - </surveyentry> - <surveyentry type="checkbox" id="checkboxtest" mandatory="true"> + </surveyquestion> + <surveycheckbox id="checkboxtest" mandatory="true"> <statement>Please select with which activities you have any experience (example checkbox question)</statement> <option name="musician">Playing a musical instrument</option> <option name="soundengineer">Recording or mixing audio</option> <option name="developer">Developing audio software</option> <option name="hwdesigner">Designing or building audio hardware</option> <option name="researcher">Research in the field of audio</option> - </surveyentry> - <surveyentry type="statement" id="test-intro"> + </surveycheckbox> + <surveystatement id="test-intro"> <statement>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. </statement> - </surveyentry> + </surveystatement> </survey> <survey location="after"> - <surveyentry type="question" id="location" mandatory="true" boxsize="large"> + <surveyquestion id="location" mandatory="true" boxsize="large"> <statement>Please enter your location. (example mandatory text question)</statement> - </surveyentry> - <surveyentry type="number" id="age" min="0"> + </surveyquestion> + <surveynumber id="age" min="0"> <statement>Please enter your age (example non-mandatory number question)</statement> - </surveyentry> - <surveyentry type="radio" id="rating"> + </surveynumber> + <surveyradio id="rating"> <statement>Please rate this interface (example radio button question)</statement> <option name="bad">Bad</option> <option name="poor">Poor</option> <option name="good">Good</option> <option name="great">Great</option> - </surveyentry> - <surveyentry type="statement" id="test-thank-you"> + </surveyradio> + <surveystatement id="test-thank-you"> <statement>Thank you for taking this listening test. Please click 'submit' and your results will appear in the 'saves/' folder.</statement> - </surveyentry> + </surveystatement> </survey> <metric> <metricenable>testTimer</metricenable> @@ -61,14 +61,14 @@ <audioelement url="0.wav" id="track-0" /> <audioelement url="1.wav" id="track-1" /> <survey location="before"> - <surveyentry type="statement" id="test-0-intro"> + <surveystatement id="test-0-intro"> <statement>A two way comparison using randomised element order, automatic loudness and synchronised looping.</statement> - </surveyentry> + </surveystatement> </survey> <survey location="after"> - <surveyentry type="question" id="genre-0" mandatory="true"> + <surveyquestion id="genre-0" mandatory="true"> <statement>Please enter the genre.</statement> - </surveyentry> + </surveyquestion> </survey> </page> <page id='test-1' hostURL="media/example/" randomiseOrder='true' repeatCount='0' loop='false' loudness="-12"> @@ -84,14 +84,14 @@ <audioelement url="5.wav" id="track-7" /> <audioelement url="6.wav" id="track-8" /> <survey location="before"> - <surveyentry type="statement" id="test-1-intro"> + <surveystatement id="test-1-intro"> <statement>A 7 way comparison using randomised element order and synchronised looping.</statement> - </surveyentry> + </surveystatement> </survey> <survey location="after"> - <surveyentry type="question" id="genre-1" mandatory="true"> + <surveyquestion id="genre-1" mandatory="true"> <statement>Please enter the genre.</statement> - </surveyentry> + </surveyquestion> </survey> </page> </waet>
--- 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 @@ </xs:attribute> <xs:attribute name="playOne" type="xs:boolean" default="false" /> + + <xs:attribute name="minWait" type="xs:nonNegativeInteger" default="0" /> <!-- define complex elements--> <xs:element name="waet"> @@ -332,6 +334,7 @@ <xs:attribute ref="id" use="required" /> <xs:attribute ref="name" /> <xs:attribute ref="mandatory" /> + <xs:attribute ref="minWait" /> <xs:attribute name="boxsize" default="normal"> <xs:simpleType> <xs:restriction base="xs:string"> @@ -365,6 +368,7 @@ <xs:attribute ref="mandatory" /> <xs:attribute name="min" type="xs:decimal" /> <xs:attribute name="max" type="xs:decimal" /> + <xs:attribute ref="minWait" /> </xs:complexType> </xs:element> @@ -386,6 +390,7 @@ <xs:attribute ref="id" use="required" /> <xs:attribute ref="name" /> <xs:attribute ref="mandatory" /> + <xs:attribute ref="minWait" /> <xs:attribute name="min" type="xs:decimal" /> <xs:attribute name="max" type="xs:decimal" /> </xs:complexType> @@ -409,6 +414,7 @@ <xs:attribute ref="id" use="required" /> <xs:attribute ref="name" /> <xs:attribute ref="mandatory" /> + <xs:attribute ref="minWait" /> <xs:attribute name="min" type="xs:decimal" /> <xs:attribute name="max" type="xs:decimal" /> </xs:complexType> @@ -424,6 +430,7 @@ </xs:sequence> <xs:attribute ref="id" use="required" /> <xs:attribute ref="name" /> + <xs:attribute ref="minWait" /> <xs:attribute name="min" use="required" type="xs:decimal" /> <xs:attribute name="max" use="required" type="xs:decimal" /> </xs:complexType> @@ -435,6 +442,7 @@ <xs:element ref="statement" minOccurs="1" maxOccurs="1" /> </xs:sequence> <xs:attribute ref="id" use="required" /> + <xs:attribute ref="minWait" /> <xs:attribute name="url" use="required" type="xs:string" /> </xs:complexType> </xs:element> @@ -445,6 +453,7 @@ <xs:element ref="statement" minOccurs="1" maxOccurs="1" /> </xs:sequence> <xs:attribute ref="id" use="required" /> + <xs:attribute ref="minWait" /> <xs:attribute name="url" use="required" type="xs:string" /> </xs:complexType> </xs:element>