Skip to content

Commit

Permalink
Excluded SCORM 1.2 from the additional cmi.interactions context as …
Browse files Browse the repository at this point in the history
…it's implementation isn't as well defined or supported by many LMSs (see #281 (comment)).
  • Loading branch information
danielghost committed Dec 4, 2024
1 parent 0111c15 commit d041c70
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions js/scorm/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,24 +627,14 @@ class ScormWrapper {
return count === '' ? 0 : count;
}

recordInteractionScorm12(id, response, correct, latency, type, correctResponsesPattern, objectiveIds) {
recordInteractionScorm12(id, response, correct, latency, type) {
id = id.trim();
const cmiPrefix = `cmi.interactions.${this.getInteractionCount()}`;
this.setValue(`${cmiPrefix}.id`, id);
this.setValueIfChildSupported(`${cmiPrefix}.type`, type);
this.setValueIfChildSupported(`${cmiPrefix}.student_response`, response);
this.setValueIfChildSupported(`${cmiPrefix}.result`, correct ? 'correct' : 'wrong');
if (latency !== null && latency !== undefined) this.setValueIfChildSupported(`${cmiPrefix}.latency`, this.convertToSCORM12Time(latency));
if (this.isChildSupported(`${cmiPrefix}.correct_responses`) && correctResponsesPattern?.length) {
correctResponsesPattern.forEach((response, index) => {
this.setValue(`${cmiPrefix}.correct_responses.${index}.pattern`, response);
});
}
if (this.isChildSupported(`${cmiPrefix}.objectives`) && objectiveIds?.length) {
objectiveIds.forEach((id, index) => {
this.setValue(`${cmiPrefix}.objectives.${index}.id`, id);
});
}
this.setValueIfChildSupported(`${cmiPrefix}.time`, this.getCMITime());
}

Expand Down Expand Up @@ -680,7 +670,6 @@ class ScormWrapper {
} else {
response = response.replace(/#/g, ',');
response = this.checkResponse(response, 'choice');
correctResponsesPattern = correctResponsesPattern.map(response => response.replace(/\[,\]/g, ','));
}
const scormRecordInteraction = this.isSCORM2004() ? this.recordInteractionScorm2004 : this.recordInteractionScorm12;
scormRecordInteraction.call(this, id, response, correct, latency, type, correctResponsesPattern, objectiveIds, description);
Expand All @@ -692,8 +681,6 @@ class ScormWrapper {
response = response.replace(/,/g, '[,]').replace(/\./g, '[.]');
} else {
response = this.checkResponse(response, 'matching');
// @todo: source prefix on target is not allowed in SCORM 1.2 - see https://github.com/adaptlearning/adapt-contrib-matching/issues/199
correctResponsesPattern = correctResponsesPattern.map(response => response.replace(/\[\.\]/g, '.').replace(/\[,\]/g, ','));
}
const scormRecordInteraction = this.isSCORM2004() ? this.recordInteractionScorm2004 : this.recordInteractionScorm12;
scormRecordInteraction.call(this, id, response, correct, latency, type, correctResponsesPattern, objectiveIds, description);
Expand Down

0 comments on commit d041c70

Please sign in to comment.