Mercurial > hg > webaudioevaluationtool
changeset 54:9a552027412f Dev_main
Added in randomiseOrder function in core.js. Updated calls in ape.js to randomise order of tests and elements.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 17 Apr 2015 09:41:31 +0100 |
parents | 8baa6b5cb4be |
children | dbc626091063 |
files | ape.js core.js |
diffstat | 2 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ape.js Mon Apr 13 11:46:21 2015 +0100 +++ b/ape.js Fri Apr 17 09:41:31 2015 +0100 @@ -59,7 +59,7 @@ } if (randomise) { - // TODO: Implement Randomisation!! + testXMLSetups = randomiseOrder(testXMLSetups); } // Obtain the metrics enabled @@ -341,7 +341,7 @@ currentTrackOrder[index] = element; }); if (randomise) { - // TODO: Randomise order + currentTrackOrder = randomiseOrder(currentTrackOrder); } // Find all the audioElements from the audioHolder
--- a/core.js Mon Apr 13 11:46:21 2015 +0100 +++ b/core.js Fri Apr 17 09:41:31 2015 +0100 @@ -340,4 +340,22 @@ this.listenStart = 0; } }; +} + +function randomiseOrder(input) +{ + // This takes an array of information and randomises the order + var N = input.length; + var K = N; + var holdArr = []; + for (var n=0; n<N; n++) + { + // First pick a random number + var r = Math.random(); + // Multiply and floor by the number of elements left + r = Math.floor(r*input.length); + // Pick out that element and delete from the array + holdArr.push(input.splice(r,1)[0]); + } + return holdArr; } \ No newline at end of file