comparison ape.js @ 668:6455bee85090

Implemented repeat function of tests
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 10 Apr 2015 16:21:57 +0100
parents 2cc25941c433
children c8eb821710fa
comparison
equal deleted inserted replaced
667:2cc25941c433 668:6455bee85090
40 // xmlDoc MUST already be parsed by jQuery! 40 // xmlDoc MUST already be parsed by jQuery!
41 var xmlSetup = xmlDoc.find('setup'); 41 var xmlSetup = xmlDoc.find('setup');
42 // Should put in an error function here incase of malprocessed or malformed XML 42 // Should put in an error function here incase of malprocessed or malformed XML
43 43
44 // Extract the different test XML DOM trees 44 // Extract the different test XML DOM trees
45 testXMLSetups = xmlDoc.find('audioHolder'); 45 var audioHolders = xmlDoc.find('audioHolder');
46 audioHolders.each(function(index,element) {
47 var repeatN = element.attributes['repeatCount'].value;
48 for (var r=0; r<=repeatN; r++) {
49 testXMLSetups[testXMLSetups.length] = element;
50 }
51 });
52
53 // New check if we need to randomise the test order
54 var randomise = xmlSetup.attributes['randomiseOrder'];
55 if (randomise != undefine) {
56 randomise = Boolean(randomise.value);
57 } else {
58 randomise = false;
59 }
60 if (randomise)
61 {
62 // TODO: Implement Randomisation!!
63 }
64
46 65
47 // Create the top div for the Title element 66 // Create the top div for the Title element
48 var titleAttr = xmlSetup[0].attributes['title']; 67 var titleAttr = xmlSetup[0].attributes['title'];
49 var title = document.createElement('div'); 68 var title = document.createElement('div');
50 title.className = "title"; 69 title.className = "title";
239 canvas.appendChild(trackSliderObj); 258 canvas.appendChild(trackSliderObj);
240 }); 259 });
241 260
242 // Now process any pre-test commands 261 // Now process any pre-test commands
243 262
244 var preTest = testXMLSetups.find('PreTest')[0]; 263 var preTest = $(testXMLSetups[id]).find('PreTest')[0];
245 if (preTest.children.length > 0) 264 if (preTest.children.length > 0)
246 { 265 {
247 currentState = 'testRunPre-'+id; 266 currentState = 'testRunPre-'+id;
248 preTestPopupStart(preTest); 267 preTestPopupStart(preTest);
249 showPopup(); 268 showPopup();
296 this.value = preTestButtonClick(preTest,this.value); 315 this.value = preTestButtonClick(preTest,this.value);
297 } else if (currentState.substr(0,10) == 'testRunPre') 316 } else if (currentState.substr(0,10) == 'testRunPre')
298 { 317 {
299 //Specific test pre-test 318 //Specific test pre-test
300 var testId = currentState.substr(11,currentState.length-10); 319 var testId = currentState.substr(11,currentState.length-10);
301 var preTest = testXMLSetups.find('PreTest')[testId]; 320 var preTest = $(testXMLSetups[testId]).find('PreTest')[0];
302 this.value = preTestButtonClick(preTest,this.value); 321 this.value = preTestButtonClick(preTest,this.value);
303 } else if (currentState.substr(0,11) == 'testRunPost') 322 } else if (currentState.substr(0,11) == 'testRunPost')
304 { 323 {
305 // Specific test post-test 324 // Specific test post-test
306 var testId = currentState.substr(12,currentState.length-11); 325 var testId = currentState.substr(12,currentState.length-11);
307 var preTest = testXMLSetups.find('PostTest')[testId]; 326 var preTest = $(testXMLSetups[testId]).find('PostTest')[0];
308 this.value = preTestButtonClick(preTest,this.value); 327 this.value = preTestButtonClick(preTest,this.value);
309 } else if (currentState == 'postTest') 328 } else if (currentState == 'postTest')
310 { 329 {
311 // At the end of the test, running global post test 330 // At the end of the test, running global post test
312 var xmlTree = projectXML.find('setup'); 331 var xmlTree = projectXML.find('setup');
414 // Start the test 433 // Start the test
415 var testId = currentState.substr(11,currentState.length-10); 434 var testId = currentState.substr(11,currentState.length-10);
416 currentState = 'testRun-'+testId; 435 currentState = 'testRun-'+testId;
417 } else if (currentState.substr(0,11) == 'testRunPost') 436 } else if (currentState.substr(0,11) == 'testRunPost')
418 { 437 {
438 var testId = currentState.substr(12,currentState.length-11);
419 testEnded(testId); 439 testEnded(testId);
420 } else if (currentState.substr(0,7) == 'testRun') 440 } else if (currentState.substr(0,7) == 'testRun')
421 { 441 {
422 var testId = currentState.substr(8,currentState.length-7); 442 var testId = currentState.substr(8,currentState.length-7);
423 // Check if we have any post tests to perform 443 // Check if we have any post tests to perform
424 var postXML = testXMLSetups.find('PostTest')[testId]; 444 var postXML = $(testXMLSetups[testId]).find('PostTest')[0];
425 if (postXML.children.length > 0) 445 if (postXML.children.length > 0)
426 { 446 {
427 currentState = 'testRunPost-'+testId; 447 currentState = 'testRunPost-'+testId;
428 showPopup(); 448 showPopup();
429 preTestPopupStart(postXML); 449 preTestPopupStart(postXML);
438 console.log(currentState); 458 console.log(currentState);
439 } 459 }
440 460
441 function testEnded(testId) 461 function testEnded(testId)
442 { 462 {
463 var xmlDoc = interfaceXMLSave();
464 testResultsHolders;
443 if (testXMLSetups.length-1 > testId) 465 if (testXMLSetups.length-1 > testId)
444 { 466 {
445 // Yes we have another test to perform 467 // Yes we have another test to perform
446 currentState = 'testRun-'+Number(testId)+1; 468 testId = (Number(testId)+1);
447 loadTest(testId+1); 469 currentState = 'testRun-'+testId;
470 loadTest(testId);
448 } else { 471 } else {
449 console.log('Testing Completed!'); 472 console.log('Testing Completed!');
450 currentState = 'postTest'; 473 currentState = 'postTest';
451 // Check for any post tests 474 // Check for any post tests
452 var xmlSetup = projectXML.find('setup'); 475 var xmlSetup = projectXML.find('setup');
461 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options 484 // This function is called when the submit button is clicked. Will check for any further tests to perform, or any post-test options
462 if (currentState.substr(0,7) == 'testRun') 485 if (currentState.substr(0,7) == 'testRun')
463 { 486 {
464 advanceState(); 487 advanceState();
465 } 488 }
489 }
490
491 function pageXMLSave(testId)
492 {
493 // Saves a specific test page
494 var xmlDoc = document.createElement("AudioHolder");
495 var testXML = testXMLSetups[testId];
496 xmlDoc.id = testXML.id;
497 xmlDoc.repeatCount = testXML.attributes['repeatCount'].value;
498
466 } 499 }
467 500
468 // Only other global function which must be defined in the interface class. Determines how to create the XML document. 501 // Only other global function which must be defined in the interface class. Determines how to create the XML document.
469 function interfaceXMLSave(){ 502 function interfaceXMLSave(){
470 // Create the XML string to be exported with results 503 // Create the XML string to be exported with results