changeset 611:fef9f13bec0a multiple-tests-concatenation

Workaround for #1658: in order to obtain a test with zero pages, set attribute hidden='true' in the one and only page
author Giulio Moro <giuliomoro@yahoo.it>
date Sun, 13 Mar 2016 02:12:30 +0000
parents babcc4ac48eb
children 80582bdf9d12
files core.js example_eval/post_survey.xml example_eval/pre_survey.xml test-schema.xsd
diffstat 4 files changed, 27 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/core.js	Sat Mar 12 16:30:56 2016 +0000
+++ b/core.js	Sun Mar 13 02:12:30 2016 +0000
@@ -1067,7 +1067,7 @@
                             buffer_ptr[n] = waveObj.decoded_data[c][n];
                         }
                     }
-                    
+
                     delete waveObj;
                 } else {
                     audioContext.decodeAudioData(bufferObj.xmlRequest.response, function(decodedData) {
@@ -1475,10 +1475,16 @@
 	
 	this.exportXMLDOM = function() {
 		var file = storage.document.createElement('file');
-		file.setAttribute('sampleRate',this.buffer.buffer.sampleRate);
-		file.setAttribute('channels',this.buffer.buffer.numberOfChannels);
-		file.setAttribute('sampleCount',this.buffer.buffer.length);
-		file.setAttribute('duration',this.buffer.buffer.duration);
+		var buf;
+		if(typeof(this.buffer) !== "undefined"){
+			buf = this.buffer.buffer;
+		} else {
+			buf = {};
+		}
+		file.setAttribute('sampleRate', buf.sampleRate);
+		file.setAttribute('channels', buf.numberOfChannels);
+		file.setAttribute('sampleCount', buf.length);
+		file.setAttribute('duration', buf.duration);
 		this.storeDOM.appendChild(file);
 		if (this.specification.type != 'outside-reference') {
 			var interfaceXML = this.interfaceDOM.exportXMLDOM(this);
@@ -2438,6 +2444,11 @@
 		interfaceContext.commentBoxes.deleteCommentBoxes();
 		interfaceContext.deleteCommentQuestions();
 		loadTest(audioHolderObject,store);
+		if(audioHolderObject.hidden === true){ 
+		// work-around to have zero pages: set the attribute hidden=true and 
+		// it will automatically skip over.
+			testState.advanceState();
+		}
 	};
 	
 	// Bounded by interface!!
--- a/example_eval/post_survey.xml	Sat Mar 12 16:30:56 2016 +0000
+++ b/example_eval/post_survey.xml	Sun Mar 13 02:12:30 2016 +0000
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <waet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="test-schema.xsd">
-	<setup interface="AB" projectReturn="save.php" randomiseOrder='true' testPages="1" loudness="-23" sampleRate="44100">
+	<setup interface="AB" projectReturn="save.php" randomiseOrder='true' testPages="2" loudness="-23" sampleRate="44100">
         <survey location="after">
             <surveyentry type="question" id="location" mandatory="true" boxsize="large">
                 <statement>Please enter your location. (example mandatory text question)</statement>
@@ -15,7 +15,7 @@
                 <option name="good">Good</option>
                 <option name="great">Great</option>
             </surveyentry>
-            <surveyentry type="statement">
+            <surveyentry type="statement" id="done">
                 <statement>Thank you for taking this listening test. May God be with you.</statement>
             </surveyentry>
         </survey>
@@ -37,12 +37,13 @@
             </interfaceoption-->
 		</interface>
 	</setup>
-    <page id="test-0" hostURL="example_eval/" randomiseOrder="true" repeatCount="0" loop="false" showElementComments="true" loudness="-12">
+    
+    <page id="test-0" hostURL="example_eval/" showElementComments="false" hidden="true">
         <commentboxprefix>Comment on fragment</commentboxprefix>
         <interface>
-            <title>SKIP THIS PAGE. I WANT 0 PAGES!!!!</title>
+            <title>Post-test survey</title>
         </interface>
-        <audioelement url="2.wav" id="track-0"/>
-        <audioelement url="1.wav" id="track-1"/>
+        <audioelement url="1.wav" id="dummy"/>
     </page>
+
 </waet>
\ No newline at end of file
--- a/example_eval/pre_survey.xml	Sat Mar 12 16:30:56 2016 +0000
+++ b/example_eval/pre_survey.xml	Sun Mar 13 02:12:30 2016 +0000
@@ -13,7 +13,7 @@
 				<option name="hwdesigner">Designing or building audio hardware</option>
 				<option name="researcher">Research in the field of audio</option>
 			</surveyentry>
-			<surveyentry type="statement">
+            <surveyentry type="statement" id="pre-survey">
 				<statement>This is a preliminary test for a study on the Hammond organ. You will be presented with pairs of stimuli. For each pair you will be asked to single out the one note that was produced by a heavier touch.
                     
                     Feel free to add any comments on the stimuli in the boxes at the bottom of each page of the test.	</statement>
@@ -40,12 +40,10 @@
             </interfaceoption-->
 		</interface>
 	</setup>
-    <page id="test-0" hostURL="example_eval/" randomiseOrder="true" repeatCount="0" loop="false" showElementComments="true" loudness="-12">
-        <commentboxprefix>Comment on fragment</commentboxprefix>
+    <page id="test-0" hostURL="example_eval/" hidden="true">
         <interface>
-            <title>SKIP OVER THIS, I WANT ZERO PAGES!!!</title>
+            <title>Pre-test survey</title>
         </interface>
-        <audioelement url="1.wav" id="track-0"/>
         <audioelement url="1.wav" id="track-1"/>
     </page>
 </waet>
\ No newline at end of file
--- a/test-schema.xsd	Sat Mar 12 16:30:56 2016 +0000
+++ b/test-schema.xsd	Sun Mar 13 02:12:30 2016 +0000
@@ -73,6 +73,7 @@
       <xs:attribute name="synchronous" type="xs:boolean" default="false"/>
       <xs:attribute name="showElementComments" type="xs:boolean" default="false"/>
       <xs:attribute name="loudness" type="xs:nonPositiveInteger" use="optional"/>
+      <xs:attribute name="hidden" type="xs:boolean" default="false"/>
       <xs:attribute name="label" use="optional" default="default">
           <xs:simpleType>
               <xs:restriction base="xs:string">