comparison ape.js @ 662:2991b5476c7c

Updated popup button functions.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 10 Apr 2015 13:46:04 +0100
parents 97ade670d7c1
children ba6cc0a042d8
comparison
equal deleted inserted replaced
661:97ade670d7c1 662:2991b5476c7c
10 * YOU ARE VIEWING THE DEV VERSION. THERE IS NO GUARANTEE THIS WILL BE FULLY FUNCTIONAL 10 * YOU ARE VIEWING THE DEV VERSION. THERE IS NO GUARANTEE THIS WILL BE FULLY FUNCTIONAL
11 * 11 *
12 * WARNING!!! 12 * WARNING!!!
13 * 13 *
14 */ 14 */
15
16 var currentState; // Keep track of the current state (pre/post test, which test, final test? first test?)
17 // preTest - In preTest state
18 // testRun-ID - In test running, test Id number at the end 'testRun-2'
19 // testRunPost-ID - Post test of test ID
20 // testRunPre-ID - Pre-test of test ID
21 // postTest - End of test, final submission!
15 22
16 23
17 // Once this is loaded and parsed, begin execution 24 // Once this is loaded and parsed, begin execution
18 loadInterface(projectXML); 25 loadInterface(projectXML);
19 26
109 116
110 // Global parent for the comment boxes on the page 117 // Global parent for the comment boxes on the page
111 var feedbackHolder = document.createElement('div'); 118 var feedbackHolder = document.createElement('div');
112 feedbackHolder.id = 'feedbackHolder'; 119 feedbackHolder.id = 'feedbackHolder';
113 120
121 testContent.style.zIndex = 1;
122 insertPoint.innerHTML = null; // Clear the current schema
123
114 // Create pre and post test questions 124 // Create pre and post test questions
115 125 var blank = document.createElement('div');
116 // Inject into HTML 126 blank.className = 'testHalt';
117 insertPoint.innerHTML = null; // Clear the current schema 127
118 testContent.appendChild(title); // Insert the title 128 var popupHolder = document.createElement('div');
119 testContent.appendChild(interfaceButtons); 129 popupHolder.id = 'popupHolder';
120 testContent.appendChild(sliderBox); 130 popupHolder.className = 'popupHolder';
121 testContent.appendChild(feedbackHolder); 131 popupHolder.style.position = 'absolute';
122 insertPoint.appendChild(testContent); 132 popupHolder.style.left = (window.innerWidth/2)-250 + 'px';
133 popupHolder.style.top = (window.innerHeight/2)-125 + 'px';
134 insertPoint.appendChild(popupHolder);
135 insertPoint.appendChild(blank);
136 hidePopup();
123 137
124 var preTest = xmlSetup.find('PreTest'); 138 var preTest = xmlSetup.find('PreTest');
125 var postTest = xmlSetup.find('PostTest'); 139 var postTest = xmlSetup.find('PostTest');
126 preTest = preTest[0]; 140 preTest = preTest[0];
127 postTest = postTest[0]; 141 postTest = postTest[0];
128 if (preTest != undefined || postTest != undefined) 142
129 { 143 currentState = 'preTest';
130 testContent.style.zIndex = 1;
131 var blank = document.createElement('div');
132 blank.className = 'testHalt';
133 insertPoint.appendChild(blank);
134 }
135 144
136 // Create Pre-Test Box 145 // Create Pre-Test Box
137 if (preTest != undefined && preTest.children.length >= 1) 146 if (preTest != undefined && preTest.children.length >= 1)
138 { 147 {
139 148 showPopup();
140 var popupHolder = document.createElement('div');
141 popupHolder.id = 'popupHolder';
142 popupHolder.className = 'popupHolder';
143 popupHolder.style.position = 'absolute';
144 popupHolder.style.left = (window.innerWidth/2)-250 + 'px';
145 popupHolder.style.top = (window.innerHeight/2)-125 + 'px';
146 149
147 // Parse the first box 150 // Parse the first box
148 var preTestOption = document.createElement('div'); 151 var preTestOption = document.createElement('div');
149 preTestOption.id = 'preTest'; 152 preTestOption.id = 'preTest';
150 preTestOption.style.marginTop = '25px'; 153 preTestOption.style.marginTop = '25px';
162 var textEnter = document.createElement('textarea'); 165 var textEnter = document.createElement('textarea');
163 preTestOption.appendChild(textHold); 166 preTestOption.appendChild(textHold);
164 preTestOption.appendChild(textEnter); 167 preTestOption.appendChild(textEnter);
165 } 168 }
166 var nextButton = document.createElement('button'); 169 var nextButton = document.createElement('button');
167 nextButton.id = 'preTestNext'; 170 nextButton.className = 'popupButton';
168 nextButton.value = '0'; 171 nextButton.value = '0';
169 nextButton.innerHTML = 'Next'; 172 nextButton.innerHTML = 'Next';
170 nextButton.onclick = preTestButtonClick; 173 nextButton.onclick = popupButtonClick;
171 174
172 popupHolder.appendChild(preTestOption); 175 popupHolder.appendChild(preTestOption);
173 popupHolder.appendChild(nextButton); 176 popupHolder.appendChild(nextButton);
174 insertPoint.appendChild(popupHolder); 177 }
175 } 178
179 // Inject into HTML
180 testContent.appendChild(title); // Insert the title
181 testContent.appendChild(interfaceButtons);
182 testContent.appendChild(sliderBox);
183 testContent.appendChild(feedbackHolder);
184 insertPoint.appendChild(testContent);
176 185
177 // Load the full interface 186 // Load the full interface
178 loadTest(testXMLSetups[0]); 187 loadTest(testXMLSetups[0]);
179 } 188 }
180 189
259 268
260 canvas.appendChild(trackSliderObj); 269 canvas.appendChild(trackSliderObj);
261 }); 270 });
262 } 271 }
263 272
264 function preTestButtonClick() 273 function popupButtonClick()
274 {
275 // Global call from the 'Next' button click
276 if (currentState == 'preTest')
277 {
278 // At the start of the preTest routine!
279 this.value = preTestButtonClick(this.value);
280 }
281 }
282
283 function preTestButtonClick(index)
265 { 284 {
266 // Called on click of pre-test button 285 // Called on click of pre-test button
267 // Need to find and parse preTest again! 286 // Need to find and parse preTest again!
268 var xmlSetup = projectXML.find('setup'); 287 var xmlSetup = projectXML.find('setup');
269 var preTest = xmlSetup.find('PreTest')[0]; 288 var preTest = xmlSetup.find('PreTest')[0];
270 var preTestOption = document.getElementById('preTest'); 289 var preTestOption = document.getElementById('preTest');
271 // Check if current state is a question! 290 // Check if current state is a question!
272 if (preTest.children[this.value].nodeName == 'question') { 291 if (preTest.children[index].nodeName == 'question') {
273 var questionId = preTest.children[this.value].attributes['id'].value; 292 var questionId = preTest.children[index].attributes['id'].value;
274 var questionHold = document.createElement('comment'); 293 var questionHold = document.createElement('comment');
275 var questionResponse = document.getElementById(questionId + 'response'); 294 var questionResponse = document.getElementById(questionId + 'response');
276 questionHold.id = questionId; 295 questionHold.id = questionId;
277 questionHold.innerHTML = questionResponse.value; 296 questionHold.innerHTML = questionResponse.value;
278 preTestQuestions.appendChild(questionHold); 297 preTestQuestions.appendChild(questionHold);
279 } 298 }
280 this.value++; 299 index++;
281 if (this.value < preTest.children.length) 300 if (index < preTest.children.length)
282 { 301 {
283 // More to process 302 // More to process
284 var child = preTest.children[this.value]; 303 var child = preTest.children[index];
285 if (child.nodeName == 'statement') 304 if (child.nodeName == 'statement')
286 { 305 {
287 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>'; 306 preTestOption.innerHTML = '<span>'+child.innerHTML+'</span>';
288 } else if (child.nodeName == 'question') 307 } else if (child.nodeName == 'question')
289 { 308 {
299 } 318 }
300 } else { 319 } else {
301 // Time to clear 320 // Time to clear
302 preTestOption.innerHTML = null; 321 preTestOption.innerHTML = null;
303 hidePopup(); 322 hidePopup();
304 } 323 // Progress the state!
324 }
325 return index;
305 } 326 }
306 327
307 function showPopup() 328 function showPopup()
308 { 329 {
309 var popupHolder = document.getElementById('popupHolder'); 330 var popupHolder = document.getElementById('popupHolder');
310 popupHolder.style.zIndex = 2; 331 popupHolder.style.zIndex = 3;
311 popupHolder.style.visibility = 'visible'; 332 popupHolder.style.visibility = 'visible';
312 var blank = document.getElementsByClassName('testHalt')[0]; 333 var blank = document.getElementsByClassName('testHalt')[0];
313 blank.style.zIndex = 2; 334 blank.style.zIndex = 2;
314 blank.style.visibility = 'visible'; 335 blank.style.visibility = 'visible';
315 } 336 }