Mercurial > hg > webaudioevaluationtool
comparison ape.js @ 706:542c613e31d6
Added start of preTest sections. Need to refine linking from inputs to results
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 09 Apr 2015 10:10:21 +0100 |
parents | 375410a5571d |
children | f5de8699e2b6 |
comparison
equal
deleted
inserted
replaced
705:f38946647666 | 706:542c613e31d6 |
---|---|
15 // Set background to grey #ddd | 15 // Set background to grey #ddd |
16 document.getElementsByTagName('body')[0].style.backgroundColor = '#ddd'; | 16 document.getElementsByTagName('body')[0].style.backgroundColor = '#ddd'; |
17 | 17 |
18 // The injection point into the HTML page | 18 // The injection point into the HTML page |
19 var insertPoint = document.getElementById("topLevelBody"); | 19 var insertPoint = document.getElementById("topLevelBody"); |
20 var testContent = document.createElement('div'); | |
21 testContent.id = 'testContent'; | |
20 | 22 |
21 | 23 |
22 // Decode parts of the xmlDoc that are needed | 24 // Decode parts of the xmlDoc that are needed |
23 // xmlDoc MUST already be parsed by jQuery! | 25 // xmlDoc MUST already be parsed by jQuery! |
24 var xmlSetup = xmlDoc.find('setup'); | 26 var xmlSetup = xmlDoc.find('setup'); |
175 | 177 |
176 canvas.appendChild(trackSliderObj); | 178 canvas.appendChild(trackSliderObj); |
177 }); | 179 }); |
178 | 180 |
179 | 181 |
182 // Create pre and post test questions | |
183 | |
180 // Inject into HTML | 184 // Inject into HTML |
181 insertPoint.innerHTML = null; // Clear the current schema | 185 insertPoint.innerHTML = null; // Clear the current schema |
182 insertPoint.appendChild(title); // Insert the title | 186 testContent.appendChild(title); // Insert the title |
183 insertPoint.appendChild(interfaceButtons); | 187 testContent.appendChild(interfaceButtons); |
184 insertPoint.appendChild(sliderBox); | 188 testContent.appendChild(sliderBox); |
185 insertPoint.appendChild(feedbackHolder); | 189 testContent.appendChild(feedbackHolder); |
190 insertPoint.appendChild(testContent); | |
191 | |
192 var preTest = xmlDoc.find('PreTest'); | |
193 var postTest = xmlDoc.find('PostTest'); | |
194 preTest = preTest[0]; | |
195 postTest = postTest[0]; | |
196 if (preTest != undefined || postTest != undefined) | |
197 { | |
198 testContent.style.zIndex = 1; | |
199 var blank = document.createElement('div'); | |
200 blank.id = 'testHalt'; | |
201 blank.style.zIndex = 2; | |
202 blank.style.width = window.innerWidth + 'px'; | |
203 blank.style.height = window.innerHeight + 'px'; | |
204 blank.style.position = 'absolute'; | |
205 blank.style.top = '0'; | |
206 blank.style.left = '0'; | |
207 insertPoint.appendChild(blank); | |
208 } | |
209 | |
210 // Create Pre-Test Box | |
211 if (preTest != undefined && preTest.children.length >= 1) | |
212 { | |
213 | |
214 var preTestHolder = document.createElement('div'); | |
215 preTestHolder.id = 'preTestHolder'; | |
216 preTestHolder.style.zIndex = 2; | |
217 preTestHolder.style.width = '500px'; | |
218 preTestHolder.style.height = '250px'; | |
219 preTestHolder.style.backgroundColor = '#fff'; | |
220 preTestHolder.style.position = 'absolute'; | |
221 preTestHolder.style.left = (window.innerWidth/2)-250 + 'px'; | |
222 preTestHolder.style.top = (window.innerHeight/2)-125 + 'px'; | |
223 // Parse the first box | |
224 var preTestOption = document.createElement('div'); | |
225 preTestOption.id = 'preTest'; | |
226 preTestOption.style.marginTop = '25px'; | |
227 preTestOption.align = "center"; | |
228 var child = preTest.children[0]; | |
229 if (child.nodeName == 'statement') | |
230 { | |
231 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; | |
232 } else if (child.nodeName == 'question') | |
233 { | |
234 var textHold = document.createElement('span'); | |
235 textHold.innerHTML = child.innerHTML; | |
236 var textEnter = document.createElement('textarea'); | |
237 preTestOption.appendChild(textHold); | |
238 preTestOption.appendChild(textEnter); | |
239 } | |
240 var nextButton = document.createElement('button'); | |
241 nextButton.id = 'preTestNext'; | |
242 nextButton.value = '1'; | |
243 nextButton.innerHTML = 'next'; | |
244 nextButton.style.position = 'relative'; | |
245 nextButton.style.left = '450px'; | |
246 nextButton.style.top = '175px'; | |
247 nextButton.onclick = function() { | |
248 // Need to find and parse preTest again! | |
249 var preTest = projectXML.find('PreTest')[0]; | |
250 if (this.value < preTest.children.length) | |
251 { | |
252 // More to process | |
253 var child = preTest.children[this.value]; | |
254 if (child.nodeName == 'statement') | |
255 { | |
256 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; | |
257 } else if (child.nodeName == 'question') | |
258 { | |
259 var textHold = document.createElement('span'); | |
260 textHold.innerHTML = child.innerHTML; | |
261 var textEnter = document.createElement('textarea'); | |
262 preTestOption.innerHTML = 'null'; | |
263 preTestOption.appendChild(textHold); | |
264 preTestOption.appendChild(textEnter); | |
265 } | |
266 } else { | |
267 // Time to clear | |
268 preTestHolder.style.zIndex = -1; | |
269 preTestHolder.style.visibility = 'hidden'; | |
270 var blank = document.getElementById('testHalt'); | |
271 blank.style.zIndex = -2; | |
272 blank.style.visibility = 'hidden'; | |
273 } | |
274 this.value++; | |
275 }; | |
276 | |
277 preTestHolder.appendChild(preTestOption); | |
278 preTestHolder.appendChild(nextButton); | |
279 insertPoint.appendChild(preTestHolder); | |
280 } | |
281 | |
186 } | 282 } |
187 | 283 |
188 function dragEnd(ev) { | 284 function dragEnd(ev) { |
189 // Function call when a div has been dropped | 285 // Function call when a div has been dropped |
190 if (ev.x >= 50 && ev.x < window.innerWidth-50) { | 286 if (ev.x >= 50 && ev.x < window.innerWidth-50) { |