From d71ed1afdc86f81a8af2b93e693efaba2b3e6fe1 Mon Sep 17 00:00:00 2001 From: Paul Ryan Date: Tue, 6 Feb 2018 15:31:47 -1000 Subject: [PATCH] Refactor xAPI Video verb creation to get correct id URI --- js/h5p-x-api-event.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/js/h5p-x-api-event.js b/js/h5p-x-api-event.js index c6004b1..f17f7ba 100644 --- a/js/h5p-x-api-event.js +++ b/js/h5p-x-api-event.js @@ -77,6 +77,14 @@ H5P.XAPIEvent.prototype.setVerb = function (verb) { } }; } + else if (H5P.jQuery.inArray(verb, H5P.XAPIEvent.allowedXAPIVideoVerbs) !== -1) { + this.data.statement.verb = { + 'id': 'https://w3id.org/xapi/video/verbs/' + verb, + 'display': { + 'en-US': verb + } + }; + } else if (verb.id !== undefined) { this.data.statement.verb = verb; } @@ -310,14 +318,20 @@ H5P.XAPIEvent.allowedXAPIVerbs = [ 'terminated', 'voided', - // Custom verbs for video events - 'played', - 'paused', - 'seeked', - 'finished', - // Custom verbs used for action toolbar below content 'downloaded', 'accessed-embed', 'accessed-copyright' ]; + +/** + * List of video verbs defined at {@link https://w3id.org/xapi/video/|xAPI Video Profile} + * + * @type Array + */ +H5P.XAPIEvent.allowedXAPIVideoVerbs = [ + 'played', + 'paused', + 'seeked', + 'finished', +];