annotate ape.js @ 182:105b6bd810e9 Dev_main

Comment Boxes handled by Interface object.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 04 Jun 2015 16:48:04 +0100
parents eb164638be5e
children aaeebbacc159
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@38 6 // preTest - In preTest state
n@38 7 // testRun-ID - In test running, test Id number at the end 'testRun-2'
n@38 8 // testRunPost-ID - Post test of test ID
n@38 9 // testRunPre-ID - Pre-test of test ID
n@38 10 // postTest - End of test, final submission!
n@38 11
n@32 12
nicholas@2 13 // Once this is loaded and parsed, begin execution
n@181 14 loadInterface();
nicholas@2 15
n@181 16 function loadInterface() {
nicholas@2 17
n@16 18 // Get the dimensions of the screen available to the page
nicholas@2 19 var width = window.innerWidth;
nicholas@2 20 var height = window.innerHeight;
nicholas@2 21
nicholas@2 22 // The injection point into the HTML page
n@182 23 interfaceContext.insertPoint = document.getElementById("topLevelBody");
n@22 24 var testContent = document.createElement('div');
nicholas@135 25
n@22 26 testContent.id = 'testContent';
n@176 27
n@34 28
n@52 29 // Create APE specific metric functions
n@52 30 audioEngineContext.metric.initialiseTest = function()
n@52 31 {
n@52 32 };
n@52 33
n@52 34 audioEngineContext.metric.sliderMoveStart = function(id)
n@52 35 {
n@52 36 if (this.data == -1)
n@52 37 {
n@52 38 this.data = id;
n@52 39 } else {
n@52 40 console.log('ERROR: Metric tracker detecting two moves!');
n@52 41 this.data = -1;
n@52 42 }
n@52 43 };
n@52 44 audioEngineContext.metric.sliderMoved = function()
n@52 45 {
n@52 46 var time = audioEngineContext.timer.getTestTime();
n@52 47 var id = this.data;
n@52 48 this.data = -1;
n@52 49 var position = convSliderPosToRate(id);
b@115 50 console.log('slider ' + id + ': '+ position + ' (' + time + ')'); // DEBUG/SAFETY: show position and slider id
n@52 51 if (audioEngineContext.timer.testStarted)
n@52 52 {
n@52 53 audioEngineContext.audioObjects[id].metric.moved(time,position);
n@52 54 }
n@52 55 };
n@52 56
n@52 57 audioEngineContext.metric.sliderPlayed = function(id)
n@52 58 {
n@52 59 var time = audioEngineContext.timer.getTestTime();
n@52 60 if (audioEngineContext.timer.testStarted)
n@52 61 {
n@52 62 if (this.lastClicked >= 0)
n@52 63 {
n@52 64 audioEngineContext.audioObjects[this.lastClicked].metric.listening(time);
n@52 65 }
n@52 66 this.lastClicked = id;
n@52 67 audioEngineContext.audioObjects[id].metric.listening(time);
n@52 68 }
b@115 69 console.log('slider ' + id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id
n@52 70 };
n@52 71
n@177 72 // Bindings for audioObjects
n@177 73
nicholas@2 74 // Create the top div for the Title element
n@181 75 var titleAttr = specification.title;
nicholas@2 76 var title = document.createElement('div');
nicholas@2 77 title.className = "title";
nicholas@2 78 title.align = "center";
nicholas@2 79 var titleSpan = document.createElement('span');
nicholas@2 80
nicholas@2 81 // Set title to that defined in XML, else set to default
nicholas@2 82 if (titleAttr != undefined) {
n@181 83 titleSpan.textContent = titleAttr;
nicholas@2 84 } else {
n@181 85 titleSpan.textContent = 'Listening test';
nicholas@2 86 }
nicholas@2 87 // Insert the titleSpan element into the title div element.
nicholas@2 88 title.appendChild(titleSpan);
nicholas@2 89
n@47 90 var pagetitle = document.createElement('div');
n@47 91 pagetitle.className = "pageTitle";
n@47 92 pagetitle.align = "center";
n@47 93 var titleSpan = document.createElement('span');
n@47 94 titleSpan.id = "pageTitle";
n@47 95 pagetitle.appendChild(titleSpan);
n@47 96
nicholas@7 97 // Create Interface buttons!
nicholas@7 98 var interfaceButtons = document.createElement('div');
nicholas@7 99 interfaceButtons.id = 'interface-buttons';
nicholas@7 100
nicholas@7 101 // Create playback start/stop points
nicholas@7 102 var playback = document.createElement("button");
b@101 103 playback.innerHTML = 'Stop';
n@49 104 playback.id = 'playback-button';
n@16 105 // onclick function. Check if it is playing or not, call the correct function in the
n@16 106 // audioEngine, change the button text to reflect the next state.
nicholas@7 107 playback.onclick = function() {
b@101 108 if (audioEngineContext.status == 1) {
b@101 109 audioEngineContext.stop();
n@25 110 this.innerHTML = 'Stop';
b@115 111 var time = audioEngineContext.timer.getTestTime();
b@115 112 console.log('Stopped at ' + time); // DEBUG/SAFETY
nicholas@7 113 }
n@16 114 };
nicholas@7 115 // Create Submit (save) button
nicholas@7 116 var submit = document.createElement("button");
n@25 117 submit.innerHTML = 'Submit';
n@43 118 submit.onclick = buttonSubmitClick;
n@49 119 submit.id = 'submit-button';
n@16 120 // Append the interface buttons into the interfaceButtons object.
nicholas@7 121 interfaceButtons.appendChild(playback);
nicholas@7 122 interfaceButtons.appendChild(submit);
nicholas@7 123
nicholas@2 124 // Now create the slider and HTML5 canvas boxes
nicholas@2 125
n@16 126 // Create the div box to center align
nicholas@2 127 var sliderBox = document.createElement('div');
nicholas@2 128 sliderBox.className = 'sliderCanvasDiv';
n@16 129 sliderBox.id = 'sliderCanvasHolder';
nicholas@2 130
n@16 131 // Create the slider box to hold the slider elements
nicholas@5 132 var canvas = document.createElement('div');
nicholas@2 133 canvas.id = 'slider';
n@127 134 canvas.align = "left";
n@127 135 canvas.addEventListener('dragover',function(event){
n@127 136 event.preventDefault();
n@127 137 return false;
n@127 138 },false);
n@127 139 var sliderMargin = document.createAttribute('marginsize');
n@127 140 sliderMargin.nodeValue = 42; // Set default margins to 42px either side
n@16 141 // Must have a known EXACT width, as this is used later to determine the ratings
n@127 142 var w = (Number(sliderMargin.nodeValue)+8)*2;
n@127 143 canvas.style.width = width - w +"px";
n@127 144 canvas.style.marginLeft = sliderMargin.nodeValue +'px';
n@127 145 canvas.setAttributeNode(sliderMargin);
nicholas@2 146 sliderBox.appendChild(canvas);
n@16 147
n@47 148 // Create the div to hold any scale objects
n@47 149 var scale = document.createElement('div');
n@47 150 scale.className = 'sliderScale';
n@47 151 scale.id = 'sliderScaleHolder';
n@47 152 scale.align = 'left';
n@47 153 sliderBox.appendChild(scale);
n@47 154
n@16 155 // Global parent for the comment boxes on the page
nicholas@3 156 var feedbackHolder = document.createElement('div');
n@34 157 feedbackHolder.id = 'feedbackHolder';
nicholas@2 158
n@38 159 testContent.style.zIndex = 1;
n@182 160 interfaceContext.insertPoint.innerHTML = null; // Clear the current schema
n@38 161
n@38 162 // Inject into HTML
n@38 163 testContent.appendChild(title); // Insert the title
n@47 164 testContent.appendChild(pagetitle);
n@38 165 testContent.appendChild(interfaceButtons);
n@38 166 testContent.appendChild(sliderBox);
n@38 167 testContent.appendChild(feedbackHolder);
n@182 168 interfaceContext.insertPoint.appendChild(testContent);
n@22 169
n@36 170 // Load the full interface
nicholas@129 171 testState.initialise();
nicholas@129 172 testState.advanceState();
nicholas@135 173
nicholas@2 174 }
nicholas@5 175
n@181 176 function loadTest(audioHolderObject)
n@34 177 {
nicholas@110 178
nicholas@110 179 // Reset audioEngineContext.Metric globals for new test
n@113 180 audioEngineContext.newTestPage();
nicholas@110 181
n@181 182 var id = audioHolderObject.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@47 188
n@47 189 // Setup question title
n@181 190 var interfaceObj = $(audioHolderObject).find('interface');
n@47 191 var titleNode = interfaceObj.find('title');
n@47 192 if (titleNode[0] != undefined)
n@47 193 {
n@47 194 document.getElementById('pageTitle').textContent = titleNode[0].textContent;
n@47 195 }
n@47 196 var positionScale = canvas.style.width.substr(0,canvas.style.width.length-2);
n@127 197 var offset = Number(document.getElementById('slider').attributes['marginsize'].value);
n@47 198 var scale = document.getElementById('sliderScaleHolder');
n@47 199 scale.innerHTML = null;
n@47 200 interfaceObj.find('scale').each(function(index,scaleObj){
n@127 201 var value = document.createAttribute('value');
n@47 202 var position = Number(scaleObj.attributes['position'].value)*0.01;
n@127 203 value.nodeValue = position;
n@47 204 var pixelPosition = (position*positionScale)+offset;
n@47 205 var scaleDOM = document.createElement('span');
n@47 206 scaleDOM.textContent = scaleObj.textContent;
n@47 207 scale.appendChild(scaleDOM);
n@47 208 scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px';
n@127 209 scaleDOM.setAttributeNode(value);
n@47 210 });
n@174 211
n@174 212 var commentBoxPrefix = interfaceObj.find('commentBoxPrefix');
n@174 213 if (commentBoxPrefix.length != 0) {
n@174 214 commentBoxPrefix = commentBoxPrefix[0].textContent;
n@174 215 } else {
n@174 216 commentBoxPrefix = "Comment on track";
n@174 217 }
n@34 218
n@34 219 /// CHECK FOR SAMPLE RATE COMPATIBILITY
n@181 220 if (audioHolderObject.sampleRate != undefined) {
n@181 221 if (Number(audioHolderObject.sampleRate) != audioContext.sampleRate) {
n@34 222 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 223 alert(errStr);
n@34 224 return;
n@34 225 }
n@34 226 }
n@45 227
n@181 228 var commentShow = audioHolderObject.elementComments;
nicholas@66 229
n@181 230 var loopPlayback = audioHolderObject.loop;
n@181 231
n@57 232 audioEngineContext.loopPlayback = loopPlayback;
n@57 233 // Create AudioEngine bindings for playback
n@57 234 if (loopPlayback) {
n@57 235 audioEngineContext.selectedTrack = function(id) {
n@57 236 for (var i=0; i<this.audioObjects.length; i++)
n@57 237 {
n@57 238 if (id == i) {
nicholas@132 239 this.audioObjects[i].loopStart();
n@57 240 } else {
nicholas@132 241 this.audioObjects[i].loopStop();
n@57 242 }
n@57 243 }
n@57 244 };
n@57 245 } else {
n@57 246 audioEngineContext.selectedTrack = function(id) {
n@57 247 for (var i=0; i<this.audioObjects.length; i++)
n@57 248 {
n@97 249 this.audioObjects[i].outputGain.gain.value = 0.0;
n@97 250 this.audioObjects[i].stop();
n@57 251 }
n@99 252 if (this.status == 1) {
n@99 253 this.audioObjects[id].outputGain.gain.value = 1.0;
n@99 254 this.audioObjects[id].play(audioContext.currentTime+0.01);
n@99 255 }
n@57 256 };
n@57 257 }
n@57 258
n@46 259 currentTestHolder = document.createElement('audioHolder');
n@181 260 currentTestHolder.id = audioHolderObject.id;
n@181 261 currentTestHolder.repeatCount = audioHolderObject.repeatCount;
n@46 262
n@181 263 var randomise = audioHolderObject.randomiseOrder;
n@45 264
n@181 265 var audioElements = audioHolderObject.audioElements;
nicholas@58 266 currentTrackOrder = [];
n@45 267 if (randomise) {
n@181 268 audioHolderObject.audioElements = randomiseOrder(audioHolderObject.audioElements);
n@45 269 }
n@45 270
nicholas@58 271 // Delete any previous audioObjects associated with the audioEngine
nicholas@58 272 audioEngineContext.audioObjects = [];
nicholas@58 273
n@45 274 // Find all the audioElements from the audioHolder
n@181 275 $(audioHolderObject.audioElements).each(function(index,element){
n@34 276 // Find URL of track
n@34 277 // In this jQuery loop, variable 'this' holds the current audioElement.
n@34 278
n@34 279 // Now load each audio sample. First create the new track by passing the full URL
n@181 280 var trackURL = audioHolderObject.hostURL + element.url;
n@182 281 var audioObject = audioEngineContext.newTrack(element);
nicholas@66 282
nicholas@66 283 if (commentShow) {
n@182 284 var node = interfaceContext.createCommentBox(audioObject);
nicholas@66 285 }
n@34 286
n@34 287 // Create a slider per track
n@34 288
n@34 289 var trackSliderObj = document.createElement('div');
n@34 290 trackSliderObj.className = 'track-slider';
n@34 291 trackSliderObj.id = 'track-slider-'+index;
n@154 292
n@154 293 var trackSliderAOIndex = document.createAttribute('trackIndex');
n@154 294 trackSliderAOIndex.nodeValue = index;
n@154 295 trackSliderObj.setAttributeNode(trackSliderAOIndex);
n@154 296
n@34 297 // Distribute it randomnly
n@138 298 var w = window.innerWidth - (offset+8)*2;
n@34 299 w = Math.random()*w;
n@138 300 w = Math.floor(w+(offset+8));
n@138 301 trackSliderObj.style.left = w+'px';
n@34 302 trackSliderObj.innerHTML = '<span>'+index+'</span>';
n@34 303 trackSliderObj.draggable = true;
n@34 304 trackSliderObj.ondragend = dragEnd;
n@49 305 trackSliderObj.ondragstart = function()
n@49 306 {
n@154 307 var id = Number(event.srcElement.attributes['trackIndex'].value);
n@49 308 audioEngineContext.metric.sliderMoveStart(id);
n@49 309 };
n@34 310
n@34 311 // Onclick, switch playback to that track
n@34 312 trackSliderObj.onclick = function() {
nicholas@108 313 // Start the test on first click, that way timings are more accurate.
nicholas@108 314 audioEngineContext.play();
nicholas@135 315 if (audioEngineContext.audioObjectsReady) {
nicholas@135 316 // Cannot continue to issue play command until audioObjects reported as ready!
nicholas@135 317 // Get the track ID from the object ID
n@154 318 var id = Number(event.srcElement.attributes['trackIndex'].value);
nicholas@135 319 //audioEngineContext.metric.sliderPlayed(id);
nicholas@135 320 audioEngineContext.selectedTrack(id);
nicholas@135 321 // Currently playing track red, rest green
n@154 322
n@154 323 //document.getElementById('track-slider-'+index).style.backgroundColor = "#FF0000";
n@154 324 $('.track-slider').removeClass('track-slider-playing');
n@154 325 $(event.srcElement).addClass('track-slider-playing');
n@154 326 $('.comment-div').removeClass('comment-box-playing');
n@154 327 $('#comment-div-'+id).addClass('comment-box-playing');
nicholas@135 328 }
n@34 329 };
n@34 330
n@177 331 // Attach binding
n@179 332 audioObject.sliderDOM = trackSliderObj;
n@177 333
n@34 334 canvas.appendChild(trackSliderObj);
n@179 335 audioObject.metric.initialised(convSliderPosToRate(index));
b@102 336
n@34 337 });
n@182 338 if (commentShow) {
n@182 339 interfaceContext.showCommentBoxes(feedbackHolder,true);
n@182 340 }
n@39 341
nicholas@65 342 // Append any commentQuestion boxes
n@181 343 $(audioHolderObject.commentQuestions).each(function(index,element) {
nicholas@65 344 // Create document objects to hold the comment boxes
nicholas@65 345 var trackComment = document.createElement('div');
nicholas@65 346 trackComment.className = 'comment-div commentQuestion';
n@181 347 trackComment.id = element.id;
nicholas@65 348 // Create a string next to each comment asking for a comment
nicholas@65 349 var trackString = document.createElement('span');
n@181 350 trackString.innerHTML = element.question;
nicholas@65 351 // Create the HTML5 comment box 'textarea'
nicholas@65 352 var trackCommentBox = document.createElement('textarea');
nicholas@65 353 trackCommentBox.rows = '4';
nicholas@65 354 trackCommentBox.cols = '100';
nicholas@65 355 trackCommentBox.name = 'commentQuestion'+index;
nicholas@65 356 trackCommentBox.className = 'trackComment';
nicholas@65 357 var br = document.createElement('br');
nicholas@65 358 // Add to the holder.
nicholas@65 359 trackComment.appendChild(trackString);
nicholas@65 360 trackComment.appendChild(br);
nicholas@65 361 trackComment.appendChild(trackCommentBox);
nicholas@65 362 feedbackHolder.appendChild(trackComment);
nicholas@65 363 });
n@153 364
n@153 365
n@153 366 testWaitIndicator();
n@39 367 }
n@39 368
nicholas@119 369
nicholas@5 370 function dragEnd(ev) {
nicholas@5 371 // Function call when a div has been dropped
n@33 372 var slider = document.getElementById('slider');
n@127 373 var marginSize = Number(slider.attributes['marginsize'].value);
n@51 374 var w = slider.style.width;
n@51 375 w = Number(w.substr(0,w.length-2));
nicholas@133 376 var x = ev.x;
n@127 377 if (x >= marginSize && x < w+marginSize) {
n@51 378 this.style.left = (x)+'px';
nicholas@5 379 } else {
n@127 380 if (x<marginSize) {
n@127 381 this.style.left = marginSize+'px';
nicholas@5 382 } else {
n@127 383 this.style.left = (w+marginSize) + 'px';
nicholas@5 384 }
nicholas@5 385 }
n@49 386 audioEngineContext.metric.sliderMoved();
nicholas@5 387 }
nicholas@7 388
b@101 389 function buttonSubmitClick() // TODO: Only when all songs have been played!
n@40 390 {
nicholas@107 391 hasBeenPlayed = audioEngineContext.checkAllPlayed();
nicholas@107 392 if (hasBeenPlayed.length == 0) {
nicholas@107 393 if (audioEngineContext.status == 1) {
nicholas@107 394 var playback = document.getElementById('playback-button');
nicholas@107 395 playback.click();
nicholas@107 396 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
nicholas@107 397 } else
nicholas@107 398 {
nicholas@107 399 if (audioEngineContext.timer.testStarted == false)
nicholas@107 400 {
nicholas@107 401 alert('You have not started the test! Please press start to begin the test!');
nicholas@107 402 return;
nicholas@107 403 }
nicholas@107 404 }
nicholas@129 405 testState.advanceState();
b@102 406 } else // if a fragment has not been played yet
b@102 407 {
nicholas@107 408 str = "";
nicholas@107 409 if (hasBeenPlayed.length > 1) {
nicholas@107 410 for (var i=0; i<hasBeenPlayed.length; i++) {
nicholas@107 411 str = str + hasBeenPlayed[i];
nicholas@107 412 if (i < hasBeenPlayed.length-2){
nicholas@107 413 str += ", ";
nicholas@107 414 } else if (i == hasBeenPlayed.length-2) {
nicholas@107 415 str += " or ";
nicholas@107 416 }
nicholas@107 417 }
nicholas@107 418 alert('You have not played fragments ' + str + ' yet. Please listen, rate and comment all samples before submitting.');
nicholas@107 419 } else {
nicholas@107 420 alert('You have not played fragment ' + hasBeenPlayed[0] + ' yet. Please listen, rate and comment all samples before submitting.');
nicholas@107 421 }
b@102 422 return;
b@102 423 }
n@40 424 }
n@40 425
n@51 426 function convSliderPosToRate(id)
n@51 427 {
n@51 428 var w = document.getElementById('slider').style.width;
n@127 429 var marginsize = Number(document.getElementById('slider').attributes['marginsize'].value);
n@51 430 var maxPix = w.substr(0,w.length-2);
n@51 431 var slider = document.getElementsByClassName('track-slider')[id];
n@51 432 var pix = slider.style.left;
n@51 433 pix = pix.substr(0,pix.length-2);
n@127 434 var rate = (pix-marginsize)/maxPix;
n@51 435 return rate;
n@51 436 }
n@51 437
n@127 438 function resizeWindow(event){
n@127 439 // Function called when the window has been resized.
n@127 440 // MANDATORY FUNCTION
n@127 441
n@127 442 // Store the slider marker values
n@127 443 var holdValues = [];
n@127 444 $(".track-slider").each(function(index,sliderObj){
n@127 445 holdValues.push(convSliderPosToRate(index));
n@127 446 });
n@127 447
n@127 448 var width = event.target.innerWidth;
n@127 449 var canvas = document.getElementById('sliderCanvasHolder');
n@127 450 var sliderDiv = canvas.children[0];
n@127 451 var sliderScaleDiv = canvas.children[1];
n@127 452 var marginsize = Number(sliderDiv.attributes['marginsize'].value);
n@127 453 var w = (marginsize+8)*2;
n@127 454 sliderDiv.style.width = width - w + 'px';
n@127 455 var width = width - w;
n@127 456 // Move sliders into new position
n@127 457 $(".track-slider").each(function(index,sliderObj){
n@127 458 var pos = holdValues[index];
n@127 459 var pix = pos * width;
n@127 460 sliderObj.style.left = pix+marginsize+'px';
n@127 461 });
n@127 462
n@127 463 // Move scale labels
n@127 464 $(sliderScaleDiv.children).each(function(index,scaleObj){
n@127 465 var position = Number(scaleObj.attributes['value'].value);
n@127 466 var pixelPosition = (position*width)+marginsize;
n@127 467 scaleObj.style.left = Math.floor((pixelPosition-($(scaleObj).width()/2)))+'px';
n@127 468 });
n@127 469 }
n@127 470
n@181 471 function pageXMLSave(store, testXML)
n@44 472 {
n@44 473 // Saves a specific test page
nicholas@129 474 var xmlDoc = store;
n@50 475 // Check if any session wide metrics are enabled
nicholas@67 476
n@181 477 var commentShow = testXML.elementComments;
nicholas@67 478
n@50 479 var metric = document.createElement('metric');
n@50 480 if (audioEngineContext.metric.enableTestTimer)
n@50 481 {
n@50 482 var testTime = document.createElement('metricResult');
n@50 483 testTime.id = 'testTime';
n@50 484 testTime.textContent = audioEngineContext.timer.testDuration;
n@50 485 metric.appendChild(testTime);
n@50 486 }
n@50 487 xmlDoc.appendChild(metric);
n@178 488 var audioObjects = audioEngineContext.audioObjects;
n@178 489 for (var i=0; i<audioObjects.length; i++)
n@45 490 {
n@45 491 var audioElement = document.createElement('audioElement');
n@178 492 audioElement.id = audioObjects[i].id;
n@178 493 audioElement.setAttribute('url',audioObjects[i].url);
n@51 494 var value = document.createElement('value');
n@51 495 value.innerHTML = convSliderPosToRate(i);
nicholas@67 496 if (commentShow) {
nicholas@67 497 var comment = document.createElement("comment");
nicholas@67 498 var question = document.createElement("question");
nicholas@67 499 var response = document.createElement("response");
n@178 500 question.textContent = audioObjects[i].commentDOM.children[0].textContent;
n@178 501 response.textContent = audioObjects[i].commentDOM.children[2].value;
n@178 502 console.log('Comment ' + i + ': ' + response.textContent); // DEBUG/SAFETY
nicholas@67 503 comment.appendChild(question);
nicholas@67 504 comment.appendChild(response);
nicholas@67 505 audioElement.appendChild(comment);
nicholas@67 506 }
n@45 507 audioElement.appendChild(value);
n@50 508 // Check for any per element metrics
n@177 509
n@178 510 audioElement.appendChild(audioObjects[i].metric.exportXMLDOM());
n@45 511 xmlDoc.appendChild(audioElement);
n@45 512 }
nicholas@65 513 var commentQuestion = document.getElementsByClassName('commentQuestion');
nicholas@65 514 for (var i=0; i<commentQuestion.length; i++)
nicholas@65 515 {
nicholas@65 516 var cqHolder = document.createElement('CommentQuestion');
nicholas@65 517 var comment = document.createElement('comment');
nicholas@65 518 var question = document.createElement('question');
nicholas@65 519 cqHolder.id = commentQuestion[i].id;
nicholas@65 520 comment.textContent = commentQuestion[i].children[2].value;
nicholas@65 521 question.textContent = commentQuestion[i].children[0].textContent;
n@124 522 console.log('Question ' + i + ': ' + commentQuestion[i].children[2].value); // DEBUG/SAFETY
nicholas@65 523 cqHolder.appendChild(question);
nicholas@65 524 cqHolder.appendChild(comment);
nicholas@65 525 xmlDoc.appendChild(cqHolder);
nicholas@65 526 }
nicholas@129 527 store = xmlDoc;
nicholas@67 528 }