Satisfy JSHint and prevent crashing.
parent
688b00f55e
commit
971a55df58
|
@ -2,7 +2,7 @@ var H5P = H5P || {};
|
|||
|
||||
/**
|
||||
* Constructor for xAPI events
|
||||
*
|
||||
*
|
||||
* @class
|
||||
*/
|
||||
H5P.XAPIEvent = function() {
|
||||
|
@ -14,7 +14,7 @@ H5P.XAPIEvent.prototype.constructor = H5P.XAPIEvent;
|
|||
|
||||
/**
|
||||
* Helperfunction to set scored result statements
|
||||
*
|
||||
*
|
||||
* @param {int} score
|
||||
* @param {int} maxScore
|
||||
*/
|
||||
|
@ -30,7 +30,7 @@ H5P.XAPIEvent.prototype.setScoredResult = function(score, maxScore) {
|
|||
|
||||
/**
|
||||
* Helperfunction to set a verb.
|
||||
*
|
||||
*
|
||||
* @param {string} verb
|
||||
* Verb in short form, one of the verbs defined at
|
||||
* http://adlnet.gov/expapi/verbs/
|
||||
|
@ -45,14 +45,13 @@ H5P.XAPIEvent.prototype.setVerb = function(verb) {
|
|||
};
|
||||
}
|
||||
else {
|
||||
console.log('illegal verb');
|
||||
H5P.error('illegal verb');
|
||||
}
|
||||
// Else: Fail silently...
|
||||
};
|
||||
|
||||
/**
|
||||
* Helperfunction to get the statements verb id
|
||||
*
|
||||
*
|
||||
* @param {boolean} full
|
||||
* if true the full verb id prefixed by http://adlnet.gov/expapi/verbs/ will be returned
|
||||
* @returns {string} - Verb or null if no verb with an id has been defined
|
||||
|
@ -68,13 +67,13 @@ H5P.XAPIEvent.prototype.getVerb = function(full) {
|
|||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helperfunction to set the object part of the statement.
|
||||
*
|
||||
*
|
||||
* The id is found automatically (the url to the content)
|
||||
*
|
||||
*
|
||||
* @param {object} instance - the H5P instance
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.setObject = function(instance) {
|
||||
|
@ -109,7 +108,7 @@ H5P.XAPIEvent.prototype.setActor = function() {
|
|||
|
||||
/**
|
||||
* Get the max value of the result - score part of the statement
|
||||
*
|
||||
*
|
||||
* @returns {int} the max score, or null if not defined
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.getMaxScore = function() {
|
||||
|
@ -118,7 +117,7 @@ H5P.XAPIEvent.prototype.getMaxScore = function() {
|
|||
|
||||
/**
|
||||
* Get the raw value of the result - score part of the statement
|
||||
*
|
||||
*
|
||||
* @returns {int} the max score, or null if not defined
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.getScore = function() {
|
||||
|
@ -127,7 +126,7 @@ H5P.XAPIEvent.prototype.getScore = function() {
|
|||
|
||||
/**
|
||||
* Figure out if a property exists in the statement and return it
|
||||
*
|
||||
*
|
||||
* @param {array} keys
|
||||
* List describing the property we're looking for. For instance
|
||||
* ['result', 'score', 'raw'] for result.score.raw
|
||||
|
@ -146,7 +145,7 @@ H5P.XAPIEvent.prototype.getVerifiedStatementValue = function(keys) {
|
|||
|
||||
/**
|
||||
* List of verbs defined at http://adlnet.gov/expapi/verbs/
|
||||
*
|
||||
*
|
||||
* @type Array
|
||||
*/
|
||||
H5P.XAPIEvent.allowedXAPIVerbs = [
|
||||
|
@ -175,4 +174,4 @@ H5P.XAPIEvent.allowedXAPIVerbs = [
|
|||
'suspended',
|
||||
'terminated',
|
||||
'voided'
|
||||
];
|
||||
];
|
||||
|
|
|
@ -11,7 +11,7 @@ if (window.top !== window.self && window.top.H5P !== undefined && window.top.H5P
|
|||
|
||||
/**
|
||||
* Helper function for triggering xAPI added to the EventDispatcher
|
||||
*
|
||||
*
|
||||
* @param {string} verb - the short id of the verb we want to trigger
|
||||
* @param {oject} extra - extra properties for the xAPI statement
|
||||
*/
|
||||
|
@ -21,10 +21,10 @@ H5P.EventDispatcher.prototype.triggerXAPI = function(verb, extra) {
|
|||
|
||||
/**
|
||||
* Helper function to create event templates added to the EventDispatcher
|
||||
*
|
||||
*
|
||||
* Will in the future be used to add representations of the questions to the
|
||||
* statements.
|
||||
*
|
||||
*
|
||||
* @param {string} verb - verb id in short form
|
||||
* @param {object} extra - Extra values to be added to the statement
|
||||
* @returns {Function} - XAPIEvent object
|
||||
|
@ -55,11 +55,11 @@ H5P.EventDispatcher.prototype.triggerXAPICompleted = function(score, maxScore) {
|
|||
var event = this.createXAPIEventTemplate('completed');
|
||||
event.setScoredResult(score, maxScore);
|
||||
this.trigger(event);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal H5P function listening for xAPI completed events and stores scores
|
||||
*
|
||||
*
|
||||
* @param {function} event - xAPI event
|
||||
*/
|
||||
H5P.xAPICompletedListener = function(event) {
|
||||
|
@ -72,4 +72,4 @@ H5P.xAPICompletedListener = function(event) {
|
|||
H5P.setFinished(contentId, score, maxScore);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -548,7 +548,7 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) {
|
|||
* @returns {undefined}
|
||||
*/
|
||||
H5P.error = function (err) {
|
||||
if (window['console'] !== undefined && console.error !== undefined) {
|
||||
if (window.console !== undefined && console.error !== undefined) {
|
||||
console.error(err);
|
||||
}
|
||||
};
|
||||
|
@ -1244,7 +1244,7 @@ H5P.trigger = function(instance, eventType) {
|
|||
}
|
||||
// Try deprecated event system
|
||||
else if (instance.$ !== undefined && instance.$.trigger !== undefined) {
|
||||
instance.$.trigger(eventType)
|
||||
instance.$.trigger(eventType);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1268,6 +1268,6 @@ H5P.on = function(instance, eventType, handler) {
|
|||
}
|
||||
// Try deprecated event system
|
||||
else if (instance.$ !== undefined && instance.$.on !== undefined) {
|
||||
instance.$.on(eventType, handler)
|
||||
instance.$.on(eventType, handler);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue