# HG changeset patch # User Brecht De Man # Date 1431849609 -3600 # Node ID 63217e7bd1a703fc894c91510c2a4e66510324aa # Parent 590e487fe3f1c6d1012c58ed2f4d6a6607c0d6c4 Don't allow to submit before all songs are played (slightly hacky patch) diff -r 590e487fe3f1 -r 63217e7bd1a7 ape.js --- a/ape.js Sat May 16 20:58:15 2015 +0100 +++ b/ape.js Sun May 17 09:00:09 2015 +0100 @@ -11,6 +11,10 @@ // 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); @@ -493,16 +497,20 @@ document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; for (var i = 0; i<$(currentTrackOrder).length; i++) { - if (i!=index) + if (i!=index) // Make all other sliders green { document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; } } 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 @@ -781,23 +789,31 @@ function buttonSubmitClick() // TODO: Only when all songs have been played! { - 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') - { - audioEngineContext.timer.stopTest(); - advanceState(); - } + 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(); + } + } 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.'); + return; + } } function convSliderPosToRate(id)