diff js/core.js @ 2349:ceaccbd708cb

Hotfix: APE sticky markers should be fixed now. Caused by improper indexing of metric trackers if outside-reference was not at the end.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 16 May 2016 13:30:41 +0100
parents 7de03d416f38
children ce406455f25b
line wrap: on
line diff
--- a/js/core.js	Mon May 16 10:48:29 2016 +0100
+++ b/js/core.js	Mon May 16 13:30:41 2016 +0100
@@ -1085,10 +1085,20 @@
 			if (this.currentStateMap == null)
 			{
 				this.currentStateMap = this.stateMap[this.stateIndex];
+                // Find and extract the outside reference
+                var elements = [], ref = null;
+                for (var elem of this.currentStateMap.audioElements) {
+                    if (elem.type == "outside-reference") {ref = elem;}
+                    else {elements.push(elem);}
+                }
 				if (this.currentStateMap.randomiseOrder)
 				{
-					this.currentStateMap.audioElements = randomiseOrder(this.currentStateMap.audioElements);
+					this.currentStateMap.audioElements = randomiseOrder(elements);
 				}
+                if (ref != null)
+                {
+                    this.currentStateMap.audioElements.push(ref);
+                }
                 this.currentStore = storage.testPages[this.stateIndex];
 				if (this.currentStateMap.preTest != null)
 				{