Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 107:cf2563abbc65
Bug #1226: Moved check to audioObjects and audioEngine so available for all interfaces. Also interface pop-up now states all outstanding fragments to listen.
author | Nicholas Jillings <nicholas.jillings@eecs.qmul.ac.uk> |
---|---|
date | Sun, 24 May 2015 09:57:35 +0100 |
parents | f2c05f147dd2 |
children | a00af1797b08 |
comparison
equal
deleted
inserted
replaced
106:f2c05f147dd2 | 107:cf2563abbc65 |
---|---|
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? | |
16 | 12 |
17 | 13 |
18 // Once this is loaded and parsed, begin execution | 14 // Once this is loaded and parsed, begin execution |
19 loadInterface(projectXML); | 15 loadInterface(projectXML); |
20 | 16 |
499 document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; | 495 document.getElementById('track-slider-'+i).style.backgroundColor = "rgb(100,200,100)"; |
500 } | 496 } |
501 | 497 |
502 } | 498 } |
503 audioEngineContext.play(); | 499 audioEngineContext.play(); |
504 hasBeenPlayed[index] = true; // mark as played | |
505 }; | 500 }; |
506 | 501 |
507 canvas.appendChild(trackSliderObj); | 502 canvas.appendChild(trackSliderObj); |
508 | 503 |
509 // Add corresponding element to array to check whether sound has been played | |
510 hasBeenPlayed.push(false); | |
511 }); | 504 }); |
512 | 505 |
513 // Append any commentQuestion boxes | 506 // Append any commentQuestion boxes |
514 var commentQuestions = $(textXML).find('CommentQuestion'); | 507 var commentQuestions = $(textXML).find('CommentQuestion'); |
515 $(commentQuestions).each(function(index,element) { | 508 $(commentQuestions).each(function(index,element) { |
734 } else if (currentState.substr(0,10) == 'testRunPre') | 727 } else if (currentState.substr(0,10) == 'testRunPre') |
735 { | 728 { |
736 // Start the test | 729 // Start the test |
737 var testId = currentState.substr(11,currentState.length-10); | 730 var testId = currentState.substr(11,currentState.length-10); |
738 currentState = 'testRun-'+testId; | 731 currentState = 'testRun-'+testId; |
732 //audioEngineContext.timer.startTest(); | |
733 audioEngineContext.play(); | |
739 } else if (currentState.substr(0,11) == 'testRunPost') | 734 } else if (currentState.substr(0,11) == 'testRunPost') |
740 { | 735 { |
741 var testId = currentState.substr(12,currentState.length-11); | 736 var testId = currentState.substr(12,currentState.length-11); |
742 testEnded(testId); | 737 testEnded(testId); |
743 } else if (currentState.substr(0,7) == 'testRun') | 738 } else if (currentState.substr(0,7) == 'testRun') |
784 } | 779 } |
785 } | 780 } |
786 | 781 |
787 function buttonSubmitClick() // TODO: Only when all songs have been played! | 782 function buttonSubmitClick() // TODO: Only when all songs have been played! |
788 { | 783 { |
789 if (hasBeenPlayed.indexOf(false)==-1) | 784 hasBeenPlayed = audioEngineContext.checkAllPlayed(); |
790 { | 785 if (hasBeenPlayed.length == 0) { |
791 if (audioEngineContext.status == 1) { | 786 if (audioEngineContext.status == 1) { |
792 var playback = document.getElementById('playback-button'); | 787 var playback = document.getElementById('playback-button'); |
793 playback.click(); | 788 playback.click(); |
794 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options | 789 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options |
795 } else | 790 } else |
796 { | 791 { |
797 if (audioEngineContext.timer.testStarted == false) | 792 if (audioEngineContext.timer.testStarted == false) |
798 { | 793 { |
799 alert('You have not started the test! Please press start to begin the test!'); | 794 alert('You have not started the test! Please press start to begin the test!'); |
800 return; | 795 return; |
801 } | 796 } |
802 } | 797 } |
803 if (currentState.substr(0,7) == 'testRun') | 798 if (currentState.substr(0,7) == 'testRun') |
804 { | 799 { |
805 hasBeenPlayed = []; // clear array to prepare for next test | 800 hasBeenPlayed = []; // clear array to prepare for next test |
806 audioEngineContext.timer.stopTest(); | 801 audioEngineContext.timer.stopTest(); |
807 advanceState(); | 802 advanceState(); |
808 } | 803 } |
809 } else // if a fragment has not been played yet | 804 } else // if a fragment has not been played yet |
810 { | 805 { |
811 alert('You have not played fragment ' + hasBeenPlayed.indexOf(false) + ' yet. Please listen, rate and comment all samples before submitting.'); | 806 str = ""; |
807 if (hasBeenPlayed.length > 1) { | |
808 for (var i=0; i<hasBeenPlayed.length; i++) { | |
809 str = str + hasBeenPlayed[i]; | |
810 if (i < hasBeenPlayed.length-2){ | |
811 str += ", "; | |
812 } else if (i == hasBeenPlayed.length-2) { | |
813 str += " or "; | |
814 } | |
815 } | |
816 alert('You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.'); | |
817 } else { | |
818 alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.'); | |
819 } | |
812 return; | 820 return; |
813 } | 821 } |
814 } | 822 } |
815 | 823 |
816 function convSliderPosToRate(id) | 824 function convSliderPosToRate(id) |