diff --git a/js/CMI5.js b/js/CMI5.js index f81925e..925055b 100644 --- a/js/CMI5.js +++ b/js/CMI5.js @@ -23,12 +23,12 @@ class CMI5 extends Backbone.Controller { auth: `Basic ${this.xapi.get('_auth')}`, activity_id: this.xapi.get('_activityId'), endpoint: this.xapi.get('_endpoint'), - strictCallbacks: true, + strictCallbacks: true }); this.xapi.set({ actor: this.xapi.get('_actor'), registration: this.xapi.get('_registration'), - activityId: this.xapi.get('_activityId'), + activityId: this.xapi.get('_activityId') }); const cmi5LaunchData = await this.getCmi5LaunchData(); if (this.isMasteryScoreSet(cmi5LaunchData)) { @@ -56,7 +56,7 @@ class CMI5 extends Backbone.Controller { _fetch: params.get('fetch'), _activityId: params.get('activityId'), _actor: JSON.parse(decodeURIComponent(params.get('actor'))), - _registration: params.get('registration'), + _registration: params.get('registration') }); } @@ -66,7 +66,7 @@ class CMI5 extends Backbone.Controller { if (!authToken) return; // Set the auth token in the model this.xapi.set({ - _auth: authToken, + _auth: authToken }); } @@ -82,7 +82,7 @@ class CMI5 extends Backbone.Controller { try { const fetchURL = this.xapi.get('_fetch'); const requestOptions = { - method: 'POST', + method: 'POST' }; const response = await fetch(fetchURL, requestOptions); if (!response.ok) { @@ -255,14 +255,14 @@ class CMI5 extends Backbone.Controller { (error, xhr) => { if (error) { logging.warn( - `adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences` + 'adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences' ); return reject(new Error(error)); } if (!xhr) { logging.warn( - `adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences` + 'adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences' ); return reject( new Error("'xhr' parameter is missing from callback") @@ -275,7 +275,7 @@ class CMI5 extends Backbone.Controller { if (xhr.status !== 200) { logging.warn( - `adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences` + 'adapt-contrib-xapi: getAgentProfile() failed for cmi5LearnerPreferences' ); return reject( new Error( @@ -379,10 +379,10 @@ class CMI5 extends Backbone.Controller { category: [ { id: 'https://w3id.org/xapi/cmi5/context/categories/cmi5', - objectType: 'Activity', - }, - ], - }, + objectType: 'Activity' + } + ] + } }; // Append the category and masteryScore. @@ -411,7 +411,7 @@ class CMI5 extends Backbone.Controller { context.contextActivities.category.push({ id: 'https://w3id.org/xapi/cmi5/context/categories/moveon', - objectType: 'Activity', + objectType: 'Activity' }); } @@ -425,13 +425,13 @@ class CMI5 extends Backbone.Controller { const { masteryScore } = this.xapi.get('launchData'); context.extensions ? context.extensions.push({ - 'https://w3id.org/xapi/cmi5/context/extensions/masteryscore': - masteryScore, - }) + 'https://w3id.org/xapi/cmi5/context/extensions/masteryscore': + masteryScore + }) : (context.extensions = { - 'https://w3id.org/xapi/cmi5/context/extensions/masteryscore': - masteryScore, - }); + 'https://w3id.org/xapi/cmi5/context/extensions/masteryscore': + masteryScore + }); } /** @@ -453,17 +453,17 @@ class CMI5 extends Backbone.Controller { ...(context?.contextActivities || {}), parent: [ ...(context?.contextActivities?.parent || []), - ...(contextActivities?.parent || []).filter(Boolean), + ...(contextActivities?.parent || []).filter(Boolean) ], grouping: [ ...(context?.contextActivities?.grouping || []), - ...(contextActivities?.grouping || []).filter(Boolean), - ], + ...(contextActivities?.grouping || []).filter(Boolean) + ] }, extensions: { ...(context?.extensions || {}), - ...(extensions || {}), - }, + ...(extensions || {}) + } }; statement.timestamp = new Date().toISOString(); @@ -489,7 +489,7 @@ class CMI5 extends Backbone.Controller { const conditions = { CompletedOrPassed: () => completionVerb === failed, Completed: () => completionVerb !== completed, - CompletedAndPassed: () => completionVerb === passed, + CompletedAndPassed: () => completionVerb === passed }; if (conditions[launchDataMoveOn]?.()) { diff --git a/js/XAPI.js b/js/XAPI.js index 0afa92f..46c938d 100644 --- a/js/XAPI.js +++ b/js/XAPI.js @@ -23,7 +23,7 @@ class XAPI extends Backbone.Model { componentBlacklist: 'blank,graphic', isInitialised: false, state: {}, - shouldListenToTracking: true, + shouldListenToTracking: true }; this.xapiWrapper = XAPIWrapper; @@ -883,7 +883,7 @@ class XAPI extends Backbone.Model { name[this.get('displayLang')] = assessment.id || 'Assessment'; object.definition = { - name: name, + name, type: window.ADL.activityTypes.assessment }; @@ -1115,7 +1115,7 @@ class XAPI extends Backbone.Model { } // Update the locally held state. - this.changedCollectionNames[collectionNames] = true; + this.changedCollectionNames[collectionName] = true; state[collectionName] = newState; this.set({ state @@ -1125,7 +1125,7 @@ class XAPI extends Backbone.Model { this.sendStateToServer(); } - sendStateToServer() { + async sendStateToServer() { const activityId = this.get('activityId'); const actor = this.get('actor'); const registration = this.get('shouldUseRegistration') === true @@ -1135,10 +1135,10 @@ class XAPI extends Backbone.Model { const changedCollectionNames = Object.keys(this.changedCollectionNames); this.changedCollectionNames = {}; - for (const collectionName of changeCollectionNames) { - const newState = this.get('state')[collectionName]; + for (const collectionName of changedCollectionNames) { + const newState = this.get('state')[collectionName]; - await new Promise(resolve => { + await new Promise(resolve => { this.xapiWrapper.sendState(activityId, actor, collectionName, registration, newState, null, null, (error, xhr) => { if (error) { Adapt.trigger('xapi:lrs:sendState:error', error); @@ -1164,7 +1164,7 @@ class XAPI extends Backbone.Model { const state = {}; try { - for (let type in this.coreObjects) { + for (const type in this.coreObjects) { await new Promise((resolve, reject) => { this.xapiWrapper.getState(activityId, actor, type, registration, null, (error, xhr) => { if (error) { @@ -1228,7 +1228,7 @@ class XAPI extends Backbone.Model { : null; try { - for (let type in this.coreObjects) { + for (const type in this.coreObjects) { await new Promise((resolve, reject) => { this.xapiWrapper.deleteState(activityId, actor, type, registration, null, null, (error, xhr) => { if (error) { @@ -1447,7 +1447,7 @@ class XAPI extends Backbone.Model { * @returns {boolean} */ isCORS(url) { - const urlparts = url.toLowerCase().match(/^(.+):\/\/([^:\/]*):?(\d+)?(\/.*)?$/); + const urlparts = url.toLowerCase().match(/^(.+):\/\/([^:/]*):?(\d+)?(\/.*)?$/); let isCORS = (location.protocol.toLowerCase().replace(':', '') !== urlparts[1] || location.hostname.toLowerCase() !== urlparts[2]); if (isCORS) return true; const urlPort = (urlparts[3] === null ? (urlparts[1] === 'http' ? '80' : '443') : urlparts[3]); @@ -1487,7 +1487,7 @@ class XAPI extends Backbone.Model { async processAttachments(statement) { const attachments = statement.attachments; - for (let attachment of attachments) { + for (const attachment of attachments) { await new Promise((resolve, reject) => { // First check the attachment for a value if (attachment.value) { @@ -1539,7 +1539,7 @@ class XAPI extends Backbone.Model { // Rather than calling the wrapper's sendStatements() function, iterate // over each statement and call sendStatement(). try { - for (let statement of statements) { + for (const statement of statements) { await this.sendStatement(statement); } } catch (error) {