annotate ape.js @ 45:4884ca36ffaa Dev_main

audioElement id's tracked from input to output for randomisation.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 10 Apr 2015 17:18:45 +0100
parents c57aba852764
children 98fd53b83df8
rev   line source
nicholas@2 1 /**
nicholas@2 2 * ape.js
nicholas@2 3 * Create the APE interface
nicholas@2 4 */
nicholas@2 5
n@32 6 /*
n@32 7 *
n@32 8 * WARNING!!!
n@32 9 *
n@32 10 * YOU ARE VIEWING THE DEV VERSION. THERE IS NO GUARANTEE THIS WILL BE FULLY FUNCTIONAL
n@32 11 *
n@32 12 * WARNING!!!
n@32 13 *
n@32 14 */
n@32 15
n@38 16 var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?)
n@38 17 // preTest - In preTest state
n@38 18 // testRun-ID - In test running, test Id number at the end 'testRun-2'
n@38 19 // testRunPost-ID - Post test of test ID
n@38 20 // testRunPre-ID - Pre-test of test ID
n@38 21 // postTest - End of test, final submission!
n@38 22
n@32 23
nicholas@2 24 // Once this is loaded and parsed, begin execution
nicholas@2 25 loadInterface(projectXML);
nicholas@2 26
nicholas@2 27 function loadInterface(xmlDoc) {
nicholas@2 28
n@16 29 // Get the dimensions of the screen available to the page
nicholas@2 30 var width = window.innerWidth;
nicholas@2 31 var height = window.innerHeight;
nicholas@2 32
nicholas@2 33 // The injection point into the HTML page
nicholas@2 34 var insertPoint = document.getElementById("topLevelBody");
n@22 35 var testContent = document.createElement('div');
n@22 36 testContent.id = 'testContent';
nicholas@2 37
nicholas@7 38
nicholas@2 39 // Decode parts of the xmlDoc that are needed
nicholas@2 40 // xmlDoc MUST already be parsed by jQuery!
nicholas@2 41 var xmlSetup = xmlDoc.find('setup');
nicholas@2 42 // Should put in an error function here incase of malprocessed or malformed XML
nicholas@2 43
n@34 44 // Extract the different test XML DOM trees
n@44 45 var audioHolders = xmlDoc.find('audioHolder');
n@44 46 audioHolders.each(function(index,element) {
n@44 47 var repeatN = element.attributes['repeatCount'].value;
n@44 48 for (var r=0; r<=repeatN; r++) {
n@44 49 testXMLSetups[testXMLSetups.length] = element;
n@44 50 }
n@44 51 });
n@44 52
n@44 53 // New check if we need to randomise the test order
n@45 54 var randomise = xmlSetup[0].attributes['randomiseOrder'];
n@45 55 if (randomise != undefined) {
n@44 56 randomise = Boolean(randomise.value);
n@44 57 } else {
n@44 58 randomise = false;
n@44 59 }
n@44 60 if (randomise)
n@44 61 {
n@44 62 // TODO: Implement Randomisation!!
n@44 63 }
n@44 64
n@34 65
nicholas@2 66 // Create the top div for the Title element
nicholas@2 67 var titleAttr = xmlSetup[0].attributes['title'];
nicholas@2 68 var title = document.createElement('div');
nicholas@2 69 title.className = "title";
nicholas@2 70 title.align = "center";
nicholas@2 71 var titleSpan = document.createElement('span');
nicholas@2 72
nicholas@2 73 // Set title to that defined in XML, else set to default
nicholas@2 74 if (titleAttr != undefined) {
n@25 75 titleSpan.innerHTML = titleAttr.value;
nicholas@2 76 } else {
n@25 77 titleSpan.innerHTML = 'APE Tool';
nicholas@2 78 }
nicholas@2 79 // Insert the titleSpan element into the title div element.
nicholas@2 80 title.appendChild(titleSpan);
nicholas@2 81
nicholas@7 82 // Store the return URL path in global projectReturn
nicholas@7 83 projectReturn = xmlSetup[0].attributes['projectReturn'].value;
nicholas@7 84
nicholas@7 85 // Create Interface buttons!
nicholas@7 86 var interfaceButtons = document.createElement('div');
nicholas@7 87 interfaceButtons.id = 'interface-buttons';
nicholas@7 88
nicholas@7 89 // MANUAL DOWNLOAD POINT
nicholas@7 90 // If project return is null, this MUST be specified as the location to create the download link
nicholas@7 91 var downloadPoint = document.createElement('div');
nicholas@7 92 downloadPoint.id = 'download-point';
nicholas@7 93
nicholas@7 94 // Create playback start/stop points
nicholas@7 95 var playback = document.createElement("button");
n@25 96 playback.innerHTML = 'Start';
n@16 97 // onclick function. Check if it is playing or not, call the correct function in the
n@16 98 // audioEngine, change the button text to reflect the next state.
nicholas@7 99 playback.onclick = function() {
nicholas@7 100 if (audioEngineContext.status == 0) {
nicholas@7 101 audioEngineContext.play();
n@25 102 this.innerHTML = 'Stop';
nicholas@7 103 } else {
nicholas@7 104 audioEngineContext.stop();
n@25 105 this.innerHTML = 'Start';
nicholas@7 106 }
n@16 107 };
nicholas@7 108 // Create Submit (save) button
nicholas@7 109 var submit = document.createElement("button");
n@25 110 submit.innerHTML = 'Submit';
n@43 111 submit.onclick = buttonSubmitClick;
n@16 112 // Append the interface buttons into the interfaceButtons object.
nicholas@7 113 interfaceButtons.appendChild(playback);
nicholas@7 114 interfaceButtons.appendChild(submit);
nicholas@7 115 interfaceButtons.appendChild(downloadPoint);
nicholas@7 116
nicholas@2 117 // Now create the slider and HTML5 canvas boxes
nicholas@2 118
n@16 119 // Create the div box to center align
nicholas@2 120 var sliderBox = document.createElement('div');
nicholas@2 121 sliderBox.className = 'sliderCanvasDiv';
n@16 122 sliderBox.id = 'sliderCanvasHolder';
nicholas@2 123 sliderBox.align = 'center';
nicholas@2 124
n@16 125 // Create the slider box to hold the slider elements
nicholas@5 126 var canvas = document.createElement('div');
nicholas@2 127 canvas.id = 'slider';
n@16 128 // Must have a known EXACT width, as this is used later to determine the ratings
nicholas@5 129 canvas.style.width = width - 100 +"px";
nicholas@5 130 canvas.align = "left";
nicholas@2 131 sliderBox.appendChild(canvas);
n@16 132
n@16 133 // Global parent for the comment boxes on the page
nicholas@3 134 var feedbackHolder = document.createElement('div');
n@34 135 feedbackHolder.id = 'feedbackHolder';
nicholas@2 136
n@38 137 testContent.style.zIndex = 1;
n@38 138 insertPoint.innerHTML = null; // Clear the current schema
n@38 139
n@22 140 // Create pre and post test questions
n@38 141 var blank = document.createElement('div');
n@38 142 blank.className = 'testHalt';
n@22 143
n@38 144 var popupHolder = document.createElement('div');
n@38 145 popupHolder.id = 'popupHolder';
n@38 146 popupHolder.className = 'popupHolder';
n@38 147 popupHolder.style.position = 'absolute';
n@38 148 popupHolder.style.left = (window.innerWidth/2)-250 + 'px';
n@38 149 popupHolder.style.top = (window.innerHeight/2)-125 + 'px';
n@38 150 insertPoint.appendChild(popupHolder);
n@38 151 insertPoint.appendChild(blank);
n@38 152 hidePopup();
n@22 153
n@36 154 var preTest = xmlSetup.find('PreTest');
n@36 155 var postTest = xmlSetup.find('PostTest');
n@22 156 preTest = preTest[0];
n@22 157 postTest = postTest[0];
n@38 158
n@38 159 currentState = 'preTest';
n@22 160
n@22 161 // Create Pre-Test Box
n@22 162 if (preTest != undefined && preTest.children.length >= 1)
n@22 163 {
n@38 164 showPopup();
n@39 165 preTestPopupStart(preTest);
n@22 166 }
n@38 167
n@38 168 // Inject into HTML
n@38 169 testContent.appendChild(title); // Insert the title
n@38 170 testContent.appendChild(interfaceButtons);
n@38 171 testContent.appendChild(sliderBox);
n@38 172 testContent.appendChild(feedbackHolder);
n@38 173 insertPoint.appendChild(testContent);
n@22 174
n@36 175 // Load the full interface
n@39 176
nicholas@2 177 }
nicholas@5 178
n@39 179 function loadTest(id)
n@34 180 {
n@34 181 // Used to load a specific test page
n@39 182 var textXML = testXMLSetups[id];
n@34 183
n@34 184 var feedbackHolder = document.getElementById('feedbackHolder');
n@34 185 var canvas = document.getElementById('slider');
n@34 186 feedbackHolder.innerHTML = null;
n@34 187 canvas.innerHTML = null;
n@34 188
n@34 189 // Extract the hostURL attribute. If not set, create an empty string.
n@34 190 var hostURL = textXML.attributes['hostURL'];
n@34 191 if (hostURL == undefined) {
n@34 192 hostURL = "";
n@34 193 } else {
n@34 194 hostURL = hostURL.value;
n@34 195 }
n@34 196 // Extract the sampleRate. If set, convert the string to a Number.
n@34 197 var hostFs = textXML.attributes['sampleRate'];
n@34 198 if (hostFs != undefined) {
n@34 199 hostFs = Number(hostFs.value);
n@34 200 }
n@34 201
n@34 202 /// CHECK FOR SAMPLE RATE COMPATIBILITY
n@34 203 if (hostFs != undefined) {
n@34 204 if (Number(hostFs) != audioContext.sampleRate) {
n@34 205 var errStr = 'Sample rates do not match! Requested '+Number(hostFs)+', got '+audioContext.sampleRate+'. Please set the sample rate to match before completing this test.';
n@34 206 alert(errStr);
n@34 207 return;
n@34 208 }
n@34 209 }
n@45 210
n@45 211 var randomise = textXML.attributes['randomiseOrder'];
n@45 212 if (randomise != undefined) {randomise = randomise.value;}
n@45 213 else {randomise = false;}
n@45 214
n@34 215 var audioElements = $(textXML).find('audioElements');
n@34 216 audioElements.each(function(index,element){
n@45 217 // Find any blind-repeats
n@45 218 // Not implemented yet, but just incase
n@45 219 currentTrackOrder[index] = element;
n@45 220 });
n@45 221 if (randomise) {
n@45 222 // TODO: Randomise order
n@45 223 }
n@45 224
n@45 225 // Find all the audioElements from the audioHolder
n@45 226 $(currentTrackOrder).each(function(index,element){
n@34 227 // Find URL of track
n@34 228 // In this jQuery loop, variable 'this' holds the current audioElement.
n@34 229
n@34 230 // Now load each audio sample. First create the new track by passing the full URL
n@34 231 var trackURL = hostURL + this.attributes['url'].value;
n@34 232 audioEngineContext.newTrack(trackURL);
n@34 233 // Create document objects to hold the comment boxes
n@34 234 var trackComment = document.createElement('div');
n@37 235 trackComment.className = 'comment-div';
n@34 236 // Create a string next to each comment asking for a comment
n@34 237 var trackString = document.createElement('span');
n@34 238 trackString.innerHTML = 'Comment on track '+index;
n@34 239 // Create the HTML5 comment box 'textarea'
n@34 240 var trackCommentBox = document.createElement('textarea');
n@34 241 trackCommentBox.rows = '4';
n@34 242 trackCommentBox.cols = '100';
n@34 243 trackCommentBox.name = 'trackComment'+index;
n@34 244 trackCommentBox.className = 'trackComment';
n@34 245 var br = document.createElement('br');
n@34 246 // Add to the holder.
n@34 247 trackComment.appendChild(trackString);
n@34 248 trackComment.appendChild(br);
n@34 249 trackComment.appendChild(trackCommentBox);
n@34 250 feedbackHolder.appendChild(trackComment);
n@34 251
n@34 252 // Create a slider per track
n@34 253
n@34 254 var trackSliderObj = document.createElement('div');
n@34 255 trackSliderObj.className = 'track-slider';
n@34 256 trackSliderObj.id = 'track-slider-'+index;
n@34 257 // Distribute it randomnly
n@34 258 var w = window.innerWidth - 100;
n@34 259 w = Math.random()*w;
n@34 260 trackSliderObj.style.left = Math.floor(w)+50+'px';
n@34 261 trackSliderObj.innerHTML = '<span>'+index+'</span>';
n@34 262 trackSliderObj.draggable = true;
n@34 263 trackSliderObj.ondragend = dragEnd;
n@34 264
n@34 265 // Onclick, switch playback to that track
n@34 266 trackSliderObj.onclick = function() {
n@34 267 // Get the track ID from the object ID
n@34 268 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
n@34 269 audioEngineContext.selectedTrack(id);
n@34 270 };
n@34 271
n@34 272 canvas.appendChild(trackSliderObj);
n@34 273 });
n@39 274
n@39 275 // Now process any pre-test commands
n@39 276
n@44 277 var preTest = $(testXMLSetups[id]).find('PreTest')[0];
n@39 278 if (preTest.children.length > 0)
n@39 279 {
n@39 280 currentState = 'testRunPre-'+id;
n@39 281 preTestPopupStart(preTest);
n@39 282 showPopup();
n@39 283 } else {
n@39 284 currentState = 'testRun-'+id;
n@39 285 }
n@39 286 }
n@39 287
n@39 288 function preTestPopupStart(preTest)
n@39 289 {
n@39 290 var popupHolder = document.getElementById('popupHolder');
n@39 291 popupHolder.innerHTML = null;
n@39 292 // Parse the first box
n@39 293 var preTestOption = document.createElement('div');
n@39 294 preTestOption.id = 'preTest';
n@39 295 preTestOption.style.marginTop = '25px';
n@39 296 preTestOption.align = "center";
n@39 297 var child = preTest.children[0];
n@39 298 if (child.nodeName == 'statement')
n@39 299 {
n@39 300 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
n@39 301 } else if (child.nodeName == 'question')
n@39 302 {
n@39 303 var questionId = child.attributes['id'].value;
n@39 304 var textHold = document.createElement('span');
n@39 305 textHold.innerHTML = child.innerHTML;
n@39 306 textHold.id = questionId + 'response';
n@39 307 var textEnter = document.createElement('textarea');
n@39 308 preTestOption.appendChild(textHold);
n@39 309 preTestOption.appendChild(textEnter);
n@39 310 }
n@39 311 var nextButton = document.createElement('button');
n@39 312 nextButton.className = 'popupButton';
n@39 313 nextButton.value = '0';
n@39 314 nextButton.innerHTML = 'Next';
n@39 315 nextButton.onclick = popupButtonClick;
n@39 316
n@39 317 popupHolder.appendChild(preTestOption);
n@39 318 popupHolder.appendChild(nextButton);
n@34 319 }
n@34 320
n@38 321 function popupButtonClick()
n@38 322 {
n@38 323 // Global call from the 'Next' button click
n@38 324 if (currentState == 'preTest')
n@38 325 {
n@38 326 // At the start of the preTest routine!
n@39 327 var xmlTree = projectXML.find('setup');
n@39 328 var preTest = xmlTree.find('PreTest')[0];
n@39 329 this.value = preTestButtonClick(preTest,this.value);
n@39 330 } else if (currentState.substr(0,10) == 'testRunPre')
n@39 331 {
n@39 332 //Specific test pre-test
n@39 333 var testId = currentState.substr(11,currentState.length-10);
n@44 334 var preTest = $(testXMLSetups[testId]).find('PreTest')[0];
n@39 335 this.value = preTestButtonClick(preTest,this.value);
n@42 336 } else if (currentState.substr(0,11) == 'testRunPost')
n@42 337 {
n@42 338 // Specific test post-test
n@42 339 var testId = currentState.substr(12,currentState.length-11);
n@44 340 var preTest = $(testXMLSetups[testId]).find('PostTest')[0];
n@42 341 this.value = preTestButtonClick(preTest,this.value);
n@41 342 } else if (currentState == 'postTest')
n@41 343 {
n@41 344 // At the end of the test, running global post test
n@41 345 var xmlTree = projectXML.find('setup');
n@41 346 var PostTest = xmlTree.find('PostTest')[0];
n@41 347 this.value = preTestButtonClick(PostTest,this.value);
n@38 348 }
n@38 349 }
n@38 350
n@39 351 function preTestButtonClick(preTest,index)
n@34 352 {
n@34 353 // Called on click of pre-test button
n@36 354 // Need to find and parse preTest again!
n@36 355 var preTestOption = document.getElementById('preTest');
n@36 356 // Check if current state is a question!
n@38 357 if (preTest.children[index].nodeName == 'question') {
n@38 358 var questionId = preTest.children[index].attributes['id'].value;
n@36 359 var questionHold = document.createElement('comment');
n@36 360 var questionResponse = document.getElementById(questionId + 'response');
n@36 361 questionHold.id = questionId;
n@36 362 questionHold.innerHTML = questionResponse.value;
n@43 363 if (currentState == 'preTest') {
n@43 364 preTestQuestions.appendChild(questionHold);
n@43 365 } else if (currentState = 'postTest') {
n@43 366 postTestQuestions.appendChild(questionHold);
n@43 367 }
n@36 368 }
n@38 369 index++;
n@38 370 if (index < preTest.children.length)
n@36 371 {
n@36 372 // More to process
n@38 373 var child = preTest.children[index];
n@36 374 if (child.nodeName == 'statement')
n@36 375 {
n@36 376 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
n@36 377 } else if (child.nodeName == 'question')
n@36 378 {
n@36 379 var textHold = document.createElement('span');
n@36 380 textHold.innerHTML = child.innerHTML;
n@36 381 var textEnter = document.createElement('textarea');
n@36 382 textEnter.id = child.attributes['id'].value + 'response';
n@36 383 var br = document.createElement('br');
n@36 384 preTestOption.innerHTML = null;
n@36 385 preTestOption.appendChild(textHold);
n@36 386 preTestOption.appendChild(br);
n@36 387 preTestOption.appendChild(textEnter);
n@36 388 }
n@36 389 } else {
n@36 390 // Time to clear
n@37 391 preTestOption.innerHTML = null;
n@43 392 if (currentState != 'postTest') {
n@43 393 hidePopup();
n@43 394 // Progress the state!
n@43 395 advanceState();
n@43 396 } else {
n@43 397 a = createProjectSave(projectReturn);
n@43 398 preTestOption.appendChild(a);
n@43 399 }
n@36 400 }
n@38 401 return index;
n@36 402 }
n@36 403
n@36 404 function showPopup()
n@36 405 {
n@37 406 var popupHolder = document.getElementById('popupHolder');
n@38 407 popupHolder.style.zIndex = 3;
n@37 408 popupHolder.style.visibility = 'visible';
n@37 409 var blank = document.getElementsByClassName('testHalt')[0];
n@37 410 blank.style.zIndex = 2;
n@37 411 blank.style.visibility = 'visible';
n@36 412 }
n@36 413
n@36 414 function hidePopup()
n@36 415 {
n@37 416 var popupHolder = document.getElementById('popupHolder');
n@37 417 popupHolder.style.zIndex = -1;
n@37 418 popupHolder.style.visibility = 'hidden';
n@37 419 var blank = document.getElementsByClassName('testHalt')[0];
n@37 420 blank.style.zIndex = -2;
n@37 421 blank.style.visibility = 'hidden';
n@34 422 }
n@34 423
nicholas@5 424 function dragEnd(ev) {
nicholas@5 425 // Function call when a div has been dropped
n@33 426 var slider = document.getElementById('slider');
nicholas@5 427 if (ev.x >= 50 && ev.x < window.innerWidth-50) {
nicholas@5 428 this.style.left = (ev.x)+'px';
nicholas@5 429 } else {
nicholas@5 430 if (ev.x<50) {
nicholas@5 431 this.style.left = '50px';
nicholas@5 432 } else {
nicholas@5 433 this.style.left = window.innerWidth-50 + 'px';
nicholas@5 434 }
nicholas@5 435 }
nicholas@5 436 }
nicholas@7 437
n@39 438 function advanceState()
n@39 439 {
n@39 440 console.log(currentState);
n@39 441 if (currentState == 'preTest')
n@39 442 {
n@39 443 // End of pre-test, begin the test
n@39 444 loadTest(0);
n@39 445 } else if (currentState.substr(0,10) == 'testRunPre')
n@39 446 {
n@39 447 // Start the test
n@39 448 var testId = currentState.substr(11,currentState.length-10);
n@39 449 currentState = 'testRun-'+testId;
n@42 450 } else if (currentState.substr(0,11) == 'testRunPost')
n@42 451 {
n@44 452 var testId = currentState.substr(12,currentState.length-11);
n@42 453 testEnded(testId);
n@40 454 } else if (currentState.substr(0,7) == 'testRun')
n@40 455 {
n@40 456 var testId = currentState.substr(8,currentState.length-7);
n@40 457 // Check if we have any post tests to perform
n@44 458 var postXML = $(testXMLSetups[testId]).find('PostTest')[0];
n@40 459 if (postXML.children.length > 0)
n@40 460 {
n@42 461 currentState = 'testRunPost-'+testId;
n@42 462 showPopup();
n@42 463 preTestPopupStart(postXML);
n@40 464 }
n@42 465 else {
n@40 466
n@40 467
n@42 468 // No post tests, check if we have another test to perform instead
n@42 469 testEnded(testId);
n@40 470 }
n@39 471 }
n@39 472 console.log(currentState);
n@39 473 }
n@39 474
n@42 475 function testEnded(testId)
n@42 476 {
n@45 477 pageXMLSave(testId);
n@42 478 if (testXMLSetups.length-1 > testId)
n@42 479 {
n@42 480 // Yes we have another test to perform
n@44 481 testId = (Number(testId)+1);
n@44 482 currentState = 'testRun-'+testId;
n@44 483 loadTest(testId);
n@42 484 } else {
n@42 485 console.log('Testing Completed!');
n@42 486 currentState = 'postTest';
n@42 487 // Check for any post tests
n@42 488 var xmlSetup = projectXML.find('setup');
n@42 489 var postTest = xmlSetup.find('PostTest')[0];
n@42 490 showPopup();
n@42 491 preTestPopupStart(postTest);
n@42 492 }
n@42 493 }
n@42 494
n@40 495 function buttonSubmitClick()
n@40 496 {
n@40 497 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
n@40 498 if (currentState.substr(0,7) == 'testRun')
n@40 499 {
n@40 500 advanceState();
n@40 501 }
n@40 502 }
n@40 503
n@44 504 function pageXMLSave(testId)
n@44 505 {
n@44 506 // Saves a specific test page
n@44 507 var xmlDoc = document.createElement("AudioHolder");
n@44 508 var testXML = testXMLSetups[testId];
n@44 509 xmlDoc.id = testXML.id;
n@44 510 xmlDoc.repeatCount = testXML.attributes['repeatCount'].value;
n@45 511 var trackSliderObjects = document.getElementsByClassName('track-slider');
n@45 512 var commentObjects = document.getElementsByClassName('comment-div');
n@45 513 var rateMin = 50;
n@45 514 var rateMax = window.innerWidth-50;
n@45 515 for (var i=0; i<trackSliderObjects.length; i++)
n@45 516 {
n@45 517 var audioElement = document.createElement('audioElement');
n@45 518 audioElement.id = currentTrackOrder[i].attributes['id'].value;
n@45 519 audioElement.url = currentTrackOrder[i].attributes['url'].value;
n@45 520 var value = document.createElement("value");
n@45 521 var rate = Number(trackSliderObjects[i].style.left.substr(0,trackSliderObjects[i].style.left.length-2));
n@45 522 rate = (rate-rateMin)/rateMax;
n@45 523 value.innerHTML = Math.floor(rate*100);
n@45 524 var comment = document.createElement("comment");
n@45 525 var question = document.createElement("question");
n@45 526 var response = document.createElement("response");
n@45 527 question.textContent = commentObjects[i].children[0].textContent;
n@45 528 response.textContent = commentObjects[i].children[2].value;
n@45 529 comment.appendChild(question);
n@45 530 comment.appendChild(response);
n@45 531 audioElement.appendChild(value);
n@45 532 audioElement.appendChild(comment);
n@45 533 xmlDoc.appendChild(audioElement);
n@45 534 }
n@45 535 testResultsHolders[testId] = xmlDoc;
n@44 536 }
n@44 537
nicholas@7 538 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
nicholas@7 539 function interfaceXMLSave(){
nicholas@7 540 // Create the XML string to be exported with results
nicholas@7 541 var xmlDoc = document.createElement("BrowserEvaluationResult");
n@45 542 for (var i=0; i<testResultsHolders.length; i++)
nicholas@7 543 {
n@45 544 xmlDoc.appendChild(testResultsHolders[i]);
nicholas@7 545 }
n@23 546 // Append Pre/Post Questions
n@23 547 xmlDoc.appendChild(preTestQuestions);
n@23 548 xmlDoc.appendChild(postTestQuestions);
n@23 549
nicholas@7 550 return xmlDoc;
nicholas@7 551 }
nicholas@7 552