Mercurial > hg > webaudioevaluationtool
comparison core.js @ 297:a8db8084d32a Dev_main
Feature #1298: <setup> node has an optional attribute testPages. Specify the number of pages the test participant to do and the tool will select a random page up to the number specified.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 10 Sep 2015 13:16:16 +0100 |
parents | 7e9c38fa7499 |
children | 18a6119854ac |
comparison
equal
deleted
inserted
replaced
296:d3d691e33fec | 297:a8db8084d32a |
---|---|
547 | 547 |
548 // Build the specification | 548 // Build the specification |
549 specification.decode(); | 549 specification.decode(); |
550 | 550 |
551 testState.stateMap.push(specification.preTest); | 551 testState.stateMap.push(specification.preTest); |
552 | |
553 // New check if we need to randomise the test order | |
554 if (specification.randomiseOrder) | |
555 { | |
556 specification.audioHolders = randomiseOrder(specification.audioHolders); | |
557 for (var i=0; i<specification.audioHolders.length; i++) | |
558 { | |
559 specification.audioHolders[i].presentedId = i; | |
560 } | |
561 } | |
562 | 552 |
563 $(specification.audioHolders).each(function(index,elem){ | 553 $(specification.audioHolders).each(function(index,elem){ |
564 testState.stateMap.push(elem); | 554 testState.stateMap.push(elem); |
565 }); | 555 }); |
566 | 556 |
1330 this.interfaceType; | 1320 this.interfaceType; |
1331 this.commonInterface; | 1321 this.commonInterface; |
1332 this.projectReturn; | 1322 this.projectReturn; |
1333 this.randomiseOrder; | 1323 this.randomiseOrder; |
1334 this.collectMetrics; | 1324 this.collectMetrics; |
1325 this.testPages; | |
1335 this.preTest; | 1326 this.preTest; |
1336 this.postTest; | 1327 this.postTest; |
1337 this.metrics =[]; | 1328 this.metrics =[]; |
1338 | 1329 |
1339 this.audioHolders = []; | 1330 this.audioHolders = []; |
1342 // projectXML - DOM Parsed document | 1333 // projectXML - DOM Parsed document |
1343 this.projectXML = projectXML.childNodes[0]; | 1334 this.projectXML = projectXML.childNodes[0]; |
1344 var setupNode = projectXML.getElementsByTagName('setup')[0]; | 1335 var setupNode = projectXML.getElementsByTagName('setup')[0]; |
1345 this.interfaceType = setupNode.getAttribute('interface'); | 1336 this.interfaceType = setupNode.getAttribute('interface'); |
1346 this.projectReturn = setupNode.getAttribute('projectReturn'); | 1337 this.projectReturn = setupNode.getAttribute('projectReturn'); |
1338 this.testPages = setupNode.getAttribute('testPages'); | |
1347 if (setupNode.getAttribute('randomiseOrder') == "true") { | 1339 if (setupNode.getAttribute('randomiseOrder') == "true") { |
1348 this.randomiseOrder = true; | 1340 this.randomiseOrder = true; |
1349 } else {this.randomiseOrder = false;} | 1341 } else {this.randomiseOrder = false;} |
1350 if (setupNode.getAttribute('collectMetrics') == "true") { | 1342 if (setupNode.getAttribute('collectMetrics') == "true") { |
1351 this.collectMetrics = true; | 1343 this.collectMetrics = true; |
1352 } else {this.collectMetrics = false;} | 1344 } else {this.collectMetrics = false;} |
1345 if (isNaN(Number(this.testPages)) || this.testPages == undefined) | |
1346 { | |
1347 this.testPages = null; | |
1348 } else { | |
1349 this.testPages = Number(this.testPages); | |
1350 if (this.testPages == 0) {this.testPages = null;} | |
1351 } | |
1353 var metricCollection = setupNode.getElementsByTagName('Metric'); | 1352 var metricCollection = setupNode.getElementsByTagName('Metric'); |
1354 | 1353 |
1355 this.preTest = new this.prepostNode('pretest',setupNode.getElementsByTagName('PreTest')); | 1354 this.preTest = new this.prepostNode('pretest',setupNode.getElementsByTagName('PreTest')); |
1356 this.postTest = new this.prepostNode('posttest',setupNode.getElementsByTagName('PostTest')); | 1355 this.postTest = new this.prepostNode('posttest',setupNode.getElementsByTagName('PostTest')); |
1357 | 1356 |
1414 var audioHolders = projectXML.getElementsByTagName('audioHolder'); | 1413 var audioHolders = projectXML.getElementsByTagName('audioHolder'); |
1415 for (var i=0; i<audioHolders.length; i++) { | 1414 for (var i=0; i<audioHolders.length; i++) { |
1416 this.audioHolders.push(new this.audioHolderNode(this,audioHolders[i])); | 1415 this.audioHolders.push(new this.audioHolderNode(this,audioHolders[i])); |
1417 } | 1416 } |
1418 | 1417 |
1418 // New check if we need to randomise the test order | |
1419 if (this.randomiseOrder) | |
1420 { | |
1421 this.audioHolders = randomiseOrder(this.audioHolders); | |
1422 for (var i=0; i<this.audioHolders.length; i++) | |
1423 { | |
1424 this.audioHolders[i].presentedId = i; | |
1425 } | |
1426 } | |
1427 | |
1428 if (this.testPages != null || this.testPages != undefined) | |
1429 { | |
1430 if (this.testPages > audioHolders.length) | |
1431 { | |
1432 console.log('Warning: You have specified '+audioHolders.length+' tests but requested '+this.testPages+' be completed!'); | |
1433 this.testPages = audioHolders.length; | |
1434 } | |
1435 var aH = this.audioHolders; | |
1436 this.audioHolders = []; | |
1437 for (var i=0; i<this.testPages; i++) | |
1438 { | |
1439 this.audioHolders.push(aH[i]); | |
1440 } | |
1441 } | |
1419 }; | 1442 }; |
1420 | 1443 |
1421 this.prepostNode = function(type,Collection) { | 1444 this.prepostNode = function(type,Collection) { |
1422 this.type = type; | 1445 this.type = type; |
1423 this.options = []; | 1446 this.options = []; |