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@50
|
45 var audioHolders = xmlDoc.find('audioHolder');
|
n@50
|
46 audioHolders.each(function(index,element) {
|
n@50
|
47 var repeatN = element.attributes['repeatCount'].value;
|
n@50
|
48 for (var r=0; r<=repeatN; r++) {
|
n@50
|
49 testXMLSetups[testXMLSetups.length] = element;
|
n@50
|
50 }
|
n@50
|
51 });
|
n@44
|
52
|
n@50
|
53 // New check if we need to randomise the test order
|
n@50
|
54 var randomise = xmlSetup[0].attributes['randomiseOrder'];
|
n@50
|
55 if (randomise != undefined) {
|
n@50
|
56 randomise = Boolean(randomise.value);
|
n@50
|
57 } else {
|
n@50
|
58 randomise = false;
|
n@50
|
59 }
|
n@50
|
60 if (randomise)
|
n@50
|
61 {
|
n@54
|
62 testXMLSetups = randomiseOrder(testXMLSetups);
|
n@50
|
63 }
|
n@44
|
64
|
n@50
|
65 // Obtain the metrics enabled
|
n@50
|
66 var metricNode = xmlSetup.find('Metric');
|
n@50
|
67 var metricNode = metricNode.find('metricEnable');
|
n@50
|
68 metricNode.each(function(index,node){
|
n@50
|
69 var enabled = node.textContent;
|
n@50
|
70 switch(enabled)
|
n@50
|
71 {
|
n@50
|
72 case 'testTimer':
|
n@50
|
73 sessionMetrics.prototype.enableTestTimer = true;
|
n@50
|
74 break;
|
n@50
|
75 case 'elementTimer':
|
n@50
|
76 sessionMetrics.prototype.enableElementTimer = true;
|
n@50
|
77 break;
|
n@50
|
78 case 'elementTracker':
|
n@50
|
79 sessionMetrics.prototype.enableElementTracker = true;
|
n@50
|
80 break;
|
n@50
|
81 case 'elementInitalPosition':
|
n@50
|
82 sessionMetrics.prototype.enableElementInitialPosition = true;
|
n@50
|
83 break;
|
n@50
|
84 case 'elementFlagListenedTo':
|
n@50
|
85 sessionMetrics.prototype.enableFlagListenedTo = true;
|
n@50
|
86 break;
|
n@50
|
87 case 'elementFlagMoved':
|
n@50
|
88 sessionMetrics.prototype.enableFlagMoved = true;
|
n@50
|
89 break;
|
n@50
|
90 case 'elementFlagComments':
|
n@50
|
91 sessionMetrics.prototype.enableFlagComments = true;
|
n@50
|
92 break;
|
n@50
|
93 }
|
n@50
|
94 });
|
n@34
|
95
|
n@52
|
96 // Create APE specific metric functions
|
n@52
|
97 audioEngineContext.metric.initialiseTest = function()
|
n@52
|
98 {
|
n@52
|
99 var sliders = document.getElementsByClassName('track-slider');
|
n@52
|
100 for (var i=0; i<sliders.length; i++)
|
n@52
|
101 {
|
n@52
|
102 audioEngineContext.audioObjects[i].metric.initialised(convSliderPosToRate(i));
|
n@52
|
103 }
|
n@52
|
104 };
|
n@52
|
105
|
n@52
|
106 audioEngineContext.metric.sliderMoveStart = function(id)
|
n@52
|
107 {
|
n@52
|
108 if (this.data == -1)
|
n@52
|
109 {
|
n@52
|
110 this.data = id;
|
n@52
|
111 } else {
|
n@52
|
112 console.log('ERROR: Metric tracker detecting two moves!');
|
n@52
|
113 this.data = -1;
|
n@52
|
114 }
|
n@52
|
115 };
|
n@52
|
116 audioEngineContext.metric.sliderMoved = function()
|
n@52
|
117 {
|
n@52
|
118 var time = audioEngineContext.timer.getTestTime();
|
n@52
|
119 var id = this.data;
|
n@52
|
120 this.data = -1;
|
n@52
|
121 var position = convSliderPosToRate(id);
|
n@52
|
122 if (audioEngineContext.timer.testStarted)
|
n@52
|
123 {
|
n@52
|
124 audioEngineContext.audioObjects[id].metric.moved(time,position);
|
n@52
|
125 }
|
n@52
|
126 };
|
n@52
|
127
|
n@52
|
128 audioEngineContext.metric.sliderPlayed = function(id)
|
n@52
|
129 {
|
n@52
|
130 var time = audioEngineContext.timer.getTestTime();
|
n@52
|
131 if (audioEngineContext.timer.testStarted)
|
n@52
|
132 {
|
n@52
|
133 if (this.lastClicked >= 0)
|
n@52
|
134 {
|
n@52
|
135 audioEngineContext.audioObjects[this.lastClicked].metric.listening(time);
|
n@52
|
136 }
|
n@52
|
137 this.lastClicked = id;
|
n@52
|
138 audioEngineContext.audioObjects[id].metric.listening(time);
|
n@52
|
139 }
|
n@52
|
140 };
|
n@52
|
141
|
nicholas@2
|
142 // Create the top div for the Title element
|
nicholas@2
|
143 var titleAttr = xmlSetup[0].attributes['title'];
|
nicholas@2
|
144 var title = document.createElement('div');
|
nicholas@2
|
145 title.className = "title";
|
nicholas@2
|
146 title.align = "center";
|
nicholas@2
|
147 var titleSpan = document.createElement('span');
|
nicholas@2
|
148
|
nicholas@2
|
149 // Set title to that defined in XML, else set to default
|
nicholas@2
|
150 if (titleAttr != undefined) {
|
n@25
|
151 titleSpan.innerHTML = titleAttr.value;
|
nicholas@2
|
152 } else {
|
n@25
|
153 titleSpan.innerHTML = 'APE Tool';
|
nicholas@2
|
154 }
|
nicholas@2
|
155 // Insert the titleSpan element into the title div element.
|
nicholas@2
|
156 title.appendChild(titleSpan);
|
nicholas@2
|
157
|
n@47
|
158 var pagetitle = document.createElement('div');
|
n@47
|
159 pagetitle.className = "pageTitle";
|
n@47
|
160 pagetitle.align = "center";
|
n@47
|
161 var titleSpan = document.createElement('span');
|
n@47
|
162 titleSpan.id = "pageTitle";
|
n@47
|
163 pagetitle.appendChild(titleSpan);
|
n@47
|
164
|
nicholas@7
|
165 // Store the return URL path in global projectReturn
|
nicholas@7
|
166 projectReturn = xmlSetup[0].attributes['projectReturn'].value;
|
nicholas@7
|
167
|
nicholas@7
|
168 // Create Interface buttons!
|
nicholas@7
|
169 var interfaceButtons = document.createElement('div');
|
nicholas@7
|
170 interfaceButtons.id = 'interface-buttons';
|
nicholas@7
|
171
|
nicholas@7
|
172 // MANUAL DOWNLOAD POINT
|
nicholas@7
|
173 // If project return is null, this MUST be specified as the location to create the download link
|
nicholas@7
|
174 var downloadPoint = document.createElement('div');
|
nicholas@7
|
175 downloadPoint.id = 'download-point';
|
nicholas@7
|
176
|
nicholas@7
|
177 // Create playback start/stop points
|
nicholas@7
|
178 var playback = document.createElement("button");
|
n@25
|
179 playback.innerHTML = 'Start';
|
n@49
|
180 playback.id = 'playback-button';
|
n@16
|
181 // onclick function. Check if it is playing or not, call the correct function in the
|
n@16
|
182 // audioEngine, change the button text to reflect the next state.
|
nicholas@7
|
183 playback.onclick = function() {
|
nicholas@7
|
184 if (audioEngineContext.status == 0) {
|
nicholas@7
|
185 audioEngineContext.play();
|
n@25
|
186 this.innerHTML = 'Stop';
|
nicholas@7
|
187 } else {
|
nicholas@7
|
188 audioEngineContext.stop();
|
n@25
|
189 this.innerHTML = 'Start';
|
nicholas@7
|
190 }
|
n@16
|
191 };
|
nicholas@7
|
192 // Create Submit (save) button
|
nicholas@7
|
193 var submit = document.createElement("button");
|
n@25
|
194 submit.innerHTML = 'Submit';
|
n@43
|
195 submit.onclick = buttonSubmitClick;
|
n@49
|
196 submit.id = 'submit-button';
|
n@16
|
197 // Append the interface buttons into the interfaceButtons object.
|
nicholas@7
|
198 interfaceButtons.appendChild(playback);
|
nicholas@7
|
199 interfaceButtons.appendChild(submit);
|
nicholas@7
|
200 interfaceButtons.appendChild(downloadPoint);
|
nicholas@7
|
201
|
nicholas@2
|
202 // Now create the slider and HTML5 canvas boxes
|
nicholas@2
|
203
|
n@16
|
204 // Create the div box to center align
|
nicholas@2
|
205 var sliderBox = document.createElement('div');
|
nicholas@2
|
206 sliderBox.className = 'sliderCanvasDiv';
|
n@16
|
207 sliderBox.id = 'sliderCanvasHolder';
|
nicholas@2
|
208 sliderBox.align = 'center';
|
nicholas@2
|
209
|
n@16
|
210 // Create the slider box to hold the slider elements
|
nicholas@5
|
211 var canvas = document.createElement('div');
|
nicholas@2
|
212 canvas.id = 'slider';
|
n@16
|
213 // Must have a known EXACT width, as this is used later to determine the ratings
|
nicholas@5
|
214 canvas.style.width = width - 100 +"px";
|
nicholas@5
|
215 canvas.align = "left";
|
nicholas@2
|
216 sliderBox.appendChild(canvas);
|
n@16
|
217
|
n@47
|
218 // Create the div to hold any scale objects
|
n@47
|
219 var scale = document.createElement('div');
|
n@47
|
220 scale.className = 'sliderScale';
|
n@47
|
221 scale.id = 'sliderScaleHolder';
|
n@47
|
222 scale.align = 'left';
|
n@47
|
223 sliderBox.appendChild(scale);
|
n@47
|
224
|
n@16
|
225 // Global parent for the comment boxes on the page
|
nicholas@3
|
226 var feedbackHolder = document.createElement('div');
|
n@34
|
227 feedbackHolder.id = 'feedbackHolder';
|
nicholas@2
|
228
|
n@38
|
229 testContent.style.zIndex = 1;
|
n@38
|
230 insertPoint.innerHTML = null; // Clear the current schema
|
n@38
|
231
|
n@22
|
232 // Create pre and post test questions
|
n@38
|
233 var blank = document.createElement('div');
|
n@38
|
234 blank.className = 'testHalt';
|
n@22
|
235
|
n@38
|
236 var popupHolder = document.createElement('div');
|
n@38
|
237 popupHolder.id = 'popupHolder';
|
n@38
|
238 popupHolder.className = 'popupHolder';
|
n@38
|
239 popupHolder.style.position = 'absolute';
|
n@38
|
240 popupHolder.style.left = (window.innerWidth/2)-250 + 'px';
|
n@38
|
241 popupHolder.style.top = (window.innerHeight/2)-125 + 'px';
|
n@38
|
242 insertPoint.appendChild(popupHolder);
|
n@38
|
243 insertPoint.appendChild(blank);
|
n@38
|
244 hidePopup();
|
n@22
|
245
|
n@36
|
246 var preTest = xmlSetup.find('PreTest');
|
n@36
|
247 var postTest = xmlSetup.find('PostTest');
|
n@22
|
248 preTest = preTest[0];
|
n@22
|
249 postTest = postTest[0];
|
n@38
|
250
|
n@38
|
251 currentState = 'preTest';
|
n@22
|
252
|
n@22
|
253 // Create Pre-Test Box
|
n@22
|
254 if (preTest != undefined && preTest.children.length >= 1)
|
n@22
|
255 {
|
n@38
|
256 showPopup();
|
n@39
|
257 preTestPopupStart(preTest);
|
n@22
|
258 }
|
n@38
|
259
|
n@38
|
260 // Inject into HTML
|
n@38
|
261 testContent.appendChild(title); // Insert the title
|
n@47
|
262 testContent.appendChild(pagetitle);
|
n@38
|
263 testContent.appendChild(interfaceButtons);
|
n@38
|
264 testContent.appendChild(sliderBox);
|
n@38
|
265 testContent.appendChild(feedbackHolder);
|
n@38
|
266 insertPoint.appendChild(testContent);
|
n@22
|
267
|
n@36
|
268 // Load the full interface
|
n@39
|
269
|
nicholas@2
|
270 }
|
nicholas@5
|
271
|
n@39
|
272 function loadTest(id)
|
n@34
|
273 {
|
n@34
|
274 // Used to load a specific test page
|
n@39
|
275 var textXML = testXMLSetups[id];
|
n@34
|
276
|
n@34
|
277 var feedbackHolder = document.getElementById('feedbackHolder');
|
n@34
|
278 var canvas = document.getElementById('slider');
|
n@34
|
279 feedbackHolder.innerHTML = null;
|
n@34
|
280 canvas.innerHTML = null;
|
n@47
|
281
|
n@47
|
282 // Setup question title
|
n@47
|
283 var interfaceObj = $(textXML).find('interface');
|
n@47
|
284 var titleNode = interfaceObj.find('title');
|
n@47
|
285 if (titleNode[0] != undefined)
|
n@47
|
286 {
|
n@47
|
287 document.getElementById('pageTitle').textContent = titleNode[0].textContent;
|
n@47
|
288 }
|
n@47
|
289 var positionScale = canvas.style.width.substr(0,canvas.style.width.length-2);
|
n@47
|
290 var offset = 50-8; // Half the offset of the slider (window width -100) minus the body padding of 8
|
n@47
|
291 // TODO: AUTOMATE ABOVE!!
|
n@47
|
292 var scale = document.getElementById('sliderScaleHolder');
|
n@47
|
293 scale.innerHTML = null;
|
n@47
|
294 interfaceObj.find('scale').each(function(index,scaleObj){
|
n@47
|
295 var position = Number(scaleObj.attributes['position'].value)*0.01;
|
n@47
|
296 var pixelPosition = (position*positionScale)+offset;
|
n@47
|
297 var scaleDOM = document.createElement('span');
|
n@47
|
298 scaleDOM.textContent = scaleObj.textContent;
|
n@47
|
299 scale.appendChild(scaleDOM);
|
n@47
|
300 scaleDOM.style.left = Math.floor((pixelPosition-($(scaleDOM).width()/2)))+'px';
|
n@47
|
301 });
|
n@34
|
302
|
n@34
|
303 // Extract the hostURL attribute. If not set, create an empty string.
|
n@34
|
304 var hostURL = textXML.attributes['hostURL'];
|
n@34
|
305 if (hostURL == undefined) {
|
n@34
|
306 hostURL = "";
|
n@34
|
307 } else {
|
n@34
|
308 hostURL = hostURL.value;
|
n@34
|
309 }
|
n@34
|
310 // Extract the sampleRate. If set, convert the string to a Number.
|
n@34
|
311 var hostFs = textXML.attributes['sampleRate'];
|
n@34
|
312 if (hostFs != undefined) {
|
n@34
|
313 hostFs = Number(hostFs.value);
|
n@34
|
314 }
|
n@34
|
315
|
n@34
|
316 /// CHECK FOR SAMPLE RATE COMPATIBILITY
|
n@34
|
317 if (hostFs != undefined) {
|
n@34
|
318 if (Number(hostFs) != audioContext.sampleRate) {
|
n@34
|
319 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
|
320 alert(errStr);
|
n@34
|
321 return;
|
n@34
|
322 }
|
n@34
|
323 }
|
n@45
|
324
|
n@57
|
325 var loopPlayback = textXML.attributes['loop'];
|
n@57
|
326 if (loopPlayback != undefined)
|
n@57
|
327 {
|
n@57
|
328 loopPlayback = loopPlayback.value;
|
n@57
|
329 if (loopPlayback == 'true') {
|
n@57
|
330 loopPlayback = true;
|
n@57
|
331 } else {
|
n@57
|
332 loopPlayback = false;
|
n@57
|
333 }
|
n@57
|
334 } else {
|
n@57
|
335 loopPlayback = false;
|
n@57
|
336 }
|
n@57
|
337 audioEngineContext.loopPlayback = loopPlayback;
|
n@57
|
338
|
n@57
|
339 // Create AudioEngine bindings for playback
|
n@57
|
340 if (loopPlayback) {
|
n@57
|
341 audioEngineContext.play = function() {
|
n@57
|
342 // Send play command to all playback buffers for synchronised start
|
n@57
|
343 // Also start timer callbacks to detect if playback has finished
|
n@57
|
344 if (this.status == 0) {
|
n@57
|
345 this.timer.startTest();
|
n@57
|
346 // First get current clock
|
n@57
|
347 var timer = audioContext.currentTime;
|
n@57
|
348 // Add 3 seconds
|
n@57
|
349 timer += 3.0;
|
n@57
|
350 // Send play to all tracks
|
n@57
|
351 for (var i=0; i<this.audioObjects.length; i++)
|
n@57
|
352 {
|
n@57
|
353 this.audioObjects[i].play(timer);
|
n@57
|
354 }
|
n@57
|
355 this.status = 1;
|
n@57
|
356 }
|
n@57
|
357 };
|
n@57
|
358
|
n@57
|
359 audioEngineContext.stop = function() {
|
n@57
|
360 // Send stop and reset command to all playback buffers
|
n@57
|
361 if (this.status == 1) {
|
n@57
|
362 if (this.loopPlayback) {
|
n@57
|
363 for (var i=0; i<this.audioObjects.length; i++)
|
n@57
|
364 {
|
n@57
|
365 this.audioObjects[i].stop();
|
n@57
|
366 }
|
n@57
|
367 }
|
n@57
|
368 this.status = 0;
|
n@57
|
369 }
|
n@57
|
370 };
|
n@57
|
371
|
n@57
|
372 audioEngineContext.selectedTrack = function(id) {
|
n@57
|
373 for (var i=0; i<this.audioObjects.length; i++)
|
n@57
|
374 {
|
n@57
|
375 if (id == i) {
|
n@57
|
376 this.audioObjects[i].outputGain.gain.value = 1.0;
|
n@57
|
377 } else {
|
n@57
|
378 this.audioObjects[i].outputGain.gain.value = 0.0;
|
n@57
|
379 }
|
n@57
|
380 }
|
n@57
|
381 };
|
n@57
|
382 } else {
|
n@57
|
383 audioEngineContext.play = function() {
|
n@57
|
384 // Send play command to all playback buffers for synchronised start
|
n@57
|
385 // Also start timer callbacks to detect if playback has finished
|
n@57
|
386 if (this.status == 0) {
|
n@57
|
387 this.timer.startTest();
|
n@57
|
388 this.status = 1;
|
n@57
|
389 }
|
n@57
|
390 };
|
n@57
|
391
|
n@57
|
392 audioEngineContext.stop = function() {
|
n@57
|
393 // Send stop and reset command to all playback buffers
|
n@57
|
394 if (this.status == 1) {
|
n@57
|
395 if (this.loopPlayback) {
|
n@57
|
396 for (var i=0; i<this.audioObjects.length; i++)
|
n@57
|
397 {
|
n@57
|
398 this.audioObjects[i].stop();
|
n@57
|
399 }
|
n@57
|
400 }
|
n@57
|
401 this.status = 0;
|
n@57
|
402 }
|
n@57
|
403 };
|
n@57
|
404
|
n@57
|
405 audioEngineContext.selectedTrack = function(id) {
|
n@57
|
406 for (var i=0; i<this.audioObjects.length; i++)
|
n@57
|
407 {
|
n@57
|
408 if (id == i) {
|
n@57
|
409 this.audioObjects[i].outputGain.gain.value = 1.0;
|
n@57
|
410 this.audioObjects[i].play(audioContext.currentTime+0.01);
|
n@57
|
411 } else {
|
n@57
|
412 this.audioObjects[i].outputGain.gain.value = 0.0;
|
n@57
|
413 }
|
n@57
|
414 }
|
n@57
|
415 };
|
n@57
|
416 }
|
n@57
|
417
|
n@46
|
418 currentTestHolder = document.createElement('audioHolder');
|
n@46
|
419 currentTestHolder.id = textXML.id;
|
n@46
|
420 currentTestHolder.repeatCount = textXML.attributes['repeatCount'].value;
|
n@46
|
421 var currentPreTestHolder = document.createElement('preTest');
|
n@46
|
422 var currentPostTestHolder = document.createElement('postTest');
|
n@46
|
423 currentTestHolder.appendChild(currentPreTestHolder);
|
n@46
|
424 currentTestHolder.appendChild(currentPostTestHolder);
|
n@46
|
425
|
n@45
|
426 var randomise = textXML.attributes['randomiseOrder'];
|
n@45
|
427 if (randomise != undefined) {randomise = randomise.value;}
|
n@45
|
428 else {randomise = false;}
|
n@45
|
429
|
n@34
|
430 var audioElements = $(textXML).find('audioElements');
|
nicholas@58
|
431 currentTrackOrder = [];
|
n@34
|
432 audioElements.each(function(index,element){
|
n@45
|
433 // Find any blind-repeats
|
n@45
|
434 // Not implemented yet, but just incase
|
n@45
|
435 currentTrackOrder[index] = element;
|
n@45
|
436 });
|
n@45
|
437 if (randomise) {
|
n@54
|
438 currentTrackOrder = randomiseOrder(currentTrackOrder);
|
n@45
|
439 }
|
n@45
|
440
|
nicholas@58
|
441 // Delete any previous audioObjects associated with the audioEngine
|
nicholas@58
|
442 audioEngineContext.audioObjects = [];
|
nicholas@58
|
443
|
n@45
|
444 // Find all the audioElements from the audioHolder
|
n@45
|
445 $(currentTrackOrder).each(function(index,element){
|
n@34
|
446 // Find URL of track
|
n@34
|
447 // In this jQuery loop, variable 'this' holds the current audioElement.
|
n@34
|
448
|
n@34
|
449 // Now load each audio sample. First create the new track by passing the full URL
|
n@34
|
450 var trackURL = hostURL + this.attributes['url'].value;
|
n@34
|
451 audioEngineContext.newTrack(trackURL);
|
n@34
|
452 // Create document objects to hold the comment boxes
|
n@34
|
453 var trackComment = document.createElement('div');
|
n@37
|
454 trackComment.className = 'comment-div';
|
n@34
|
455 // Create a string next to each comment asking for a comment
|
n@34
|
456 var trackString = document.createElement('span');
|
n@34
|
457 trackString.innerHTML = 'Comment on track '+index;
|
n@34
|
458 // Create the HTML5 comment box 'textarea'
|
n@34
|
459 var trackCommentBox = document.createElement('textarea');
|
n@34
|
460 trackCommentBox.rows = '4';
|
n@34
|
461 trackCommentBox.cols = '100';
|
n@34
|
462 trackCommentBox.name = 'trackComment'+index;
|
n@34
|
463 trackCommentBox.className = 'trackComment';
|
n@34
|
464 var br = document.createElement('br');
|
n@34
|
465 // Add to the holder.
|
n@34
|
466 trackComment.appendChild(trackString);
|
n@34
|
467 trackComment.appendChild(br);
|
n@34
|
468 trackComment.appendChild(trackCommentBox);
|
n@34
|
469 feedbackHolder.appendChild(trackComment);
|
n@34
|
470
|
n@34
|
471 // Create a slider per track
|
n@34
|
472
|
n@34
|
473 var trackSliderObj = document.createElement('div');
|
n@34
|
474 trackSliderObj.className = 'track-slider';
|
n@34
|
475 trackSliderObj.id = 'track-slider-'+index;
|
n@34
|
476 // Distribute it randomnly
|
n@34
|
477 var w = window.innerWidth - 100;
|
n@34
|
478 w = Math.random()*w;
|
n@34
|
479 trackSliderObj.style.left = Math.floor(w)+50+'px';
|
n@34
|
480 trackSliderObj.innerHTML = '<span>'+index+'</span>';
|
n@34
|
481 trackSliderObj.draggable = true;
|
n@34
|
482 trackSliderObj.ondragend = dragEnd;
|
n@49
|
483 trackSliderObj.ondragstart = function()
|
n@49
|
484 {
|
n@49
|
485 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
|
n@49
|
486 audioEngineContext.metric.sliderMoveStart(id);
|
n@49
|
487 };
|
n@34
|
488
|
n@34
|
489 // Onclick, switch playback to that track
|
n@34
|
490 trackSliderObj.onclick = function() {
|
n@34
|
491 // Get the track ID from the object ID
|
n@34
|
492 var id = Number(this.id.substr(13,2)); // Maximum theoretical tracks is 99!
|
n@49
|
493 audioEngineContext.metric.sliderPlayed(id);
|
n@34
|
494 audioEngineContext.selectedTrack(id);
|
n@34
|
495 };
|
n@34
|
496
|
n@34
|
497 canvas.appendChild(trackSliderObj);
|
n@34
|
498 });
|
n@39
|
499
|
nicholas@65
|
500 // Append any commentQuestion boxes
|
nicholas@65
|
501 var commentQuestions = $(textXML).find('CommentQuestion');
|
nicholas@65
|
502 $(commentQuestions).each(function(index,element) {
|
nicholas@65
|
503 // Create document objects to hold the comment boxes
|
nicholas@65
|
504 var trackComment = document.createElement('div');
|
nicholas@65
|
505 trackComment.className = 'comment-div commentQuestion';
|
nicholas@65
|
506 trackComment.id = element.attributes['id'].value;
|
nicholas@65
|
507 // Create a string next to each comment asking for a comment
|
nicholas@65
|
508 var trackString = document.createElement('span');
|
nicholas@65
|
509 trackString.innerHTML = element.textContent;
|
nicholas@65
|
510 // Create the HTML5 comment box 'textarea'
|
nicholas@65
|
511 var trackCommentBox = document.createElement('textarea');
|
nicholas@65
|
512 trackCommentBox.rows = '4';
|
nicholas@65
|
513 trackCommentBox.cols = '100';
|
nicholas@65
|
514 trackCommentBox.name = 'commentQuestion'+index;
|
nicholas@65
|
515 trackCommentBox.className = 'trackComment';
|
nicholas@65
|
516 var br = document.createElement('br');
|
nicholas@65
|
517 // Add to the holder.
|
nicholas@65
|
518 trackComment.appendChild(trackString);
|
nicholas@65
|
519 trackComment.appendChild(br);
|
nicholas@65
|
520 trackComment.appendChild(trackCommentBox);
|
nicholas@65
|
521 feedbackHolder.appendChild(trackComment);
|
nicholas@65
|
522 });
|
nicholas@65
|
523
|
n@39
|
524 // Now process any pre-test commands
|
n@39
|
525
|
n@44
|
526 var preTest = $(testXMLSetups[id]).find('PreTest')[0];
|
n@39
|
527 if (preTest.children.length > 0)
|
n@39
|
528 {
|
n@39
|
529 currentState = 'testRunPre-'+id;
|
n@39
|
530 preTestPopupStart(preTest);
|
n@39
|
531 showPopup();
|
n@39
|
532 } else {
|
n@39
|
533 currentState = 'testRun-'+id;
|
n@39
|
534 }
|
n@39
|
535 }
|
n@39
|
536
|
n@39
|
537 function preTestPopupStart(preTest)
|
n@39
|
538 {
|
n@39
|
539 var popupHolder = document.getElementById('popupHolder');
|
n@39
|
540 popupHolder.innerHTML = null;
|
n@39
|
541 // Parse the first box
|
n@39
|
542 var preTestOption = document.createElement('div');
|
n@39
|
543 preTestOption.id = 'preTest';
|
n@39
|
544 preTestOption.style.marginTop = '25px';
|
n@39
|
545 preTestOption.align = "center";
|
n@39
|
546 var child = preTest.children[0];
|
n@39
|
547 if (child.nodeName == 'statement')
|
n@39
|
548 {
|
n@39
|
549 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
|
n@39
|
550 } else if (child.nodeName == 'question')
|
n@39
|
551 {
|
n@39
|
552 var questionId = child.attributes['id'].value;
|
n@39
|
553 var textHold = document.createElement('span');
|
n@39
|
554 textHold.innerHTML = child.innerHTML;
|
n@39
|
555 textHold.id = questionId + 'response';
|
n@39
|
556 var textEnter = document.createElement('textarea');
|
n@39
|
557 preTestOption.appendChild(textHold);
|
n@39
|
558 preTestOption.appendChild(textEnter);
|
n@39
|
559 }
|
n@39
|
560 var nextButton = document.createElement('button');
|
n@39
|
561 nextButton.className = 'popupButton';
|
n@39
|
562 nextButton.value = '0';
|
n@39
|
563 nextButton.innerHTML = 'Next';
|
n@39
|
564 nextButton.onclick = popupButtonClick;
|
n@39
|
565
|
n@39
|
566 popupHolder.appendChild(preTestOption);
|
n@39
|
567 popupHolder.appendChild(nextButton);
|
n@34
|
568 }
|
n@34
|
569
|
n@38
|
570 function popupButtonClick()
|
n@38
|
571 {
|
n@38
|
572 // Global call from the 'Next' button click
|
n@38
|
573 if (currentState == 'preTest')
|
n@38
|
574 {
|
n@38
|
575 // At the start of the preTest routine!
|
n@39
|
576 var xmlTree = projectXML.find('setup');
|
n@39
|
577 var preTest = xmlTree.find('PreTest')[0];
|
n@39
|
578 this.value = preTestButtonClick(preTest,this.value);
|
n@39
|
579 } else if (currentState.substr(0,10) == 'testRunPre')
|
n@39
|
580 {
|
n@39
|
581 //Specific test pre-test
|
n@39
|
582 var testId = currentState.substr(11,currentState.length-10);
|
n@44
|
583 var preTest = $(testXMLSetups[testId]).find('PreTest')[0];
|
n@39
|
584 this.value = preTestButtonClick(preTest,this.value);
|
n@42
|
585 } else if (currentState.substr(0,11) == 'testRunPost')
|
n@42
|
586 {
|
n@42
|
587 // Specific test post-test
|
n@42
|
588 var testId = currentState.substr(12,currentState.length-11);
|
n@44
|
589 var preTest = $(testXMLSetups[testId]).find('PostTest')[0];
|
n@42
|
590 this.value = preTestButtonClick(preTest,this.value);
|
n@41
|
591 } else if (currentState == 'postTest')
|
n@41
|
592 {
|
n@41
|
593 // At the end of the test, running global post test
|
n@41
|
594 var xmlTree = projectXML.find('setup');
|
n@41
|
595 var PostTest = xmlTree.find('PostTest')[0];
|
n@41
|
596 this.value = preTestButtonClick(PostTest,this.value);
|
n@38
|
597 }
|
n@38
|
598 }
|
n@38
|
599
|
n@39
|
600 function preTestButtonClick(preTest,index)
|
n@34
|
601 {
|
n@34
|
602 // Called on click of pre-test button
|
n@36
|
603 // Need to find and parse preTest again!
|
n@36
|
604 var preTestOption = document.getElementById('preTest');
|
n@36
|
605 // Check if current state is a question!
|
n@38
|
606 if (preTest.children[index].nodeName == 'question') {
|
n@38
|
607 var questionId = preTest.children[index].attributes['id'].value;
|
n@36
|
608 var questionHold = document.createElement('comment');
|
n@36
|
609 var questionResponse = document.getElementById(questionId + 'response');
|
nicholas@64
|
610 var mandatory = preTest.children[index].attributes['mandatory'];
|
nicholas@64
|
611 if (mandatory != undefined){
|
nicholas@64
|
612 if (mandatory.value == 'true') {mandatory = true;}
|
nicholas@64
|
613 else {mandatory = false;}
|
nicholas@64
|
614 } else {mandatory = false;}
|
nicholas@64
|
615 if (mandatory == true && questionResponse.value.length == 0) {
|
nicholas@64
|
616 return index;
|
nicholas@64
|
617 }
|
n@36
|
618 questionHold.id = questionId;
|
n@36
|
619 questionHold.innerHTML = questionResponse.value;
|
n@46
|
620 postPopupResponse(questionHold);
|
n@36
|
621 }
|
n@38
|
622 index++;
|
n@38
|
623 if (index < preTest.children.length)
|
n@36
|
624 {
|
n@36
|
625 // More to process
|
n@38
|
626 var child = preTest.children[index];
|
n@36
|
627 if (child.nodeName == 'statement')
|
n@36
|
628 {
|
n@36
|
629 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
|
n@36
|
630 } else if (child.nodeName == 'question')
|
n@36
|
631 {
|
n@36
|
632 var textHold = document.createElement('span');
|
n@36
|
633 textHold.innerHTML = child.innerHTML;
|
n@36
|
634 var textEnter = document.createElement('textarea');
|
n@36
|
635 textEnter.id = child.attributes['id'].value + 'response';
|
n@36
|
636 var br = document.createElement('br');
|
n@36
|
637 preTestOption.innerHTML = null;
|
n@36
|
638 preTestOption.appendChild(textHold);
|
n@36
|
639 preTestOption.appendChild(br);
|
n@36
|
640 preTestOption.appendChild(textEnter);
|
n@36
|
641 }
|
n@36
|
642 } else {
|
n@36
|
643 // Time to clear
|
n@37
|
644 preTestOption.innerHTML = null;
|
n@43
|
645 if (currentState != 'postTest') {
|
n@43
|
646 hidePopup();
|
n@43
|
647 // Progress the state!
|
n@43
|
648 advanceState();
|
n@43
|
649 } else {
|
n@43
|
650 a = createProjectSave(projectReturn);
|
n@43
|
651 preTestOption.appendChild(a);
|
n@43
|
652 }
|
n@36
|
653 }
|
n@38
|
654 return index;
|
n@36
|
655 }
|
n@36
|
656
|
n@46
|
657 function postPopupResponse(response)
|
n@46
|
658 {
|
n@46
|
659 if (currentState == 'preTest') {
|
n@46
|
660 preTestQuestions.appendChild(response);
|
n@46
|
661 } else if (currentState == 'postTest') {
|
n@46
|
662 postTestQuestions.appendChild(response);
|
n@46
|
663 } else {
|
n@46
|
664 // Inside a specific test
|
n@46
|
665 if (currentState.substr(0,10) == 'testRunPre') {
|
n@46
|
666 // Pre Test
|
n@46
|
667 var store = $(currentTestHolder).find('preTest');
|
n@46
|
668 } else {
|
n@46
|
669 // Post Test
|
n@46
|
670 var store = $(currentTestHolder).find('postTest');
|
n@46
|
671 }
|
n@46
|
672 store[0].appendChild(response);
|
n@46
|
673 }
|
n@46
|
674 }
|
n@46
|
675
|
n@36
|
676 function showPopup()
|
n@36
|
677 {
|
n@37
|
678 var popupHolder = document.getElementById('popupHolder');
|
n@38
|
679 popupHolder.style.zIndex = 3;
|
n@37
|
680 popupHolder.style.visibility = 'visible';
|
n@37
|
681 var blank = document.getElementsByClassName('testHalt')[0];
|
n@37
|
682 blank.style.zIndex = 2;
|
n@37
|
683 blank.style.visibility = 'visible';
|
n@36
|
684 }
|
n@36
|
685
|
n@36
|
686 function hidePopup()
|
n@36
|
687 {
|
n@37
|
688 var popupHolder = document.getElementById('popupHolder');
|
n@37
|
689 popupHolder.style.zIndex = -1;
|
n@37
|
690 popupHolder.style.visibility = 'hidden';
|
n@37
|
691 var blank = document.getElementsByClassName('testHalt')[0];
|
n@37
|
692 blank.style.zIndex = -2;
|
n@37
|
693 blank.style.visibility = 'hidden';
|
n@34
|
694 }
|
n@34
|
695
|
nicholas@5
|
696 function dragEnd(ev) {
|
nicholas@5
|
697 // Function call when a div has been dropped
|
n@33
|
698 var slider = document.getElementById('slider');
|
n@51
|
699 var w = slider.style.width;
|
n@51
|
700 w = Number(w.substr(0,w.length-2));
|
n@51
|
701 var x = ev.x;
|
n@51
|
702 if (x >= 42 && x < w+42) {
|
n@51
|
703 this.style.left = (x)+'px';
|
nicholas@5
|
704 } else {
|
n@51
|
705 if (x<42) {
|
n@51
|
706 this.style.left = '42px';
|
nicholas@5
|
707 } else {
|
n@51
|
708 this.style.left = (w+42) + 'px';
|
nicholas@5
|
709 }
|
nicholas@5
|
710 }
|
n@49
|
711 audioEngineContext.metric.sliderMoved();
|
nicholas@5
|
712 }
|
nicholas@7
|
713
|
n@39
|
714 function advanceState()
|
n@39
|
715 {
|
n@39
|
716 console.log(currentState);
|
n@39
|
717 if (currentState == 'preTest')
|
n@39
|
718 {
|
n@39
|
719 // End of pre-test, begin the test
|
n@39
|
720 loadTest(0);
|
n@39
|
721 } else if (currentState.substr(0,10) == 'testRunPre')
|
n@39
|
722 {
|
n@39
|
723 // Start the test
|
n@39
|
724 var testId = currentState.substr(11,currentState.length-10);
|
n@39
|
725 currentState = 'testRun-'+testId;
|
n@42
|
726 } else if (currentState.substr(0,11) == 'testRunPost')
|
n@42
|
727 {
|
n@44
|
728 var testId = currentState.substr(12,currentState.length-11);
|
n@42
|
729 testEnded(testId);
|
n@40
|
730 } else if (currentState.substr(0,7) == 'testRun')
|
n@40
|
731 {
|
n@40
|
732 var testId = currentState.substr(8,currentState.length-7);
|
n@40
|
733 // Check if we have any post tests to perform
|
n@44
|
734 var postXML = $(testXMLSetups[testId]).find('PostTest')[0];
|
n@40
|
735 if (postXML.children.length > 0)
|
n@40
|
736 {
|
n@42
|
737 currentState = 'testRunPost-'+testId;
|
n@42
|
738 showPopup();
|
n@42
|
739 preTestPopupStart(postXML);
|
n@40
|
740 }
|
n@42
|
741 else {
|
n@40
|
742
|
n@40
|
743
|
n@42
|
744 // No post tests, check if we have another test to perform instead
|
n@42
|
745 testEnded(testId);
|
n@40
|
746 }
|
n@39
|
747 }
|
n@39
|
748 console.log(currentState);
|
n@39
|
749 }
|
n@39
|
750
|
n@42
|
751 function testEnded(testId)
|
n@42
|
752 {
|
n@45
|
753 pageXMLSave(testId);
|
n@42
|
754 if (testXMLSetups.length-1 > testId)
|
n@42
|
755 {
|
n@42
|
756 // Yes we have another test to perform
|
n@44
|
757 testId = (Number(testId)+1);
|
n@44
|
758 currentState = 'testRun-'+testId;
|
n@44
|
759 loadTest(testId);
|
n@42
|
760 } else {
|
n@42
|
761 console.log('Testing Completed!');
|
n@42
|
762 currentState = 'postTest';
|
n@42
|
763 // Check for any post tests
|
n@42
|
764 var xmlSetup = projectXML.find('setup');
|
n@42
|
765 var postTest = xmlSetup.find('PostTest')[0];
|
n@42
|
766 showPopup();
|
n@42
|
767 preTestPopupStart(postTest);
|
n@42
|
768 }
|
n@42
|
769 }
|
n@42
|
770
|
n@40
|
771 function buttonSubmitClick()
|
n@40
|
772 {
|
n@49
|
773 if (audioEngineContext.status == 1) {
|
n@49
|
774 var playback = document.getElementById('playback-button');
|
n@49
|
775 playback.click();
|
n@40
|
776 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
|
n@55
|
777 } else
|
n@55
|
778 {
|
n@55
|
779 if (audioEngineContext.timer.testStarted == false)
|
n@55
|
780 {
|
n@55
|
781 alert('You have not started the test! Please press start to begin the test!');
|
n@55
|
782 return;
|
n@55
|
783 }
|
n@49
|
784 }
|
n@40
|
785 if (currentState.substr(0,7) == 'testRun')
|
n@40
|
786 {
|
n@49
|
787 audioEngineContext.timer.stopTest();
|
n@40
|
788 advanceState();
|
n@40
|
789 }
|
n@40
|
790 }
|
n@40
|
791
|
n@51
|
792 function convSliderPosToRate(id)
|
n@51
|
793 {
|
n@51
|
794 var w = document.getElementById('slider').style.width;
|
n@51
|
795 var maxPix = w.substr(0,w.length-2);
|
n@51
|
796 var slider = document.getElementsByClassName('track-slider')[id];
|
n@51
|
797 var pix = slider.style.left;
|
n@51
|
798 pix = pix.substr(0,pix.length-2);
|
n@51
|
799 var rate = (pix-42)/maxPix;
|
n@51
|
800 return rate;
|
n@51
|
801 }
|
n@51
|
802
|
n@44
|
803 function pageXMLSave(testId)
|
n@44
|
804 {
|
n@44
|
805 // Saves a specific test page
|
n@46
|
806 var xmlDoc = currentTestHolder;
|
n@50
|
807 // Check if any session wide metrics are enabled
|
n@50
|
808 var metric = document.createElement('metric');
|
n@50
|
809 if (audioEngineContext.metric.enableTestTimer)
|
n@50
|
810 {
|
n@50
|
811 var testTime = document.createElement('metricResult');
|
n@50
|
812 testTime.id = 'testTime';
|
n@50
|
813 testTime.textContent = audioEngineContext.timer.testDuration;
|
n@50
|
814 metric.appendChild(testTime);
|
n@50
|
815 }
|
n@50
|
816 xmlDoc.appendChild(metric);
|
n@45
|
817 var trackSliderObjects = document.getElementsByClassName('track-slider');
|
n@45
|
818 var commentObjects = document.getElementsByClassName('comment-div');
|
n@45
|
819 for (var i=0; i<trackSliderObjects.length; i++)
|
n@45
|
820 {
|
n@45
|
821 var audioElement = document.createElement('audioElement');
|
n@45
|
822 audioElement.id = currentTrackOrder[i].attributes['id'].value;
|
n@45
|
823 audioElement.url = currentTrackOrder[i].attributes['url'].value;
|
n@51
|
824 var value = document.createElement('value');
|
n@51
|
825 value.innerHTML = convSliderPosToRate(i);
|
n@45
|
826 var comment = document.createElement("comment");
|
n@45
|
827 var question = document.createElement("question");
|
n@45
|
828 var response = document.createElement("response");
|
n@45
|
829 question.textContent = commentObjects[i].children[0].textContent;
|
n@45
|
830 response.textContent = commentObjects[i].children[2].value;
|
n@45
|
831 comment.appendChild(question);
|
n@45
|
832 comment.appendChild(response);
|
n@45
|
833 audioElement.appendChild(value);
|
n@45
|
834 audioElement.appendChild(comment);
|
n@50
|
835 // Check for any per element metrics
|
n@50
|
836 var metric = document.createElement('metric');
|
n@50
|
837 var elementMetric = audioEngineContext.audioObjects[i].metric;
|
n@50
|
838 if (audioEngineContext.metric.enableElementTimer) {
|
n@50
|
839 var elementTimer = document.createElement('metricResult');
|
n@50
|
840 elementTimer.id = 'elementTimer';
|
n@50
|
841 elementTimer.textContent = elementMetric.listenedTimer;
|
n@50
|
842 metric.appendChild(elementTimer);
|
n@50
|
843 }
|
n@50
|
844 if (audioEngineContext.metric.enableElementTracker) {
|
n@50
|
845 var elementTrackerFull = document.createElement('metricResult');
|
n@50
|
846 elementTrackerFull.id = 'elementTrackerFull';
|
n@50
|
847 var data = elementMetric.movementTracker;
|
n@50
|
848 for (var k=0; k<data.length; k++)
|
n@50
|
849 {
|
n@50
|
850 var timePos = document.createElement('timePos');
|
n@50
|
851 timePos.id = k;
|
n@50
|
852 var time = document.createElement('time');
|
n@50
|
853 time.textContent = data[k][0];
|
n@50
|
854 var position = document.createElement('position');
|
n@50
|
855 position.textContent = data[k][1];
|
n@50
|
856 timePos.appendChild(time);
|
n@50
|
857 timePos.appendChild(position);
|
n@50
|
858 elementTrackerFull.appendChild(timePos);
|
n@50
|
859 }
|
n@50
|
860 metric.appendChild(elementTrackerFull);
|
n@50
|
861 }
|
n@50
|
862 if (audioEngineContext.metric.enableElementInitialPosition) {
|
n@50
|
863 var elementInitial = document.createElement('metricResult');
|
n@50
|
864 elementInitial.id = 'elementInitialPosition';
|
n@50
|
865 elementInitial.textContent = elementMetric.initialPosition;
|
n@50
|
866 metric.appendChild(elementInitial);
|
n@50
|
867 }
|
n@50
|
868 if (audioEngineContext.metric.enableFlagListenedTo) {
|
n@50
|
869 var flagListenedTo = document.createElement('metricResult');
|
n@50
|
870 flagListenedTo.id = 'elementFlagListenedTo';
|
n@50
|
871 flagListenedTo.textContent = elementMetric.wasListenedTo;
|
n@50
|
872 metric.appendChild(flagListenedTo);
|
n@50
|
873 }
|
n@50
|
874 if (audioEngineContext.metric.enableFlagMoved) {
|
n@50
|
875 var flagMoved = document.createElement('metricResult');
|
n@50
|
876 flagMoved.id = 'elementFlagMoved';
|
n@50
|
877 flagMoved.textContent = elementMetric.wasMoved;
|
n@50
|
878 metric.appendChild(flagMoved);
|
n@50
|
879 }
|
n@50
|
880 if (audioEngineContext.metric.enableFlagComments) {
|
n@50
|
881 var flagComments = document.createElement('metricResult');
|
n@50
|
882 flagComments.id = 'elementFlagComments';
|
n@50
|
883 if (response.textContent.length == 0) {flag.textContent = 'false';}
|
n@50
|
884 else {flag.textContet = 'true';}
|
n@50
|
885 metric.appendChild(flagComments);
|
n@50
|
886 }
|
n@50
|
887 audioElement.appendChild(metric);
|
n@45
|
888 xmlDoc.appendChild(audioElement);
|
n@45
|
889 }
|
nicholas@65
|
890 var commentQuestion = document.getElementsByClassName('commentQuestion');
|
nicholas@65
|
891 for (var i=0; i<commentQuestion.length; i++)
|
nicholas@65
|
892 {
|
nicholas@65
|
893 var cqHolder = document.createElement('CommentQuestion');
|
nicholas@65
|
894 var comment = document.createElement('comment');
|
nicholas@65
|
895 var question = document.createElement('question');
|
nicholas@65
|
896 cqHolder.id = commentQuestion[i].id;
|
nicholas@65
|
897 comment.textContent = commentQuestion[i].children[2].value;
|
nicholas@65
|
898 question.textContent = commentQuestion[i].children[0].textContent;
|
nicholas@65
|
899 cqHolder.appendChild(question);
|
nicholas@65
|
900 cqHolder.appendChild(comment);
|
nicholas@65
|
901 xmlDoc.appendChild(cqHolder);
|
nicholas@65
|
902 }
|
n@45
|
903 testResultsHolders[testId] = xmlDoc;
|
n@44
|
904 }
|
n@44
|
905
|
nicholas@7
|
906 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
|
nicholas@7
|
907 function interfaceXMLSave(){
|
nicholas@7
|
908 // Create the XML string to be exported with results
|
nicholas@7
|
909 var xmlDoc = document.createElement("BrowserEvaluationResult");
|
n@45
|
910 for (var i=0; i<testResultsHolders.length; i++)
|
nicholas@7
|
911 {
|
n@45
|
912 xmlDoc.appendChild(testResultsHolders[i]);
|
nicholas@7
|
913 }
|
n@23
|
914 // Append Pre/Post Questions
|
n@23
|
915 xmlDoc.appendChild(preTestQuestions);
|
n@23
|
916 xmlDoc.appendChild(postTestQuestions);
|
n@23
|
917
|
nicholas@7
|
918 return xmlDoc;
|
nicholas@7
|
919 }
|
nicholas@7
|
920
|