From 738dced2861dc8467e86ffa53843296659818716 Mon Sep 17 00:00:00 2001 From: Paal Joergensen Date: Wed, 4 Jan 2017 16:16:28 +0100 Subject: [PATCH] Added utility function for figuriong out if event is from child [HFP-436] --- js/h5p-x-api-event.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index 212fe0b..cc7fd66 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -248,6 +248,16 @@ H5P.XAPIEvent.prototype.getContentXAPIId = function (instance) { return xAPIId; }; +/** + * Check if this event is sent from a child (i.e not from grandchild) + * + * @return {Boolean} + */ +H5P.XAPIEvent.prototype.isFromChild = function () { + var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']); + return !parentId || parentId.indexOf('subContentId') === -1; +} + /** * Figure out if a property exists in the statement and return it *