Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 39:6653aaec3650 Dev_main
Completed Pre-Test of global test and page tests
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Fri, 10 Apr 2015 14:52:39 +0100 |
parents | 8894d17cfad7 |
children | ee5ae5902574 |
comparison
equal
deleted
inserted
replaced
38:8894d17cfad7 | 39:6653aaec3650 |
---|---|
144 | 144 |
145 // Create Pre-Test Box | 145 // Create Pre-Test Box |
146 if (preTest != undefined && preTest.children.length >= 1) | 146 if (preTest != undefined && preTest.children.length >= 1) |
147 { | 147 { |
148 showPopup(); | 148 showPopup(); |
149 | 149 preTestPopupStart(preTest); |
150 // Parse the first box | |
151 var preTestOption = document.createElement('div'); | |
152 preTestOption.id = 'preTest'; | |
153 preTestOption.style.marginTop = '25px'; | |
154 preTestOption.align = "center"; | |
155 var child = preTest.children[0]; | |
156 if (child.nodeName == 'statement') | |
157 { | |
158 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; | |
159 } else if (child.nodeName == 'question') | |
160 { | |
161 var questionId = child.attributes['id'].value; | |
162 var textHold = document.createElement('span'); | |
163 textHold.innerHTML = child.innerHTML; | |
164 textHold.id = questionId + 'response'; | |
165 var textEnter = document.createElement('textarea'); | |
166 preTestOption.appendChild(textHold); | |
167 preTestOption.appendChild(textEnter); | |
168 } | |
169 var nextButton = document.createElement('button'); | |
170 nextButton.className = 'popupButton'; | |
171 nextButton.value = '0'; | |
172 nextButton.innerHTML = 'Next'; | |
173 nextButton.onclick = popupButtonClick; | |
174 | |
175 popupHolder.appendChild(preTestOption); | |
176 popupHolder.appendChild(nextButton); | |
177 } | 150 } |
178 | 151 |
179 // Inject into HTML | 152 // Inject into HTML |
180 testContent.appendChild(title); // Insert the title | 153 testContent.appendChild(title); // Insert the title |
181 testContent.appendChild(interfaceButtons); | 154 testContent.appendChild(interfaceButtons); |
182 testContent.appendChild(sliderBox); | 155 testContent.appendChild(sliderBox); |
183 testContent.appendChild(feedbackHolder); | 156 testContent.appendChild(feedbackHolder); |
184 insertPoint.appendChild(testContent); | 157 insertPoint.appendChild(testContent); |
185 | 158 |
186 // Load the full interface | 159 // Load the full interface |
187 loadTest(testXMLSetups[0]); | 160 |
188 } | 161 } |
189 | 162 |
190 function loadTest(textXML) | 163 function loadTest(id) |
191 { | 164 { |
192 // Used to load a specific test page | 165 // Used to load a specific test page |
193 | 166 var textXML = testXMLSetups[id]; |
194 | 167 |
195 var feedbackHolder = document.getElementById('feedbackHolder'); | 168 var feedbackHolder = document.getElementById('feedbackHolder'); |
196 var canvas = document.getElementById('slider'); | 169 var canvas = document.getElementById('slider'); |
197 feedbackHolder.innerHTML = null; | 170 feedbackHolder.innerHTML = null; |
198 canvas.innerHTML = null; | 171 canvas.innerHTML = null; |
266 audioEngineContext.selectedTrack(id); | 239 audioEngineContext.selectedTrack(id); |
267 }; | 240 }; |
268 | 241 |
269 canvas.appendChild(trackSliderObj); | 242 canvas.appendChild(trackSliderObj); |
270 }); | 243 }); |
244 | |
245 // Now process any pre-test commands | |
246 | |
247 var preTest = testXMLSetups.find('PreTest')[0]; | |
248 if (preTest.children.length > 0) | |
249 { | |
250 currentState = 'testRunPre-'+id; | |
251 preTestPopupStart(preTest); | |
252 showPopup(); | |
253 } else { | |
254 currentState = 'testRun-'+id; | |
255 } | |
256 } | |
257 | |
258 function preTestPopupStart(preTest) | |
259 { | |
260 var popupHolder = document.getElementById('popupHolder'); | |
261 popupHolder.innerHTML = null; | |
262 // Parse the first box | |
263 var preTestOption = document.createElement('div'); | |
264 preTestOption.id = 'preTest'; | |
265 preTestOption.style.marginTop = '25px'; | |
266 preTestOption.align = "center"; | |
267 var child = preTest.children[0]; | |
268 if (child.nodeName == 'statement') | |
269 { | |
270 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; | |
271 } else if (child.nodeName == 'question') | |
272 { | |
273 var questionId = child.attributes['id'].value; | |
274 var textHold = document.createElement('span'); | |
275 textHold.innerHTML = child.innerHTML; | |
276 textHold.id = questionId + 'response'; | |
277 var textEnter = document.createElement('textarea'); | |
278 preTestOption.appendChild(textHold); | |
279 preTestOption.appendChild(textEnter); | |
280 } | |
281 var nextButton = document.createElement('button'); | |
282 nextButton.className = 'popupButton'; | |
283 nextButton.value = '0'; | |
284 nextButton.innerHTML = 'Next'; | |
285 nextButton.onclick = popupButtonClick; | |
286 | |
287 popupHolder.appendChild(preTestOption); | |
288 popupHolder.appendChild(nextButton); | |
271 } | 289 } |
272 | 290 |
273 function popupButtonClick() | 291 function popupButtonClick() |
274 { | 292 { |
275 // Global call from the 'Next' button click | 293 // Global call from the 'Next' button click |
276 if (currentState == 'preTest') | 294 if (currentState == 'preTest') |
277 { | 295 { |
278 // At the start of the preTest routine! | 296 // At the start of the preTest routine! |
279 this.value = preTestButtonClick(this.value); | 297 var xmlTree = projectXML.find('setup'); |
280 } | 298 var preTest = xmlTree.find('PreTest')[0]; |
281 } | 299 this.value = preTestButtonClick(preTest,this.value); |
282 | 300 } else if (currentState.substr(0,10) == 'testRunPre') |
283 function preTestButtonClick(index) | 301 { |
302 //Specific test pre-test | |
303 var testId = currentState.substr(11,currentState.length-10); | |
304 var preTest = testXMLSetups.find('PreTest')[testId]; | |
305 this.value = preTestButtonClick(preTest,this.value); | |
306 } | |
307 } | |
308 | |
309 function preTestButtonClick(preTest,index) | |
284 { | 310 { |
285 // Called on click of pre-test button | 311 // Called on click of pre-test button |
286 // Need to find and parse preTest again! | 312 // Need to find and parse preTest again! |
287 var xmlSetup = projectXML.find('setup'); | |
288 var preTest = xmlSetup.find('PreTest')[0]; | |
289 var preTestOption = document.getElementById('preTest'); | 313 var preTestOption = document.getElementById('preTest'); |
290 // Check if current state is a question! | 314 // Check if current state is a question! |
291 if (preTest.children[index].nodeName == 'question') { | 315 if (preTest.children[index].nodeName == 'question') { |
292 var questionId = preTest.children[index].attributes['id'].value; | 316 var questionId = preTest.children[index].attributes['id'].value; |
293 var questionHold = document.createElement('comment'); | 317 var questionHold = document.createElement('comment'); |
319 } else { | 343 } else { |
320 // Time to clear | 344 // Time to clear |
321 preTestOption.innerHTML = null; | 345 preTestOption.innerHTML = null; |
322 hidePopup(); | 346 hidePopup(); |
323 // Progress the state! | 347 // Progress the state! |
348 advanceState(); | |
324 } | 349 } |
325 return index; | 350 return index; |
326 } | 351 } |
327 | 352 |
328 function showPopup() | 353 function showPopup() |
355 this.style.left = '50px'; | 380 this.style.left = '50px'; |
356 } else { | 381 } else { |
357 this.style.left = window.innerWidth-50 + 'px'; | 382 this.style.left = window.innerWidth-50 + 'px'; |
358 } | 383 } |
359 } | 384 } |
385 } | |
386 | |
387 function advanceState() | |
388 { | |
389 console.log(currentState); | |
390 if (currentState == 'preTest') | |
391 { | |
392 // End of pre-test, begin the test | |
393 loadTest(0); | |
394 } else if (currentState.substr(0,10) == 'testRunPre') | |
395 { | |
396 // Start the test | |
397 var testId = currentState.substr(11,currentState.length-10); | |
398 currentState = 'testRun-'+testId; | |
399 } | |
400 console.log(currentState); | |
360 } | 401 } |
361 | 402 |
362 // Only other global function which must be defined in the interface class. Determines how to create the XML document. | 403 // Only other global function which must be defined in the interface class. Determines how to create the XML document. |
363 function interfaceXMLSave(){ | 404 function interfaceXMLSave(){ |
364 // Create the XML string to be exported with results | 405 // Create the XML string to be exported with results |