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:
60
dist/scorm-again.js
vendored
60
dist/scorm-again.js
vendored
File diff suppressed because one or more lines are too long
2
dist/scorm-again.js.map
vendored
2
dist/scorm-again.js.map
vendored
File diff suppressed because one or more lines are too long
16
dist/scorm-again.min.js
vendored
16
dist/scorm-again.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "scorm-again",
|
"name": "scorm-again",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
|
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
|
||||||
"main": "dist/scorm-again.min.js",
|
"main": "dist/scorm-again.min.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ export function check12ValidRange(
|
|||||||
export class CMI extends BaseCMI {
|
export class CMI extends BaseCMI {
|
||||||
#_children = '';
|
#_children = '';
|
||||||
#_version = '3.4';
|
#_version = '3.4';
|
||||||
#suspend_data = '';
|
|
||||||
#launch_data = '';
|
#launch_data = '';
|
||||||
#comments = '';
|
#comments = '';
|
||||||
#comments_from_lms = '';
|
#comments_from_lms = '';
|
||||||
@@ -91,7 +90,9 @@ export class CMI extends BaseCMI {
|
|||||||
|
|
||||||
if (initialized) this.initialize();
|
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.core = new CMICore();
|
||||||
this.objectives = new CMIObjectives();
|
this.objectives = new CMIObjectives();
|
||||||
this.student_data = student_data ? student_data : new CMIStudentData();
|
this.student_data = student_data ? student_data : new CMIStudentData();
|
||||||
@@ -182,7 +183,7 @@ export class CMI extends BaseCMI {
|
|||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
get suspend_data() {
|
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
|
* @param {string} suspend_data
|
||||||
*/
|
*/
|
||||||
set suspend_data(suspend_data) {
|
set suspend_data(suspend_data) {
|
||||||
if (check12ValidFormat(suspend_data, scorm12_regex.CMIString4096, true)) {
|
if (this.core) {
|
||||||
this.#suspend_data = suspend_data;
|
this.core.suspend_data = suspend_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +298,7 @@ class CMICore extends BaseCMI {
|
|||||||
#lesson_mode = 'normal';
|
#lesson_mode = 'normal';
|
||||||
#exit = '';
|
#exit = '';
|
||||||
#session_time = '00:00:00';
|
#session_time = '00:00:00';
|
||||||
|
#suspend_data = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter for #_children
|
* 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.
|
* Adds the current session time to the existing total time.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -374,6 +374,17 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
fieldName: 'cmi.suspend_data',
|
fieldName: 'cmi.suspend_data',
|
||||||
valueToTest: '',
|
valueToTest: '',
|
||||||
});
|
});
|
||||||
|
h.checkFieldConstraintSize({
|
||||||
|
cmi: cmiInitialized(),
|
||||||
|
fieldName: 'cmi.core.suspend_data',
|
||||||
|
limit: 4096,
|
||||||
|
expectedError: type_mismatch,
|
||||||
|
});
|
||||||
|
h.checkWrite({
|
||||||
|
cmi: cmiInitialized(),
|
||||||
|
fieldName: 'cmi.core.suspend_data',
|
||||||
|
valueToTest: '',
|
||||||
|
});
|
||||||
h.checkReadOnly({
|
h.checkReadOnly({
|
||||||
cmi: cmiInitialized(),
|
cmi: cmiInitialized(),
|
||||||
fieldName: 'cmi.launch_data',
|
fieldName: 'cmi.launch_data',
|
||||||
|
|||||||
Reference in New Issue
Block a user