# HG changeset patch # User Nicholas Jillings # Date 1432457855 -3600 # Node ID cf2563abbc6518e873b4d62654926101847bc168 # Parent f2c05f147dd28732e0d13af01e708c1b30f18b27 Bug #1226: Moved check to audioObjects and audioEngine so available for all interfaces. Also interface pop-up now states all outstanding fragments to listen. diff -r f2c05f147dd2 -r cf2563abbc65 ape.js --- a/ape.js Sun May 17 21:37:08 2015 +0100 +++ b/ape.js Sun May 24 09:57:35 2015 +0100 @@ -11,10 +11,6 @@ // postTest - End of test, final submission! -// Create empty array to log whether different samples have been played -var hasBeenPlayed = []; // HERE? - - // Once this is loaded and parsed, begin execution loadInterface(projectXML); @@ -501,13 +497,10 @@ } audioEngineContext.play(); - hasBeenPlayed[index] = true; // mark as played }; canvas.appendChild(trackSliderObj); - // Add corresponding element to array to check whether sound has been played - hasBeenPlayed.push(false); }); // Append any commentQuestion boxes @@ -736,6 +729,8 @@ // Start the test var testId = currentState.substr(11,currentState.length-10); currentState = 'testRun-'+testId; + //audioEngineContext.timer.startTest(); + audioEngineContext.play(); } else if (currentState.substr(0,11) == 'testRunPost') { var testId = currentState.substr(12,currentState.length-11); @@ -786,29 +781,42 @@ function buttonSubmitClick() // TODO: Only when all songs have been played! { - if (hasBeenPlayed.indexOf(false)==-1) - { - if (audioEngineContext.status == 1) { - var playback = document.getElementById('playback-button'); - playback.click(); - // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options - } else - { - if (audioEngineContext.timer.testStarted == false) - { - alert('You have not started the test! Please press start to begin the test!'); - return; - } - } - if (currentState.substr(0,7) == 'testRun') - { - hasBeenPlayed = []; // clear array to prepare for next test - audioEngineContext.timer.stopTest(); - advanceState(); - } + hasBeenPlayed = audioEngineContext.checkAllPlayed(); + if (hasBeenPlayed.length == 0) { + if (audioEngineContext.status == 1) { + var playback = document.getElementById('playback-button'); + playback.click(); + // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options + } else + { + if (audioEngineContext.timer.testStarted == false) + { + alert('You have not started the test! Please press start to begin the test!'); + return; + } + } + if (currentState.substr(0,7) == 'testRun') + { + hasBeenPlayed = []; // clear array to prepare for next test + audioEngineContext.timer.stopTest(); + advanceState(); + } } else // if a fragment has not been played yet { - alert('You have not played fragment ' + hasBeenPlayed.indexOf(false) + ' yet. Please listen, rate and comment all samples before submitting.'); + str = ""; + if (hasBeenPlayed.length > 1) { + for (var i=0; i