# HG changeset patch # User Nicholas Jillings # Date 1460633213 -3600 # Node ID 6dbee0a437927e6496c38c17ed8f94ae7b4890fe # Parent de1feb0d13dfc84750d436c8cd5e776f3130438a# Parent 7f44ba6533b47065cab9feaaaccdf05b595dfdf6 Merge branch 'Dev_main'. Preparing for tidy up of file structure. diff -r de1feb0d13df -r 6dbee0a43792 core.js --- a/core.js Wed Apr 13 15:46:40 2016 +0100 +++ b/core.js Thu Apr 14 12:26:53 2016 +0100 @@ -492,10 +492,59 @@ return Math.pow(10,gain/20.0); } +function secondsToSamples(time,fs) { + return Math.round(time*fs); +} + +function samplesToSeconds(samples,fs) { + return samples / fs; +} + function randomString(length) { return Math.round((Math.pow(36, length + 1) - Math.random() * Math.pow(36, length))).toString(36).slice(1); } +function randomiseOrder(input) +{ + // This takes an array of information and randomises the order + var N = input.length; + + var inputSequence = []; // For safety purposes: keep track of randomisation + for (var counter = 0; counter < N; ++counter) + inputSequence.push(counter) // Fill array + var inputSequenceClone = inputSequence.slice(0); + + var holdArr = []; + var outputSequence = []; + for (var n=0; n array.length) { + num = array.length; + } + var ret = []; + while (num > 0) { + var index = Math.floor(Math.random() * array.length); + ret.push( array.splice(index,1)[0] ); + num--; + } + return ret; +} + function interfacePopup() { // Creates an object to manage the popup this.popup = null; @@ -556,12 +605,14 @@ }; this.hidePopup = function(){ - this.popup.style.zIndex = -1; - this.popup.style.visibility = 'hidden'; - var blank = document.getElementsByClassName('testHalt')[0]; - blank.style.zIndex = -2; - blank.style.visibility = 'hidden'; - this.buttonPrevious.style.visibility = 'inherit'; + if (this.popup) { + this.popup.style.zIndex = -1; + this.popup.style.visibility = 'hidden'; + var blank = document.getElementsByClassName('testHalt')[0]; + blank.style.zIndex = -2; + blank.style.visibility = 'hidden'; + this.buttonPrevious.style.visibility = 'inherit'; + } }; this.postNode = function() { @@ -850,43 +901,68 @@ this.currentStatePosition = null; this.currentStore = null; this.initialise = function(){ - + // Get the data from Specification - var pageHolder = []; + var pagePool = []; + var pageInclude = []; for (var page of specification.pages) { - var repeat = page.repeatCount; - while(repeat >= 0) - { - pageHolder.push(page); - repeat--; + if (page.alwaysInclude) { + pageInclude.push(page); + } else { + pagePool.push(page); } } + + // Find how many are left to get + var numPages = specification.poolSize; + if (numPages > pagePool.length) { + console.log("WARNING - You have specified more pages in than you have created!!"); + numPages = specification.pages.length; + } + if (specification.poolSize == 0) { + numPages = specification.pages.length; + } + numPages -= pageInclude.length; + + if (numPages > 0) { + // Go find the rest of the pages from the pool + var subarr = null; + if (specification.randomiseOrder) { + // Append a random sub-array + subarr = randomSubArray(pagePool,numPages); + } else { + // Append the matching number + subarr = pagePool.slice(0,numPages); + } + pageInclude = pageInclude.concat(subarr); + } + + // We now have our selected pages in pageInclude array if (specification.randomiseOrder) { - pageHolder = randomiseOrder(pageHolder); + pageInclude = randomiseOrder(pageInclude); } - for (var i=0; i - + Please enter your name. diff -r de1feb0d13df -r 6dbee0a43792 example_eval/AB_example.xml --- a/example_eval/AB_example.xml Wed Apr 13 15:46:40 2016 +0100 +++ b/example_eval/AB_example.xml Thu Apr 14 12:26:53 2016 +0100 @@ -1,6 +1,6 @@ - + Please enter your name. diff -r de1feb0d13df -r 6dbee0a43792 example_eval/mushra_example.xml --- a/example_eval/mushra_example.xml Wed Apr 13 15:46:40 2016 +0100 +++ b/example_eval/mushra_example.xml Thu Apr 14 12:26:53 2016 +0100 @@ -1,6 +1,6 @@ - + Thank you for looking at WAET. You can modify the successful completion text as well! diff -r de1feb0d13df -r 6dbee0a43792 example_eval/project.xml --- a/example_eval/project.xml Wed Apr 13 15:46:40 2016 +0100 +++ b/example_eval/project.xml Thu Apr 14 12:26:53 2016 +0100 @@ -1,6 +1,6 @@ - + Please enter your name. diff -r de1feb0d13df -r 6dbee0a43792 example_eval/radio_example.xml --- a/example_eval/radio_example.xml Wed Apr 13 15:46:40 2016 +0100 +++ b/example_eval/radio_example.xml Thu Apr 14 12:26:53 2016 +0100 @@ -1,6 +1,6 @@ - + testTimer elementTimer @@ -18,7 +18,7 @@ - + (1) Very Annoying @@ -28,8 +28,9 @@ (5) Inaudible - + + diff -r de1feb0d13df -r 6dbee0a43792 specification.js --- a/specification.js Wed Apr 13 15:46:40 2016 +0100 +++ b/specification.js Thu Apr 14 12:26:53 2016 +0100 @@ -27,7 +27,19 @@ } var dataType = schema.getAttribute('type'); if (typeof dataType == "string") { dataType = dataType.substr(3);} - else {dataType = "string";} + else { + var rest = schema.getAllElementsByTagName("xs:restriction").concat(schema.getAllElementsByTagName("xs:enumeration")); + if (rest.length > 0) { + dataType = rest[0].getAttribute("base"); + if (typeof dataType == "string") { + dataType = dataType.substr(3); + } else { + dataType = "string"; + } + } else { + dataType = "string"; + } + } if (attribute == null) { return attribute; diff -r de1feb0d13df -r 6dbee0a43792 test-schema.xsd --- a/test-schema.xsd Wed Apr 13 15:46:40 2016 +0100 +++ b/test-schema.xsd Thu Apr 14 12:26:53 2016 +0100 @@ -1,263 +1,275 @@ - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +