comparison interfaces/AB.js @ 2703:536cb44c7292

Tidied up check on submits for AB/ABX/APE.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 13 Mar 2017 11:53:36 +0000
parents 1ccc083552d5
children 7b1dfb582637
comparison
equal deleted inserted replaced
2702:28e179d4fb9a 2703:536cb44c7292
7 var height = window.innerHeight; 7 var height = window.innerHeight;
8 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema 8 interfaceContext.insertPoint.innerHTML = ""; // Clear the current schema
9 9
10 // Custom comparator Object 10 // Custom comparator Object
11 Interface.prototype.comparator = null; 11 Interface.prototype.comparator = null;
12
13 Interface.prototype.checkScaleRange = function (min, max) {
14 var page = testState.getCurrentTestPage();
15 var audioObjects = audioEngineContext.audioObjects;
16 var state = true;
17 var str = "Please keep listening. ";
18 var minRanking = Infinity;
19 var maxRanking = -Infinity;
20 for (var ao of audioObjects) {
21 var rank = ao.interfaceDOM.getValue();
22 if (rank < minRanking) {
23 minRanking = rank;
24 }
25 if (rank > maxRanking) {
26 maxRanking = rank;
27 }
28 }
29 if (maxRanking * 100 < max) {
30 str += "At least one fragment must be selected.";
31 state = false;
32 }
33 if (!state) {
34 console.log(str);
35 this.storeErrorNode(str);
36 interfaceContext.lightbox.post("Message", str);
37 }
38 return state;
39 };
40 12
41 // The injection point into the HTML page 13 // The injection point into the HTML page
42 interfaceContext.insertPoint = document.getElementById("topLevelBody"); 14 interfaceContext.insertPoint = document.getElementById("topLevelBody");
43 var testContent = document.createElement('div'); 15 var testContent = document.createElement('div');
44 testContent.id = 'testContent'; 16 testContent.id = 'testContent';
435 canContinue = false; 407 canContinue = false;
436 } 408 }
437 break; 409 break;
438 case 'scalerange': 410 case 'scalerange':
439 // Check the scale has been used effectively 411 // Check the scale has been used effectively
440 checkState = interfaceContext.checkScaleRange(checks[i].min, checks[i].max); 412 console.log("WARNING - Check 'scalerange' does not make sense in AB/ABX! Ignoring!");
441 if (checkState === false) {
442 canContinue = false;
443 }
444 break; 413 break;
445 default: 414 default:
446 console.log("WARNING - Check option " + checks[i].check + " is not supported on this interface"); 415 console.log("WARNING - Check option " + checks[i].check + " is not supported on this interface");
447 break; 416 break;
448 } 417 }