changeset 2826:28a5504db337

#209 define interfaceContext.checkFragmentMinPlays
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 09 May 2017 15:40:37 +0100
parents 64a5603831e2
children cf1a3a529177
files js/core.js
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/js/core.js	Tue May 09 15:39:40 2017 +0100
+++ b/js/core.js	Tue May 09 15:40:37 2017 +0100
@@ -3333,6 +3333,27 @@
         }
         return state;
     };
+    this.checkFragmentMinPlays = function () {
+        var failedObjects = audioEngineContext.audioObjects.filter(function (a) {
+            var minPlays = a.specification.minNumberPlays || a.specification.parent.minNumberPlays || specification.minNumberPlays;
+            if (minPlays === undefined || a.numberOfPlays >= minPlays) {
+                return false;
+            }
+            return true;
+        });
+        if (failedObjects.length === 0) {
+            return false;
+        }
+        var failedString = [];
+        failedObjects.forEach(function (a) {
+            failedString.push(a.interfaceDOM.getPresentedId());
+        });
+        var str = "You have not played fragments " + failedString.join(", ") + " enough. Please keep listening";
+        interfaceContext.lightbox.post("Message", str);
+        this.storeErrorNode(str);
+        return true;
+    };
+
 
     this.storeErrorNode = function (errorMessage) {
         var time = audioEngineContext.timer.getTestTime();