comparison ape.js @ 36:d848d24fdb7c Dev_main

Shuffled project.xml so metrics and pre/post are part of setup tag. Split pre-post button interface to separate functions
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 10 Apr 2015 12:48:07 +0100
parents 8fdb7c1af7d9
children 8a78c6d38c5f
comparison
equal deleted inserted replaced
35:5bc6e6fd2e36 36:d848d24fdb7c
119 testContent.appendChild(interfaceButtons); 119 testContent.appendChild(interfaceButtons);
120 testContent.appendChild(sliderBox); 120 testContent.appendChild(sliderBox);
121 testContent.appendChild(feedbackHolder); 121 testContent.appendChild(feedbackHolder);
122 insertPoint.appendChild(testContent); 122 insertPoint.appendChild(testContent);
123 123
124 loadTest(testXMLSetups[0]); 124 var preTest = xmlSetup.find('PreTest');
125 125 var postTest = xmlSetup.find('PostTest');
126 var preTest = xmlDoc.find('PreTest');
127 var postTest = xmlDoc.find('PostTest');
128 preTest = preTest[0]; 126 preTest = preTest[0];
129 postTest = postTest[0]; 127 postTest = postTest[0];
130 if (preTest != undefined || postTest != undefined) 128 if (preTest != undefined || postTest != undefined)
131 { 129 {
132 testContent.style.zIndex = 1; 130 testContent.style.zIndex = 1;
164 preTestOption.appendChild(textHold); 162 preTestOption.appendChild(textHold);
165 preTestOption.appendChild(textEnter); 163 preTestOption.appendChild(textEnter);
166 } 164 }
167 var nextButton = document.createElement('button'); 165 var nextButton = document.createElement('button');
168 nextButton.id = 'preTestNext'; 166 nextButton.id = 'preTestNext';
169 nextButton.value = '1'; 167 nextButton.value = '0';
170 nextButton.innerHTML = 'Next'; 168 nextButton.innerHTML = 'Next';
171 nextButton.onclick = function() { 169 nextButton.onclick = preTestButtonClick;
172 // Need to find and parse preTest again!
173 var preTest = projectXML.find('PreTest')[0];
174 // Check if current state is a question!
175 if (preTest.children[this.value-1].nodeName == 'question') {
176 var questionId = preTest.children[this.value-1].attributes['id'].value;
177 var questionHold = document.createElement('comment');
178 var questionResponse = document.getElementById(questionId + 'response');
179 questionHold.id = questionId;
180 questionHold.innerHTML = questionResponse.value;
181 preTestQuestions.appendChild(questionHold);
182 }
183 if (this.value < preTest.children.length)
184 {
185 // More to process
186 var child = preTest.children[this.value];
187 if (child.nodeName == 'statement')
188 {
189 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
190 } else if (child.nodeName == 'question')
191 {
192 var textHold = document.createElement('span');
193 textHold.innerHTML = child.innerHTML;
194 var textEnter = document.createElement('textarea');
195 textEnter.id = child.attributes['id'].value + 'response';
196 var br = document.createElement('br');
197 preTestOption.innerHTML = null;
198 preTestOption.appendChild(textHold);
199 preTestOption.appendChild(br);
200 preTestOption.appendChild(textEnter);
201 }
202 } else {
203 // Time to clear
204 preTestHolder.style.zIndex = -1;
205 preTestHolder.style.visibility = 'hidden';
206 var blank = document.getElementsByClassName('testHalt')[0];
207 blank.style.zIndex = -2;
208 blank.style.visibility = 'hidden';
209 }
210 this.value++;
211 };
212 170
213 preTestHolder.appendChild(preTestOption); 171 preTestHolder.appendChild(preTestOption);
214 preTestHolder.appendChild(nextButton); 172 preTestHolder.appendChild(nextButton);
215 insertPoint.appendChild(preTestHolder); 173 insertPoint.appendChild(preTestHolder);
216 } 174 }
217 175
176 // Load the full interface
177 loadTest(testXMLSetups[0]);
218 } 178 }
219 179
220 function loadTest(textXML) 180 function loadTest(textXML)
221 { 181 {
222 // Used to load a specific test page 182 // Used to load a specific test page
300 } 260 }
301 261
302 function preTestButtonClick() 262 function preTestButtonClick()
303 { 263 {
304 // Called on click of pre-test button 264 // Called on click of pre-test button
265 // Need to find and parse preTest again!
266 var xmlSetup = projectXML.find('setup');
267 var preTest = xmlSetup.find('PreTest')[0];
268 var preTestOption = document.getElementById('preTest');
269 // Check if current state is a question!
270 if (preTest.children[this.value].nodeName == 'question') {
271 var questionId = preTest.children[this.value].attributes['id'].value;
272 var questionHold = document.createElement('comment');
273 var questionResponse = document.getElementById(questionId + 'response');
274 questionHold.id = questionId;
275 questionHold.innerHTML = questionResponse.value;
276 preTestQuestions.appendChild(questionHold);
277 }
278 this.value++;
279 if (this.value < preTest.children.length)
280 {
281 // More to process
282 var child = preTest.children[this.value];
283 if (child.nodeName == 'statement')
284 {
285 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
286 } else if (child.nodeName == 'question')
287 {
288 var textHold = document.createElement('span');
289 textHold.innerHTML = child.innerHTML;
290 var textEnter = document.createElement('textarea');
291 textEnter.id = child.attributes['id'].value + 'response';
292 var br = document.createElement('br');
293 preTestOption.innerHTML = null;
294 preTestOption.appendChild(textHold);
295 preTestOption.appendChild(br);
296 preTestOption.appendChild(textEnter);
297 }
298 } else {
299 // Time to clear
300 preTestHolder.style.zIndex = -1;
301 preTestHolder.style.visibility = 'hidden';
302 var blank = document.getElementsByClassName('testHalt')[0];
303 blank.style.zIndex = -2;
304 blank.style.visibility = 'hidden';
305 }
306 }
307
308 function showPopup()
309 {
310
311 }
312
313 function hidePopup()
314 {
315
305 } 316 }
306 317
307 function dragEnd(ev) { 318 function dragEnd(ev) {
308 // Function call when a div has been dropped 319 // Function call when a div has been dropped
309 var slider = document.getElementById('slider'); 320 var slider = document.getElementById('slider');