# HG changeset patch # User Nicholas Jillings # Date 1457624019 0 # Node ID 6531e3903ea17d8d98d5a54d946c4b864717e963 # Parent 0df685136c898742d697a109cb152b1d25e866f2 Intermediate saves can be used to resume a test. Note, previous saves will NOT work for resumption. To resume, use the save XML as the ?url= option. diff -r 0df685136c89 -r 6531e3903ea1 core.js --- a/core.js Thu Mar 10 11:49:08 2016 +0000 +++ b/core.js Thu Mar 10 15:33:39 2016 +0000 @@ -220,12 +220,51 @@ } else if (responseDocument.children[0].nodeName == "waetresult") { // document is a result - projectXML = responseDocument.getElementsByTagName('waet')[0]; + projectXML = document.implementation.createDocument(null,"waet"); + projectXML.children[0].appendChild(responseDocument.getElementsByTagName('waet')[0].getElementsByTagName("setup")[0].cloneNode(true)); + var child = responseDocument.children[0].children[0]; + while (child != null) { + if (child.nodeName == "survey") { + // One of the global survey elements + if (child.getAttribute("state") == "complete") { + // We need to remove this survey from + var location = child.getAttribute("location"); + var globalSurveys = projectXML.getElementsByTagName("setup")[0].getElementsByTagName("survey")[0]; + while(globalSurveys != null) { + if (location == "pre" || location == "before") { + if (globalSurveys.getAttribute("location") == "pre" || globalSurveys.getAttribute("location") == "before") { + projectXML.getElementsByTagName("setup")[0].removeChild(globalSurveys); + break; + } + } else { + if (globalSurveys.getAttribute("location") == "post" || globalSurveys.getAttribute("location") == "after") { + projectXML.getElementsByTagName("setup")[0].removeChild(globalSurveys); + break; + } + } + globalSurveys = globalSurveys.nextElementSibling; + } + } else { + // We need to complete this, so it must be regenerated by store + var copy = child; + child = child.previousElementSibling; + responseDocument.children[0].removeChild(copy); + } + } else if (child.nodeName == "page") { + if (child.getAttribute("state") == "empty") { + // We need to complete this page + projectXML.children[0].appendChild(responseDocument.getElementById(child.getAttribute("ref")).cloneNode(true)); + var copy = child; + child = child.previousElementSibling; + responseDocument.children[0].removeChild(copy); + } + } + child = child.nextElementSibling; + } // Build the specification specification.decode(projectXML); - // Use the session-key - var sessionKey = responseDocument.children[0].getAttribute(key); - storage.initialise(sessionKey); + // Use the original + storage.initialise(responseDocument); } /// CHECK FOR SAMPLE RATE COMPATIBILITY if (specification.sampleRate != undefined) { @@ -717,6 +756,7 @@ { this.store.postResult(node); } + this.store.complete(); advanceState(); } }; @@ -923,6 +963,7 @@ element.exportXMLDOM(storePoint); } pageXMLSave(storePoint.XMLDOM, this.currentStateMap); + storePoint.complete(); }; } @@ -1176,7 +1217,7 @@ var aeNodes = this.pageStore.XMLDOM.getElementsByTagName('audioelement'); for (var i=0; i