Mercurial > hg > webaudioevaluationtool
comparison js/core.js @ 2789:3c14e0b6c9ff
#133 check handles in core.js accept unknown message string. Will override displayed message but preserved debug and results message
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Sat, 22 Apr 2017 17:53:51 +0100 |
parents | d8c36948f2b7 |
children | 1954075487ed |
comparison
equal
deleted
inserted
replaced
2788:a4bcbcda23f7 | 2789:3c14e0b6c9ff |
---|---|
3114 }; | 3114 }; |
3115 | 3115 |
3116 | 3116 |
3117 // Global Checkers | 3117 // Global Checkers |
3118 // These functions will help enforce the checkers | 3118 // These functions will help enforce the checkers |
3119 this.checkHiddenAnchor = function () { | 3119 this.checkHiddenAnchor = function (message) { |
3120 var anchors = audioEngineContext.audioObjects.filter(function (ao) { | 3120 var anchors = audioEngineContext.audioObjects.filter(function (ao) { |
3121 return ao.specification.type === "anchor"; | 3121 return ao.specification.type === "anchor"; |
3122 }); | 3122 }); |
3123 var state = anchors.some(function (ao) { | 3123 var state = anchors.some(function (ao) { |
3124 return (ao.interfaceDOM.getValue() > (ao.specification.marker / 100) && ao.specification.marker > 0); | 3124 return (ao.interfaceDOM.getValue() > (ao.specification.marker / 100) && ao.specification.marker > 0); |
3125 }); | 3125 }); |
3126 if (state) { | 3126 if (state) { |
3127 console.log('Anchor node not below marker value'); | 3127 console.log('Anchor node not below marker value'); |
3128 interfaceContext.lightbox.post("Message", 'Please keep listening'); | 3128 if (message) { |
3129 interfaceContext.lightbox.post("Message", message); | |
3130 } else { | |
3131 interfaceContext.lightbox.post("Message", 'Please keep listening'); | |
3132 } | |
3129 this.storeErrorNode('Anchor node not below marker value'); | 3133 this.storeErrorNode('Anchor node not below marker value'); |
3130 return false; | 3134 return false; |
3131 } | 3135 } |
3132 return true; | 3136 return true; |
3133 }; | 3137 }; |
3134 | 3138 |
3135 this.checkHiddenReference = function () { | 3139 this.checkHiddenReference = function (message) { |
3136 var references = audioEngineContext.audioObjects.filter(function (ao) { | 3140 var references = audioEngineContext.audioObjects.filter(function (ao) { |
3137 return ao.specification.type === "reference"; | 3141 return ao.specification.type === "reference"; |
3138 }); | 3142 }); |
3139 var state = references.some(function (ao) { | 3143 var state = references.some(function (ao) { |
3140 return (ao.interfaceDOM.getValue() < (ao.specification.marker / 100) && ao.specification.marker > 0); | 3144 return (ao.interfaceDOM.getValue() < (ao.specification.marker / 100) && ao.specification.marker > 0); |
3141 }); | 3145 }); |
3142 if (state) { | 3146 if (state) { |
3143 console.log('Reference node not below marker value'); | 3147 console.log('Reference node not below marker value'); |
3144 interfaceContext.lightbox.post("Message", 'Please keep listening'); | 3148 if (message) { |
3149 interfaceContext.lightbox.post("Message", message); | |
3150 } else { | |
3151 interfaceContext.lightbox.post("Message", 'Please keep listening'); | |
3152 } | |
3145 this.storeErrorNode('Reference node not below marker value'); | 3153 this.storeErrorNode('Reference node not below marker value'); |
3146 return false; | 3154 return false; |
3147 } | 3155 } |
3148 return true; | 3156 return true; |
3149 }; | 3157 }; |
3150 | 3158 |
3151 this.checkFragmentsFullyPlayed = function () { | 3159 this.checkFragmentsFullyPlayed = function (message) { |
3152 // Checks the entire file has been played back | 3160 // Checks the entire file has been played back |
3153 // NOTE ! This will return true IF playback is Looped!!! | 3161 // NOTE ! This will return true IF playback is Looped!!! |
3154 if (audioEngineContext.loopPlayback) { | 3162 if (audioEngineContext.loopPlayback) { |
3155 console.log("WARNING - Looped source: Cannot check fragments are fully played"); | 3163 console.log("WARNING - Looped source: Cannot check fragments are fully played"); |
3156 return true; | 3164 return true; |
3186 if (i != error_obj.length - 1) { | 3194 if (i != error_obj.length - 1) { |
3187 str_start += ', '; | 3195 str_start += ', '; |
3188 } | 3196 } |
3189 } | 3197 } |
3190 str_start += ". Please keep listening"; | 3198 str_start += ". Please keep listening"; |
3191 console.log("[ALERT]: " + str_start); | 3199 console.log(str_start); |
3192 this.storeErrorNode("[ALERT]: " + str_start); | 3200 this.storeErrorNode(str_start); |
3201 if (message) { | |
3202 str_start = message; | |
3203 } | |
3193 interfaceContext.lightbox.post("Error", str_start); | 3204 interfaceContext.lightbox.post("Error", str_start); |
3194 return false; | 3205 return false; |
3195 } | 3206 } |
3196 return true; | 3207 return true; |
3197 }; | 3208 }; |
3198 this.checkAllMoved = function () { | 3209 this.checkAllMoved = function (message) { |
3199 var str = "You have not moved "; | 3210 var str = "You have not moved "; |
3200 var failed = []; | 3211 var failed = []; |
3201 audioEngineContext.audioObjects.forEach(function (ao) { | 3212 audioEngineContext.audioObjects.forEach(function (ao) { |
3202 if (ao.metric.wasMoved === false && ao.interfaceDOM.canMove() === true) { | 3213 if (ao.metric.wasMoved === false && ao.interfaceDOM.canMove() === true) { |
3203 failed.push(ao.interfaceDOM.getPresentedId()); | 3214 failed.push(ao.interfaceDOM.getPresentedId()); |
3213 str += failed[i] + ', '; | 3224 str += failed[i] + ', '; |
3214 } | 3225 } |
3215 str += 'and ' + failed[i]; | 3226 str += 'and ' + failed[i]; |
3216 } | 3227 } |
3217 str += '.'; | 3228 str += '.'; |
3218 interfaceContext.lightbox.post("Error", str); | |
3219 console.log(str); | 3229 console.log(str); |
3220 this.storeErrorNode(str); | 3230 this.storeErrorNode(str); |
3231 if (message) { | |
3232 str = message; | |
3233 } | |
3234 interfaceContext.lightbox.post("Error", str); | |
3221 return false; | 3235 return false; |
3222 }; | 3236 }; |
3223 this.checkAllPlayed = function () { | 3237 this.checkAllPlayed = function (message) { |
3224 var str = "You have not played "; | 3238 var str = "You have not played "; |
3225 var failed = []; | 3239 var failed = []; |
3226 audioEngineContext.audioObjects.forEach(function (ao) { | 3240 audioEngineContext.audioObjects.forEach(function (ao) { |
3227 if (ao.metric.wasListenedTo === false) { | 3241 if (ao.metric.wasListenedTo === false) { |
3228 failed.push(ao.interfaceDOM.getPresentedId()); | 3242 failed.push(ao.interfaceDOM.getPresentedId()); |
3238 str += failed[i] + ', '; | 3252 str += failed[i] + ', '; |
3239 } | 3253 } |
3240 str += 'and ' + failed[i]; | 3254 str += 'and ' + failed[i]; |
3241 } | 3255 } |
3242 str += '.'; | 3256 str += '.'; |
3243 interfaceContext.lightbox.post("Error", str); | |
3244 console.log(str); | 3257 console.log(str); |
3245 this.storeErrorNode(str); | 3258 this.storeErrorNode(str); |
3259 if (message) { | |
3260 str = message; | |
3261 } | |
3262 interfaceContext.lightbox.post("Error", str); | |
3246 return false; | 3263 return false; |
3247 }; | 3264 }; |
3248 this.checkAllCommented = function () { | 3265 this.checkAllCommented = function (message) { |
3249 var str = "You have not commented on all the fragments."; | 3266 var str = "You have not commented on all the fragments."; |
3250 var cont = true, | 3267 var cont = true, |
3251 boxes = this.commentBoxes.boxes, | 3268 boxes = this.commentBoxes.boxes, |
3252 numBoxes = boxes.length, | 3269 numBoxes = boxes.length, |
3253 i; | 3270 i; |
3254 for (i = 0; i < numBoxes; i++) { | 3271 for (i = 0; i < numBoxes; i++) { |
3255 if (boxes[i].trackCommentBox.value === "") { | 3272 if (boxes[i].trackCommentBox.value === "") { |
3256 interfaceContext.lightbox.post("Error", str); | |
3257 console.log(str); | 3273 console.log(str); |
3258 this.storeErrorNode(str); | 3274 this.storeErrorNode(str); |
3275 if (message) { | |
3276 str = message; | |
3277 } | |
3278 interfaceContext.lightbox.post("Error", str); | |
3259 return false; | 3279 return false; |
3260 } | 3280 } |
3261 } | 3281 } |
3262 return true; | 3282 return true; |
3263 }; | 3283 }; |
3264 this.checkScaleRange = function () { | 3284 this.checkScaleRange = function (message) { |
3265 var page = testState.getCurrentTestPage(); | 3285 var page = testState.getCurrentTestPage(); |
3266 var interfaceObject = page.interfaces; | 3286 var interfaceObject = page.interfaces; |
3267 var state = true; | 3287 var state = true; |
3268 var str = "Please keep listening. "; | 3288 var str = "Please keep listening. "; |
3269 if (interfaceObject === undefined) { | 3289 if (interfaceObject === undefined) { |
3297 state = false; | 3317 state = false; |
3298 } | 3318 } |
3299 if (state === false) { | 3319 if (state === false) { |
3300 console.log(str); | 3320 console.log(str); |
3301 this.storeErrorNode(str); | 3321 this.storeErrorNode(str); |
3322 if (message) { | |
3323 str = message; | |
3324 } | |
3302 interfaceContext.lightbox.post("Error", str); | 3325 interfaceContext.lightbox.post("Error", str); |
3303 } | 3326 } |
3304 return state; | 3327 return state; |
3305 }; | 3328 }; |
3306 | 3329 |