cmi.core.suspend_data vs. cmi.suspend_data

It seems to be a common issue that some SCORM 1.2 modules are trying to store "suspend_data" in cmi.core.suspend_data instead of cmi.suspend_data, which is actually the correct field according to the spec. We're still only storing it once, but will allow getting and setting from cmi.core.suspend_data. Exported JSON will continue to only output spec compliant data.
This commit is contained in:
Jonathan Putney
2020-02-06 12:35:49 -05:00
parent de91be85e2
commit 3103707aec
6 changed files with 87 additions and 34 deletions

View File

@@ -73,7 +73,6 @@ export function check12ValidRange(
export class CMI extends BaseCMI {
#_children = '';
#_version = '3.4';
#suspend_data = '';
#launch_data = '';
#comments = '';
#comments_from_lms = '';
@@ -91,7 +90,9 @@ export class CMI extends BaseCMI {
if (initialized) this.initialize();
this.#_children = cmi_children ? cmi_children : scorm12_constants.cmi_children;
this.#_children = cmi_children ?
cmi_children :
scorm12_constants.cmi_children;
this.core = new CMICore();
this.objectives = new CMIObjectives();
this.student_data = student_data ? student_data : new CMIStudentData();
@@ -182,7 +183,7 @@ export class CMI extends BaseCMI {
* @return {string}
*/
get suspend_data() {
return this.#suspend_data;
return this.core?.suspend_data;
}
/**
@@ -190,8 +191,8 @@ export class CMI extends BaseCMI {
* @param {string} suspend_data
*/
set suspend_data(suspend_data) {
if (check12ValidFormat(suspend_data, scorm12_regex.CMIString4096, true)) {
this.#suspend_data = suspend_data;
if (this.core) {
this.core.suspend_data = suspend_data;
}
}
@@ -297,6 +298,7 @@ class CMICore extends BaseCMI {
#lesson_mode = 'normal';
#exit = '';
#session_time = '00:00:00';
#suspend_data = '';
/**
* Getter for #_children
@@ -486,6 +488,24 @@ class CMICore extends BaseCMI {
}
}
/**
* Getter for #suspend_data
* @return {string}
*/
get suspend_data() {
return this.#suspend_data;
}
/**
* Setter for #suspend_data
* @param {string} suspend_data
*/
set suspend_data(suspend_data) {
if (check12ValidFormat(suspend_data, scorm12_regex.CMIString4096, true)) {
this.#suspend_data = suspend_data;
}
}
/**
* Adds the current session time to the existing total time.
*