Mercurial > hg > webaudioevaluationtool
comparison core.js @ 380:42cf69a134aa Dev_main
Specification: sync across project. Now randomises audioElements.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Mon, 07 Dec 2015 18:34:26 +0000 |
parents | f49339868324 |
children | b1cb28c63a19 |
comparison
equal
deleted
inserted
replaced
379:f49339868324 | 380:42cf69a134aa |
---|---|
1395 } else if (this.type == "check") | 1395 } else if (this.type == "check") |
1396 { | 1396 { |
1397 this.check = input.id; | 1397 this.check = input.id; |
1398 } | 1398 } |
1399 }; | 1399 }; |
1400 }; | |
1401 | |
1402 this.randomiseOrder = function(input) | |
1403 { | |
1404 // This takes an array of information and randomises the order | |
1405 var N = input.length; | |
1406 | |
1407 var inputSequence = []; // For safety purposes: keep track of randomisation | |
1408 for (var counter = 0; counter < N; ++counter) | |
1409 inputSequence.push(counter) // Fill array | |
1410 var inputSequenceClone = inputSequence.slice(0); | |
1411 | |
1412 var holdArr = []; | |
1413 var outputSequence = []; | |
1414 for (var n=0; n<N; n++) | |
1415 { | |
1416 // First pick a random number | |
1417 var r = Math.random(); | |
1418 // Multiply and floor by the number of elements left | |
1419 r = Math.floor(r*input.length); | |
1420 // Pick out that element and delete from the array | |
1421 holdArr.push(input.splice(r,1)[0]); | |
1422 // Do the same with sequence | |
1423 outputSequence.push(inputSequence.splice(r,1)[0]); | |
1424 } | |
1425 console.log(inputSequenceClone.toString()); // print original array to console | |
1426 console.log(outputSequence.toString()); // print randomised array to console | |
1427 return holdArr; | |
1400 }; | 1428 }; |
1401 this.projectReturn = null; | 1429 this.projectReturn = null; |
1402 this.randomiseOrder = null; | 1430 this.randomiseOrder = null; |
1403 this.collectMetrics = null; | 1431 this.collectMetrics = null; |
1404 this.testPages = null; | 1432 this.testPages = null; |
1808 } else { | 1836 } else { |
1809 this.audioElements.push(node); | 1837 this.audioElements.push(node); |
1810 } | 1838 } |
1811 } | 1839 } |
1812 | 1840 |
1841 if (this.randomiseOrder == true) | |
1842 { | |
1843 this.audioElements = randomiseOrder(this.audioElements); | |
1844 } | |
1845 | |
1813 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); | 1846 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); |
1814 for (var i=0; i<commentQuestionsDOM.length; i++) { | 1847 for (var i=0; i<commentQuestionsDOM.length; i++) { |
1815 var node = new this.commentQuestionNode(); | 1848 var node = new this.commentQuestionNode(); |
1816 node.decode(commentQuestionsDOM[i]); | 1849 node.decode(commentQuestionsDOM[i]); |
1817 this.commentQuestions.push(node); | 1850 this.commentQuestions.push(node); |