Mercurial > hg > webaudioevaluationtool
comparison test_create/test_create.html @ 774:67c6048d920f
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 | 30adbf6a6d50 |
children | 3123565e0c49 |
comparison
equal
deleted
inserted
replaced
773:d07bc42a716c | 774:67c6048d920f |
---|---|
1615 { | 1615 { |
1616 this.check = input.id; | 1616 this.check = input.id; |
1617 } | 1617 } |
1618 }; | 1618 }; |
1619 }; | 1619 }; |
1620 | |
1621 this.randomiseOrder = function(input) | |
1622 { | |
1623 // This takes an array of information and randomises the order | |
1624 var N = input.length; | |
1625 | |
1626 var inputSequence = []; // For safety purposes: keep track of randomisation | |
1627 for (var counter = 0; counter < N; ++counter) | |
1628 inputSequence.push(counter) // Fill array | |
1629 var inputSequenceClone = inputSequence.slice(0); | |
1630 | |
1631 var holdArr = []; | |
1632 var outputSequence = []; | |
1633 for (var n=0; n<N; n++) | |
1634 { | |
1635 // First pick a random number | |
1636 var r = Math.random(); | |
1637 // Multiply and floor by the number of elements left | |
1638 r = Math.floor(r*input.length); | |
1639 // Pick out that element and delete from the array | |
1640 holdArr.push(input.splice(r,1)[0]); | |
1641 // Do the same with sequence | |
1642 outputSequence.push(inputSequence.splice(r,1)[0]); | |
1643 } | |
1644 console.log(inputSequenceClone.toString()); // print original array to console | |
1645 console.log(outputSequence.toString()); // print randomised array to console | |
1646 return holdArr; | |
1647 }; | |
1620 this.projectReturn = null; | 1648 this.projectReturn = null; |
1621 this.randomiseOrder = null; | 1649 this.randomiseOrder = null; |
1622 this.collectMetrics = null; | 1650 this.collectMetrics = null; |
1623 this.testPages = null; | 1651 this.testPages = null; |
1624 this.audioHolders = []; | 1652 this.audioHolders = []; |
2027 } else { | 2055 } else { |
2028 this.audioElements.push(node); | 2056 this.audioElements.push(node); |
2029 } | 2057 } |
2030 } | 2058 } |
2031 | 2059 |
2060 if (this.randomiseOrder == true) | |
2061 { | |
2062 this.audioElements = randomiseOrder(this.audioElements); | |
2063 } | |
2064 | |
2032 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); | 2065 var commentQuestionsDOM = xml.getElementsByTagName('CommentQuestion'); |
2033 for (var i=0; i<commentQuestionsDOM.length; i++) { | 2066 for (var i=0; i<commentQuestionsDOM.length; i++) { |
2034 var node = new this.commentQuestionNode(); | 2067 var node = new this.commentQuestionNode(); |
2035 node.decode(commentQuestionsDOM[i]); | 2068 node.decode(commentQuestionsDOM[i]); |
2036 this.commentQuestions.push(node); | 2069 this.commentQuestions.push(node); |
2281 } | 2314 } |
2282 }; | 2315 }; |
2283 }; | 2316 }; |
2284 }; | 2317 }; |
2285 } | 2318 } |
2286 | 2319 |
2287 function createDeleteNodeButton(node) | 2320 function createDeleteNodeButton(node) |
2288 { | 2321 { |
2289 var button = document.createElement("button"); | 2322 var button = document.createElement("button"); |
2290 button.textContent = "Delete"; | 2323 button.textContent = "Delete"; |
2291 button.onclick = function(event) | 2324 button.onclick = function(event) |