annotate ape.js @ 670:77c974fd7e60

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