annotate ape.js @ 46:98fd53b83df8 Dev_main

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 4884ca36ffaa
children 896111a0849b
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@46 211 currentTestHolder = document.createElement('audioHolder');
n@46 212 currentTestHolder.id = textXML.id;
n@46 213 currentTestHolder.repeatCount = textXML.attributes['repeatCount'].value;
n@46 214 var currentPreTestHolder = document.createElement('preTest');
n@46 215 var currentPostTestHolder = document.createElement('postTest');
n@46 216 currentTestHolder.appendChild(currentPreTestHolder);
n@46 217 currentTestHolder.appendChild(currentPostTestHolder);
n@46 218
n@45 219 var randomise = textXML.attributes['randomiseOrder'];
n@45 220 if (randomise != undefined) {randomise = randomise.value;}
n@45 221 else {randomise = false;}
n@45 222
n@34 223 var audioElements = $(textXML).find('audioElements');
n@34 224 audioElements.each(function(index,element){
n@45 225 // Find any blind-repeats
n@45 226 // Not implemented yet, but just incase
n@45 227 currentTrackOrder[index] = element;
n@45 228 });
n@45 229 if (randomise) {
n@45 230 // TODO: Randomise order
n@45 231 }
n@45 232
n@45 233 // Find all the audioElements from the audioHolder
n@45 234 $(currentTrackOrder).each(function(index,element){
n@34 235 // Find URL of track
n@34 236 // In this jQuery loop, variable 'this' holds the current audioElement.
n@34 237
n@34 238 // Now load each audio sample. First create the new track by passing the full URL
n@34 239 var trackURL = hostURL + this.attributes['url'].value;
n@34 240 audioEngineContext.newTrack(trackURL);
n@34 241 // Create document objects to hold the comment boxes
n@34 242 var trackComment = document.createElement('div');
n@37 243 trackComment.className = 'comment-div';
n@34 244 // Create a string next to each comment asking for a comment
n@34 245 var trackString = document.createElement('span');
n@34 246 trackString.innerHTML = 'Comment on track '+index;
n@34 247 // Create the HTML5 comment box 'textarea'
n@34 248 var trackCommentBox = document.createElement('textarea');
n@34 249 trackCommentBox.rows = '4';
n@34 250 trackCommentBox.cols = '100';
n@34 251 trackCommentBox.name = 'trackComment'+index;
n@34 252 trackCommentBox.className = 'trackComment';
n@34 253 var br = document.createElement('br');
n@34 254 // Add to the holder.
n@34 255 trackComment.appendChild(trackString);
n@34 256 trackComment.appendChild(br);
n@34 257 trackComment.appendChild(trackCommentBox);
n@34 258 feedbackHolder.appendChild(trackComment);
n@34 259
n@34 260 // Create a slider per track
n@34 261
n@34 262 var trackSliderObj = document.createElement('div');
n@34 263 trackSliderObj.className = 'track-slider';
n@34 264 trackSliderObj.id = 'track-slider-'+index;
n@34 265 // Distribute it randomnly
n@34 266 var w = window.innerWidth - 100;
n@34 267 w = Math.random()*w;
n@34 268 trackSliderObj.style.left = Math.floor(w)+50+'px';
n@34 269 trackSliderObj.innerHTML = '<span>'+index+'</span>';
n@34 270 trackSliderObj.draggable = true;
n@34 271 trackSliderObj.ondragend = dragEnd;
n@34 272
n@34 273 // Onclick, switch playback to that track
n@34 274 trackSliderObj.onclick = function() {
n@34 275 // Get the track ID from the object ID
n@34 276 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
n@34 277 audioEngineContext.selectedTrack(id);
n@34 278 };
n@34 279
n@34 280 canvas.appendChild(trackSliderObj);
n@34 281 });
n@39 282
n@39 283 // Now process any pre-test commands
n@39 284
n@44 285 var preTest = $(testXMLSetups[id]).find('PreTest')[0];
n@39 286 if (preTest.children.length > 0)
n@39 287 {
n@39 288 currentState = 'testRunPre-'+id;
n@39 289 preTestPopupStart(preTest);
n@39 290 showPopup();
n@39 291 } else {
n@39 292 currentState = 'testRun-'+id;
n@39 293 }
n@39 294 }
n@39 295
n@39 296 function preTestPopupStart(preTest)
n@39 297 {
n@39 298 var popupHolder = document.getElementById('popupHolder');
n@39 299 popupHolder.innerHTML = null;
n@39 300 // Parse the first box
n@39 301 var preTestOption = document.createElement('div');
n@39 302 preTestOption.id = 'preTest';
n@39 303 preTestOption.style.marginTop = '25px';
n@39 304 preTestOption.align = "center";
n@39 305 var child = preTest.children[0];
n@39 306 if (child.nodeName == 'statement')
n@39 307 {
n@39 308 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
n@39 309 } else if (child.nodeName == 'question')
n@39 310 {
n@39 311 var questionId = child.attributes['id'].value;
n@39 312 var textHold = document.createElement('span');
n@39 313 textHold.innerHTML = child.innerHTML;
n@39 314 textHold.id = questionId + 'response';
n@39 315 var textEnter = document.createElement('textarea');
n@39 316 preTestOption.appendChild(textHold);
n@39 317 preTestOption.appendChild(textEnter);
n@39 318 }
n@39 319 var nextButton = document.createElement('button');
n@39 320 nextButton.className = 'popupButton';
n@39 321 nextButton.value = '0';
n@39 322 nextButton.innerHTML = 'Next';
n@39 323 nextButton.onclick = popupButtonClick;
n@39 324
n@39 325 popupHolder.appendChild(preTestOption);
n@39 326 popupHolder.appendChild(nextButton);
n@34 327 }
n@34 328
n@38 329 function popupButtonClick()
n@38 330 {
n@38 331 // Global call from the 'Next' button click
n@38 332 if (currentState == 'preTest')
n@38 333 {
n@38 334 // At the start of the preTest routine!
n@39 335 var xmlTree = projectXML.find('setup');
n@39 336 var preTest = xmlTree.find('PreTest')[0];
n@39 337 this.value = preTestButtonClick(preTest,this.value);
n@39 338 } else if (currentState.substr(0,10) == 'testRunPre')
n@39 339 {
n@39 340 //Specific test pre-test
n@39 341 var testId = currentState.substr(11,currentState.length-10);
n@44 342 var preTest = $(testXMLSetups[testId]).find('PreTest')[0];
n@39 343 this.value = preTestButtonClick(preTest,this.value);
n@42 344 } else if (currentState.substr(0,11) == 'testRunPost')
n@42 345 {
n@42 346 // Specific test post-test
n@42 347 var testId = currentState.substr(12,currentState.length-11);
n@44 348 var preTest = $(testXMLSetups[testId]).find('PostTest')[0];
n@42 349 this.value = preTestButtonClick(preTest,this.value);
n@41 350 } else if (currentState == 'postTest')
n@41 351 {
n@41 352 // At the end of the test, running global post test
n@41 353 var xmlTree = projectXML.find('setup');
n@41 354 var PostTest = xmlTree.find('PostTest')[0];
n@41 355 this.value = preTestButtonClick(PostTest,this.value);
n@38 356 }
n@38 357 }
n@38 358
n@39 359 function preTestButtonClick(preTest,index)
n@34 360 {
n@34 361 // Called on click of pre-test button
n@36 362 // Need to find and parse preTest again!
n@36 363 var preTestOption = document.getElementById('preTest');
n@36 364 // Check if current state is a question!
n@38 365 if (preTest.children[index].nodeName == 'question') {
n@38 366 var questionId = preTest.children[index].attributes['id'].value;
n@36 367 var questionHold = document.createElement('comment');
n@36 368 var questionResponse = document.getElementById(questionId + 'response');
n@36 369 questionHold.id = questionId;
n@36 370 questionHold.innerHTML = questionResponse.value;
n@46 371 postPopupResponse(questionHold);
n@36 372 }
n@38 373 index++;
n@38 374 if (index < preTest.children.length)
n@36 375 {
n@36 376 // More to process
n@38 377 var child = preTest.children[index];
n@36 378 if (child.nodeName == 'statement')
n@36 379 {
n@36 380 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
n@36 381 } else if (child.nodeName == 'question')
n@36 382 {
n@36 383 var textHold = document.createElement('span');
n@36 384 textHold.innerHTML = child.innerHTML;
n@36 385 var textEnter = document.createElement('textarea');
n@36 386 textEnter.id = child.attributes['id'].value + 'response';
n@36 387 var br = document.createElement('br');
n@36 388 preTestOption.innerHTML = null;
n@36 389 preTestOption.appendChild(textHold);
n@36 390 preTestOption.appendChild(br);
n@36 391 preTestOption.appendChild(textEnter);
n@36 392 }
n@36 393 } else {
n@36 394 // Time to clear
n@37 395 preTestOption.innerHTML = null;
n@43 396 if (currentState != 'postTest') {
n@43 397 hidePopup();
n@43 398 // Progress the state!
n@43 399 advanceState();
n@43 400 } else {
n@43 401 a = createProjectSave(projectReturn);
n@43 402 preTestOption.appendChild(a);
n@43 403 }
n@36 404 }
n@38 405 return index;
n@36 406 }
n@36 407
n@46 408 function postPopupResponse(response)
n@46 409 {
n@46 410 if (currentState == 'preTest') {
n@46 411 preTestQuestions.appendChild(response);
n@46 412 } else if (currentState == 'postTest') {
n@46 413 postTestQuestions.appendChild(response);
n@46 414 } else {
n@46 415 // Inside a specific test
n@46 416 if (currentState.substr(0,10) == 'testRunPre') {
n@46 417 // Pre Test
n@46 418 var store = $(currentTestHolder).find('preTest');
n@46 419 } else {
n@46 420 // Post Test
n@46 421 var store = $(currentTestHolder).find('postTest');
n@46 422 }
n@46 423 store[0].appendChild(response);
n@46 424 }
n@46 425 }
n@46 426
n@36 427 function showPopup()
n@36 428 {
n@37 429 var popupHolder = document.getElementById('popupHolder');
n@38 430 popupHolder.style.zIndex = 3;
n@37 431 popupHolder.style.visibility = 'visible';
n@37 432 var blank = document.getElementsByClassName('testHalt')[0];
n@37 433 blank.style.zIndex = 2;
n@37 434 blank.style.visibility = 'visible';
n@36 435 }
n@36 436
n@36 437 function hidePopup()
n@36 438 {
n@37 439 var popupHolder = document.getElementById('popupHolder');
n@37 440 popupHolder.style.zIndex = -1;
n@37 441 popupHolder.style.visibility = 'hidden';
n@37 442 var blank = document.getElementsByClassName('testHalt')[0];
n@37 443 blank.style.zIndex = -2;
n@37 444 blank.style.visibility = 'hidden';
n@34 445 }
n@34 446
nicholas@5 447 function dragEnd(ev) {
nicholas@5 448 // Function call when a div has been dropped
n@33 449 var slider = document.getElementById('slider');
nicholas@5 450 if (ev.x >= 50 && ev.x < window.innerWidth-50) {
nicholas@5 451 this.style.left = (ev.x)+'px';
nicholas@5 452 } else {
nicholas@5 453 if (ev.x<50) {
nicholas@5 454 this.style.left = '50px';
nicholas@5 455 } else {
nicholas@5 456 this.style.left = window.innerWidth-50 + 'px';
nicholas@5 457 }
nicholas@5 458 }
nicholas@5 459 }
nicholas@7 460
n@39 461 function advanceState()
n@39 462 {
n@39 463 console.log(currentState);
n@39 464 if (currentState == 'preTest')
n@39 465 {
n@39 466 // End of pre-test, begin the test
n@39 467 loadTest(0);
n@39 468 } else if (currentState.substr(0,10) == 'testRunPre')
n@39 469 {
n@39 470 // Start the test
n@39 471 var testId = currentState.substr(11,currentState.length-10);
n@39 472 currentState = 'testRun-'+testId;
n@42 473 } else if (currentState.substr(0,11) == 'testRunPost')
n@42 474 {
n@44 475 var testId = currentState.substr(12,currentState.length-11);
n@42 476 testEnded(testId);
n@40 477 } else if (currentState.substr(0,7) == 'testRun')
n@40 478 {
n@40 479 var testId = currentState.substr(8,currentState.length-7);
n@40 480 // Check if we have any post tests to perform
n@44 481 var postXML = $(testXMLSetups[testId]).find('PostTest')[0];
n@40 482 if (postXML.children.length > 0)
n@40 483 {
n@42 484 currentState = 'testRunPost-'+testId;
n@42 485 showPopup();
n@42 486 preTestPopupStart(postXML);
n@40 487 }
n@42 488 else {
n@40 489
n@40 490
n@42 491 // No post tests, check if we have another test to perform instead
n@42 492 testEnded(testId);
n@40 493 }
n@39 494 }
n@39 495 console.log(currentState);
n@39 496 }
n@39 497
n@42 498 function testEnded(testId)
n@42 499 {
n@45 500 pageXMLSave(testId);
n@42 501 if (testXMLSetups.length-1 > testId)
n@42 502 {
n@42 503 // Yes we have another test to perform
n@44 504 testId = (Number(testId)+1);
n@44 505 currentState = 'testRun-'+testId;
n@44 506 loadTest(testId);
n@42 507 } else {
n@42 508 console.log('Testing Completed!');
n@42 509 currentState = 'postTest';
n@42 510 // Check for any post tests
n@42 511 var xmlSetup = projectXML.find('setup');
n@42 512 var postTest = xmlSetup.find('PostTest')[0];
n@42 513 showPopup();
n@42 514 preTestPopupStart(postTest);
n@42 515 }
n@42 516 }
n@42 517
n@40 518 function buttonSubmitClick()
n@40 519 {
n@40 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@40 521 if (currentState.substr(0,7) == 'testRun')
n@40 522 {
n@40 523 advanceState();
n@40 524 }
n@40 525 }
n@40 526
n@44 527 function pageXMLSave(testId)
n@44 528 {
n@44 529 // Saves a specific test page
n@46 530 var xmlDoc = currentTestHolder;
n@45 531 var trackSliderObjects = document.getElementsByClassName('track-slider');
n@45 532 var commentObjects = document.getElementsByClassName('comment-div');
n@45 533 var rateMin = 50;
n@45 534 var rateMax = window.innerWidth-50;
n@45 535 for (var i=0; i<trackSliderObjects.length; i++)
n@45 536 {
n@45 537 var audioElement = document.createElement('audioElement');
n@45 538 audioElement.id = currentTrackOrder[i].attributes['id'].value;
n@45 539 audioElement.url = currentTrackOrder[i].attributes['url'].value;
n@45 540 var value = document.createElement("value");
n@45 541 var rate = Number(trackSliderObjects[i].style.left.substr(0,trackSliderObjects[i].style.left.length-2));
n@45 542 rate = (rate-rateMin)/rateMax;
n@45 543 value.innerHTML = Math.floor(rate*100);
n@45 544 var comment = document.createElement("comment");
n@45 545 var question = document.createElement("question");
n@45 546 var response = document.createElement("response");
n@45 547 question.textContent = commentObjects[i].children[0].textContent;
n@45 548 response.textContent = commentObjects[i].children[2].value;
n@45 549 comment.appendChild(question);
n@45 550 comment.appendChild(response);
n@45 551 audioElement.appendChild(value);
n@45 552 audioElement.appendChild(comment);
n@45 553 xmlDoc.appendChild(audioElement);
n@45 554 }
n@45 555 testResultsHolders[testId] = xmlDoc;
n@44 556 }
n@44 557
nicholas@7 558 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
nicholas@7 559 function interfaceXMLSave(){
nicholas@7 560 // Create the XML string to be exported with results
nicholas@7 561 var xmlDoc = document.createElement("BrowserEvaluationResult");
n@45 562 for (var i=0; i<testResultsHolders.length; i++)
nicholas@7 563 {
n@45 564 xmlDoc.appendChild(testResultsHolders[i]);
nicholas@7 565 }
n@23 566 // Append Pre/Post Questions
n@23 567 xmlDoc.appendChild(preTestQuestions);
n@23 568 xmlDoc.appendChild(postTestQuestions);
n@23 569
nicholas@7 570 return xmlDoc;
nicholas@7 571 }
nicholas@7 572