Fixing an issue with CMI interactions not being loaded in the proper order

Interaction ID and Type need to be loaded before most other interaction fields, so I added a built in sort when loading using the flattened JSON load.
This commit is contained in:
Jonathan Putney
2020-07-28 22:36:37 -04:00
parent f4ab13ca8c
commit 1b48c9ee4d
7 changed files with 138 additions and 15 deletions

View File

@@ -819,8 +819,13 @@ export class CMIInteractionsObject extends BaseCMI {
* @param {string} type
*/
set type(type) {
if (check2004ValidFormat(type, scorm2004_regex.CMIType)) {
this.#type = type;
if (typeof this.id === 'undefined') {
throw new ValidationError(
scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
} else {
if (check2004ValidFormat(type, scorm2004_regex.CMIType)) {
this.#type = type;
}
}
}
@@ -874,7 +879,7 @@ export class CMIInteractionsObject extends BaseCMI {
* @param {string} learner_response
*/
set learner_response(learner_response) {
if (typeof this.type === 'undefined') {
if (typeof this.type === 'undefined' || typeof this.id === 'undefined') {
throw new ValidationError(
scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
} else {