Mercurial > hg > webaudioevaluationtool
comparison core.js @ 678:1e736dc124ab
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 | e604ee22185b |
children | ab56aa2fe064 |
comparison
equal
deleted
inserted
replaced
677:89e08a7e0b6b | 678:1e736dc124ab |
---|---|
339 this.listenedTimer += (time - this.listenStart); | 339 this.listenedTimer += (time - this.listenStart); |
340 this.listenStart = 0; | 340 this.listenStart = 0; |
341 } | 341 } |
342 }; | 342 }; |
343 } | 343 } |
344 | |
345 function randomiseOrder(input) | |
346 { | |
347 // This takes an array of information and randomises the order | |
348 var N = input.length; | |
349 var K = N; | |
350 var holdArr = []; | |
351 for (var n=0; n<N; n++) | |
352 { | |
353 // First pick a random number | |
354 var r = Math.random(); | |
355 // Multiply and floor by the number of elements left | |
356 r = Math.floor(r*input.length); | |
357 // Pick out that element and delete from the array | |
358 holdArr.push(input.splice(r,1)[0]); | |
359 } | |
360 return holdArr; | |
361 } |