Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Changed logic for 401 error handling #303

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions js/scorm/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,24 +368,19 @@ class ScormWrapper {
this.logger.info('ScormWrapper::recordInteraction: cmi.interactions are not supported by this LMS...');
return;
}

switch (type) {
case 'choice':
this.recordInteractionMultipleChoice.apply(this, arguments);
break;

case 'matching':
this.recordInteractionMatching.apply(this, arguments);
break;

case 'numeric':
this.isSCORM2004() ? this.recordInteractionScorm2004.apply(this, arguments) : this.recordInteractionScorm12.apply(this, arguments);
break;

case 'fill-in':
this.recordInteractionFillIn.apply(this, arguments);
break;

default:
console.error(`ScormWrapper.recordInteraction: unknown interaction type of '${type}' encountered...`);
}
Expand Down Expand Up @@ -474,19 +469,20 @@ class ScormWrapper {
*/
isSupported(property) {
this.logger.debug(`ScormWrapper::isSupported: _property=${property}`);

if (this.finishCalled) {
this.logger.debug('ScormWrapper::isSupported: ignoring request as \'finish\' has been called');
return;
}

if (!this.lmsConnected) {
this.handleConnectionError();
return false;
}

this.scorm.get(property);
return (this.scorm.debug.getCode() !== 401); // 401 is the 'not implemented' error code
return !this.isUnsupportedErrorCode(this.scorm.debug.getCode());
}

isUnsupportedErrorCode(code) {
return code === 401;
}

initTimedCommit() {
Expand Down Expand Up @@ -528,7 +524,7 @@ class ScormWrapper {

async handleDataError(error) {
if (!Data.isReady) await Data.whenReady();
Adapt.trigger('tracking:dataError');
if (!this.isUnsupportedErrorCode(error.data.errorCode)) Adapt.trigger('tracking:dataError');
this.handleError(error);
}

Expand All @@ -551,6 +547,8 @@ class ScormWrapper {
const config = Adapt.course.get('_spoor');
const messages = Object.assign({}, ScormError.defaultMessages, config && config._messages);
const message = Handlebars.compile(messages[error.name])(error.data);
this.logger.error(message);
if (this.isUnsupportedErrorCode(error.data.errorCode)) return;
switch (error.name) {
case CLIENT_COULD_NOT_CONNECT:
// don't show if error notification already handled by other plugins
Expand All @@ -565,7 +563,6 @@ class ScormWrapper {
});
}
}
this.logger.error(message);
if (!this.suppressErrors && (!this.logOutputWin || this.logOutputWin.closed) && confirm(`${messages.title}:\n\n${message}\n\n${messages.pressOk}`)) {
this.showDebugWindow();
}
Expand Down