# HG changeset patch # User Nicholas Jillings # Date 1461926406 -3600 # Node ID 426995e02e79133b0b03183324c97e67cf64a40c # Parent 64be32cd1c31496741401f4dc11ca3d627586c05 Fix for #43. Added scale range check enforcement diff -r 64be32cd1c31 -r 426995e02e79 interfaces/AB.js --- a/interfaces/AB.js Thu Apr 28 16:52:36 2016 +0100 +++ b/interfaces/AB.js Fri Apr 29 11:40:06 2016 +0100 @@ -388,6 +388,11 @@ var checkState = interfaceContext.checkAllCommented(); if (checkState == false) {canContinue = false;} break; + case 'scalerange': + // Check the scale has been used effectively + var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max); + if (checkState == false) {canContinue = false;} + break; default: console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); break; diff -r 64be32cd1c31 -r 426995e02e79 interfaces/ABX.js --- a/interfaces/ABX.js Thu Apr 28 16:52:36 2016 +0100 +++ b/interfaces/ABX.js Fri Apr 29 11:40:06 2016 +0100 @@ -430,6 +430,11 @@ var checkState = interfaceContext.checkAllCommented(); if (checkState == false) {canContinue = false;} break; + case 'scalerange': + // Check the scale has been used effectively + var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max); + if (checkState == false) {canContinue = false;} + break; default: console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); break; diff -r 64be32cd1c31 -r 426995e02e79 interfaces/discrete.js --- a/interfaces/discrete.js Thu Apr 28 16:52:36 2016 +0100 +++ b/interfaces/discrete.js Fri Apr 29 11:40:06 2016 +0100 @@ -492,11 +492,11 @@ var checkState = interfaceContext.checkAllCommented(); if (checkState == false) {canContinue = false;} break; - //case 'scalerange': - // Check the scale is used to its full width outlined by the node - //var checkState = interfaceContext.checkScaleRange(); - //if (checkState == false) {canContinue = false;} - // break; + case 'scalerange': + // Check the scale has been used effectively + var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max); + if (checkState == false) {canContinue = false;} + break; default: console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); break; diff -r 64be32cd1c31 -r 426995e02e79 interfaces/horizontal-sliders.js --- a/interfaces/horizontal-sliders.js Thu Apr 28 16:52:36 2016 +0100 +++ b/interfaces/horizontal-sliders.js Fri Apr 29 11:40:06 2016 +0100 @@ -445,11 +445,11 @@ var checkState = interfaceContext.checkAllCommented(); if (checkState == false) {canContinue = false;} break; - //case 'scalerange': - // Check the scale is used to its full width outlined by the node - //var checkState = interfaceContext.checkScaleRange(); - //if (checkState == false) {canContinue = false;} - // break; + case 'scalerange': + // Check the scale has been used effectively + var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max); + if (checkState == false) {canContinue = false;} + break; default: console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); break; diff -r 64be32cd1c31 -r 426995e02e79 interfaces/mushra.js --- a/interfaces/mushra.js Thu Apr 28 16:52:36 2016 +0100 +++ b/interfaces/mushra.js Fri Apr 29 11:40:06 2016 +0100 @@ -469,11 +469,11 @@ var checkState = interfaceContext.checkAllCommented(); if (checkState == false) {canContinue = false;} break; - //case 'scalerange': - // Check the scale is used to its full width outlined by the node - //var checkState = interfaceContext.checkScaleRange(); - //if (checkState == false) {canContinue = false;} - // break; + case 'scalerange': + // Check the scale has been used effectively + var checkState = interfaceContext.checkScaleRange(checks[i].min,checks[i].max); + if (checkState == false) {canContinue = false;} + break; default: console.log("WARNING - Check option "+checks[i].check+" is not supported on this interface"); break; diff -r 64be32cd1c31 -r 426995e02e79 js/core.js --- a/js/core.js Thu Apr 28 16:52:36 2016 +0100 +++ b/js/core.js Fri Apr 29 11:40:06 2016 +0100 @@ -1095,6 +1095,14 @@ pageXMLSave(storePoint.XMLDOM, this.currentStateMap); storePoint.complete(); }; + + this.getCurrentTestPage = function() { + if (this.stateIndex >= 0 && this.stateIndex< this.stateMap.length) { + return this.currentStateMap; + } else { + return null; + } + } } function AudioEngine(specification) { @@ -2783,6 +2791,33 @@ this.storeErrorNode(str); return false; }; + this.checkScaleRange = function(min, max) { + var page = testState.getCurrentTestPage(); + var audioObjects = audioEngineContext.audioObjects; + var state = true; + var str = "Please keep listening. "; + var minRanking = Infinity; + var maxRanking = -Infinity; + for (var ao of audioObjects) { + var rank = ao.interfaceDOM.getValue(); + if (rank < minRanking) {minRanking = rank;} + if (rank > maxRanking) {maxRanking = rank;} + } + if (minRanking*100 > min) { + str += "At least one fragment must be below the "+min+" mark."; + state = false; + } + if (maxRanking*100 < max) { + str += "At least one fragment must be above the "+max+" mark." + state = false; + } + if (!state) { + console.log(str); + this.storeErrorNode(str); + alert(str); + } + return state; + } this.storeErrorNode = function(errorMessage) {