Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 940:475aeb3075da
Don't allow to submit before all songs are played (slightly hacky patch)
author | Brecht De Man <BrechtDeMan@users.noreply.github.com> |
---|---|
date | Sun, 17 May 2015 09:00:09 +0100 |
parents | c2fe27b91359 |
children | 36d5c460f04b |
comparison
equal
deleted
inserted
replaced
939:c2fe27b91359 | 940:475aeb3075da |
---|---|
7 // preTest - In preTest state | 7 // preTest - In preTest state |
8 // testRun-ID - In test running, test Id number at the end 'testRun-2' | 8 // testRun-ID - In test running, test Id number at the end 'testRun-2' |
9 // testRunPost-ID - Post test of test ID | 9 // testRunPost-ID - Post test of test ID |
10 // testRunPre-ID - Pre-test of test ID | 10 // testRunPre-ID - Pre-test of test ID |
11 // postTest - End of test, final submission! | 11 // postTest - End of test, final submission! |
12 | |
13 | |
14 // Create empty array to log whether different samples have been played | |
15 var hasBeenPlayed = []; // HERE? | |
12 | 16 |
13 | 17 |
14 // Once this is loaded and parsed, begin execution | 18 // Once this is loaded and parsed, begin execution |
15 loadInterface(projectXML); | 19 loadInterface(projectXML); |
16 | 20 |
491 audioEngineContext.selectedTrack(id); | 495 audioEngineContext.selectedTrack(id); |
492 // Currently playing track red, rest green | 496 // Currently playing track red, rest green |
493 document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; | 497 document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000"; |
494 for (var i = 0; i<$(currentTrackOrder).length; i++) | 498 for (var i = 0; i<$(currentTrackOrder).length; i++) |
495 { | 499 { |
496 if (i!=index) | 500 if (i!=index) // Make all other sliders green |
497 { | 501 { |
498 document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; | 502 document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; |
499 } | 503 } |
500 | 504 |
501 } | 505 } |
502 audioEngineContext.play(); | 506 audioEngineContext.play(); |
507 hasBeenPlayed[index] = true; // mark as played | |
503 }; | 508 }; |
504 | 509 |
505 canvas.appendChild(trackSliderObj); | 510 canvas.appendChild(trackSliderObj); |
511 | |
512 // Add corresponding element to array to check whether sound has been played | |
513 hasBeenPlayed.push(false); | |
506 }); | 514 }); |
507 | 515 |
508 // Append any commentQuestion boxes | 516 // Append any commentQuestion boxes |
509 var commentQuestions = $(textXML).find('CommentQuestion'); | 517 var commentQuestions = $(textXML).find('CommentQuestion'); |
510 $(commentQuestions).each(function(index,element) { | 518 $(commentQuestions).each(function(index,element) { |
779 } | 787 } |
780 } | 788 } |
781 | 789 |
782 function buttonSubmitClick() // TODO: Only when all songs have been played! | 790 function buttonSubmitClick() // TODO: Only when all songs have been played! |
783 { | 791 { |
784 if (audioEngineContext.status == 1) { | 792 if (hasBeenPlayed.indexOf(false)==-1) |
785 var playback = document.getElementById('playback-button'); | 793 { |
786 playback.click(); | 794 if (audioEngineContext.status == 1) { |
787 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options | 795 var playback = document.getElementById('playback-button'); |
788 } else | 796 playback.click(); |
789 { | 797 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options |
790 if (audioEngineContext.timer.testStarted == false) | 798 } else |
791 { | 799 { |
792 alert('You have not started the test! Please press start to begin the test!'); | 800 if (audioEngineContext.timer.testStarted == false) |
793 return; | 801 { |
794 } | 802 alert('You have not started the test! Please press start to begin the test!'); |
795 } | 803 return; |
796 if (currentState.substr(0,7) == 'testRun') | 804 } |
797 { | 805 } |
798 audioEngineContext.timer.stopTest(); | 806 if (currentState.substr(0,7) == 'testRun') |
799 advanceState(); | 807 { |
800 } | 808 hasBeenPlayed = []; // clear array to prepare for next test |
809 audioEngineContext.timer.stopTest(); | |
810 advanceState(); | |
811 } | |
812 } else // if a fragment has not been played yet | |
813 { | |
814 alert('You have not played fragment ' + hasBeenPlayed.indexOf(false) + ' yet. Please listen, rate and comment all samples before submitting.'); | |
815 return; | |
816 } | |
801 } | 817 } |
802 | 818 |
803 function convSliderPosToRate(id) | 819 function convSliderPosToRate(id) |
804 { | 820 { |
805 var w = document.getElementById('slider').style.width; | 821 var w = document.getElementById('slider').style.width; |