comparison ape.js @ 176:9eda81aa9fe0 Dev_main

Moved non interface specific code from loadInterface in ape.js to core.js
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 04 Jun 2015 10:43:06 +0100
parents b19712875046
children 25c296b254f8
comparison
equal deleted inserted replaced
175:fe2b350c2fbd 176:9eda81aa9fe0
28 28
29 // Decode parts of the xmlDoc that are needed 29 // Decode parts of the xmlDoc that are needed
30 // xmlDoc MUST already be parsed by jQuery! 30 // xmlDoc MUST already be parsed by jQuery!
31 var xmlSetup = xmlDoc.find('setup'); 31 var xmlSetup = xmlDoc.find('setup');
32 // Should put in an error function here incase of malprocessed or malformed XML 32 // Should put in an error function here incase of malprocessed or malformed XML
33 33
34 // Create pre and post test questions
35
36 var preTest = xmlSetup.find('PreTest');
37 var postTest = xmlSetup.find('PostTest');
38 preTest = preTest[0];
39 postTest = postTest[0];
40
41 if (preTest == undefined) {preTest = document.createElement("preTest");}
42 if (postTest == undefined){postTest= document.createElement("postTest");}
43
44 testState.stateMap.push(preTest);
45
46 // Extract the different test XML DOM trees
47 var audioHolders = xmlDoc.find('audioHolder');
48 var testXMLSetups = [];
49 audioHolders.each(function(index,element) {
50 var repeatN = element.attributes['repeatCount'].value;
51 for (var r=0; r<=repeatN; r++) {
52 testXMLSetups.push(element);
53 }
54 });
55
56 // New check if we need to randomise the test order
57 var randomise = xmlSetup[0].attributes['randomiseOrder'];
58 if (randomise != undefined) {
59 if (randomise.value === 'true'){
60 randomise = true;
61 } else {
62 randomise = false;
63 }
64 } else {
65 randomise = false;
66 }
67
68 if (randomise)
69 {
70 testXMLSetups = randomiseOrder(testXMLSetups);
71 }
72
73 $(testXMLSetups).each(function(index,elem){
74 testState.stateMap.push(elem);
75 })
76
77 testState.stateMap.push(postTest);
78
79 // Obtain the metrics enabled
80 var metricNode = xmlSetup.find('Metric');
81 var metricNode = metricNode.find('metricEnable');
82 metricNode.each(function(index,node){
83 var enabled = node.textContent;
84 switch(enabled)
85 {
86 case 'testTimer':
87 sessionMetrics.prototype.enableTestTimer = true;
88 break;
89 case 'elementTimer':
90 sessionMetrics.prototype.enableElementTimer = true;
91 break;
92 case 'elementTracker':
93 sessionMetrics.prototype.enableElementTracker = true;
94 break;
95 case 'elementListenTracker':
96 sessionMetrics.prototype.enableElementListenTracker = true;
97 break;
98 case 'elementInitialPosition':
99 sessionMetrics.prototype.enableElementInitialPosition = true;
100 break;
101 case 'elementFlagListenedTo':
102 sessionMetrics.prototype.enableFlagListenedTo = true;
103 break;
104 case 'elementFlagMoved':
105 sessionMetrics.prototype.enableFlagMoved = true;
106 break;
107 case 'elementFlagComments':
108 sessionMetrics.prototype.enableFlagComments = true;
109 break;
110 }
111 });
112 34
113 // Create APE specific metric functions 35 // Create APE specific metric functions
114 audioEngineContext.metric.initialiseTest = function() 36 audioEngineContext.metric.initialiseTest = function()
115 { 37 {
116 }; 38 };
253 var feedbackHolder = document.createElement('div'); 175 var feedbackHolder = document.createElement('div');
254 feedbackHolder.id = 'feedbackHolder'; 176 feedbackHolder.id = 'feedbackHolder';
255 177
256 testContent.style.zIndex = 1; 178 testContent.style.zIndex = 1;
257 insertPoint.innerHTML = null; // Clear the current schema 179 insertPoint.innerHTML = null; // Clear the current schema
258
259 currentState = 'preTest';
260 180
261 // Inject into HTML 181 // Inject into HTML
262 testContent.appendChild(title); // Insert the title 182 testContent.appendChild(title); // Insert the title
263 testContent.appendChild(pagetitle); 183 testContent.appendChild(pagetitle);
264 testContent.appendChild(interfaceButtons); 184 testContent.appendChild(interfaceButtons);