diff core.js @ 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 34d8bca65edc
children cad1178196b4
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!!