Rework of constants and some additional tests
This commit is contained in:
732
dist/scorm-again.js
vendored
732
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
26
dist/scorm-again.min.js
vendored
26
dist/scorm-again.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,10 +1,13 @@
|
||||
// @flow
|
||||
import {CMIArray} from './cmi/common';
|
||||
import {ValidationError} from './exceptions';
|
||||
import {scorm12_error_codes} from './constants/error_codes';
|
||||
import {global_constants} from './constants/api_constants';
|
||||
import ErrorCodes from './constants/error_codes';
|
||||
import APIConstants from './constants/api_constants';
|
||||
import {unflatten} from './utilities';
|
||||
|
||||
const global_constants = APIConstants.global;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
/**
|
||||
* Base API class for AICC, SCORM 1.2, and SCORM 2004. Should be considered
|
||||
* abstract, and never initialized on it's own.
|
||||
@@ -186,7 +189,11 @@ export default class BaseAPI {
|
||||
this.lastErrorCode = e.errorCode;
|
||||
returnValue = global_constants.SCORM_FALSE;
|
||||
} else {
|
||||
console.error(e.getMessage());
|
||||
if (e.message) {
|
||||
console.error(e.message);
|
||||
} else {
|
||||
console.error(e);
|
||||
}
|
||||
this.throwSCORMError(this.#error_codes.GENERAL);
|
||||
}
|
||||
}
|
||||
@@ -533,6 +540,7 @@ export default class BaseAPI {
|
||||
|
||||
if (item) {
|
||||
refObject = item;
|
||||
foundFirstIndex = true;
|
||||
} else {
|
||||
const newChild = this.getChildElement(CMIElement, value,
|
||||
foundFirstIndex);
|
||||
|
||||
@@ -8,10 +8,12 @@ import {
|
||||
CMIObjectivesObject, NAV,
|
||||
} from './cmi/scorm12_cmi';
|
||||
import * as Utilities from './utilities';
|
||||
import {global_constants, scorm12_constants} from './constants/api_constants';
|
||||
import {scorm12_error_codes} from './constants/error_codes';
|
||||
import APIConstants from './constants/api_constants';
|
||||
import ErrorCodes from './constants/error_codes';
|
||||
|
||||
const constants = scorm12_constants;
|
||||
const scorm12_constants = APIConstants.scorm12;
|
||||
const global_constants = APIConstants.global;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
/**
|
||||
* API class for SCORM 1.2
|
||||
@@ -177,7 +179,8 @@ export default class Scorm12API extends BaseAPI {
|
||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||
'cmi\\.interactions\\.\\d\\.objectives\\.\\d')) {
|
||||
newChild = new CMIInteractionsObjectivesObject();
|
||||
} else if (this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
||||
} else if (!foundFirstIndex &&
|
||||
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
||||
newChild = new CMIInteractionsObject();
|
||||
}
|
||||
|
||||
@@ -208,9 +211,9 @@ export default class Scorm12API extends BaseAPI {
|
||||
|
||||
// Set error number to string since inconsistent from modules if string or number
|
||||
errorNumber = String(errorNumber);
|
||||
if (constants.error_descriptions[errorNumber]) {
|
||||
basicMessage = constants.error_descriptions[errorNumber].basicMessage;
|
||||
detailMessage = constants.error_descriptions[errorNumber].detailMessage;
|
||||
if (scorm12_constants.error_descriptions[errorNumber]) {
|
||||
basicMessage = scorm12_constants.error_descriptions[errorNumber].basicMessage;
|
||||
detailMessage = scorm12_constants.error_descriptions[errorNumber].detailMessage;
|
||||
}
|
||||
|
||||
return detail ? detailMessage : basicMessage;
|
||||
|
||||
@@ -10,13 +10,17 @@ import {
|
||||
CMIObjectivesObject,
|
||||
} from './cmi/scorm2004_cmi';
|
||||
import * as Utilities from './utilities';
|
||||
import {global_constants, scorm2004_constants} from './constants/api_constants';
|
||||
import {scorm2004_error_codes} from './constants/error_codes';
|
||||
import {correct_responses} from './constants/response_constants';
|
||||
import {valid_languages} from './constants/language_constants';
|
||||
import {scorm2004_regex} from './constants/regex';
|
||||
import APIConstants from './constants/api_constants';
|
||||
import ErrorCodes from './constants/error_codes';
|
||||
import Responses from './constants/response_constants';
|
||||
import ValidLanguages from './constants/language_constants';
|
||||
import Regex from './constants/regex';
|
||||
|
||||
const constants = scorm2004_constants;
|
||||
const scorm2004_constants = APIConstants.scorm2004;
|
||||
const global_constants = APIConstants.global;
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
const correct_responses = Responses.correct;
|
||||
const scorm2004_regex = Regex.scorm2004;
|
||||
|
||||
/**
|
||||
* API class for SCORM 2004
|
||||
@@ -190,7 +194,7 @@ export default class Scorm2004API extends BaseAPI {
|
||||
const parts = CMIElement.split('.');
|
||||
const index = Number(parts[2]);
|
||||
const interaction = this.cmi.interactions.childArray[index];
|
||||
if (typeof interaction.type === 'undefined') {
|
||||
if (!interaction.type) {
|
||||
this.throwSCORMError(scorm2004_error_codes.DEPENDENCY_NOT_ESTABLISHED);
|
||||
} else {
|
||||
const interaction_type = interaction.type;
|
||||
@@ -206,18 +210,23 @@ export default class Scorm2004API extends BaseAPI {
|
||||
}
|
||||
|
||||
const response_type = correct_responses[interaction_type];
|
||||
let nodes = [];
|
||||
if (response_type.delimiter !== '') {
|
||||
nodes = String(value).split(response_type.delimiter);
|
||||
} else {
|
||||
nodes[0] = value;
|
||||
}
|
||||
if (response_type) {
|
||||
let nodes = [];
|
||||
if (response_type?.delimiter) {
|
||||
nodes = String(value).split(response_type.delimiter);
|
||||
} else {
|
||||
nodes[0] = value;
|
||||
}
|
||||
|
||||
if (nodes.length > 0 && nodes.length <= response_type.max) {
|
||||
this.checkCorrectResponseValue(interaction_type, nodes, value);
|
||||
} else if (nodes.length > response_type.max) {
|
||||
if (nodes.length > 0 && nodes.length <= response_type.max) {
|
||||
this.checkCorrectResponseValue(interaction_type, nodes, value);
|
||||
} else if (nodes.length > response_type.max) {
|
||||
this.throwSCORMError(scorm2004_error_codes.GENERAL_SET_FAILURE,
|
||||
'Data Model Element Pattern Too Long');
|
||||
}
|
||||
} else {
|
||||
this.throwSCORMError(scorm2004_error_codes.GENERAL_SET_FAILURE,
|
||||
'Data Model Element Pattern Too Long');
|
||||
'Incorrect Response Type: ' + interaction_type);
|
||||
}
|
||||
}
|
||||
if (this.lastErrorCode === 0) {
|
||||
@@ -226,7 +235,8 @@ export default class Scorm2004API extends BaseAPI {
|
||||
} else if (foundFirstIndex && this.stringMatches(CMIElement,
|
||||
'cmi\\.interactions\\.\\d\\.objectives\\.\\d')) {
|
||||
newChild = new CMIInteractionsObjectivesObject();
|
||||
} else if (this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
||||
} else if (!foundFirstIndex &&
|
||||
this.stringMatches(CMIElement, 'cmi\\.interactions\\.\\d')) {
|
||||
newChild = new CMIInteractionsObject();
|
||||
} else if (this.stringMatches(CMIElement,
|
||||
'cmi\\.comments_from_learner\\.\\d')) {
|
||||
@@ -261,11 +271,11 @@ export default class Scorm2004API extends BaseAPI {
|
||||
}
|
||||
}
|
||||
|
||||
const response_type = scorm2004_constants.correct_responses[interaction_type];
|
||||
const response_type = correct_responses[interaction_type];
|
||||
if (typeof response_type.limit !== 'undefined' || interaction_count <
|
||||
response_type.limit) {
|
||||
let nodes = [];
|
||||
if (response_type.delimiter !== '') {
|
||||
if (response_type?.delimiter) {
|
||||
nodes = String(value).split(response_type.delimiter);
|
||||
} else {
|
||||
nodes[0] = value;
|
||||
@@ -319,9 +329,9 @@ export default class Scorm2004API extends BaseAPI {
|
||||
|
||||
// Set error number to string since inconsistent from modules if string or number
|
||||
errorNumber = String(errorNumber);
|
||||
if (constants.error_descriptions[errorNumber]) {
|
||||
basicMessage = constants.error_descriptions[errorNumber].basicMessage;
|
||||
detailMessage = constants.error_descriptions[errorNumber].detailMessage;
|
||||
if (scorm2004_constants.error_descriptions[errorNumber]) {
|
||||
basicMessage = scorm2004_constants.error_descriptions[errorNumber].basicMessage;
|
||||
detailMessage = scorm2004_constants.error_descriptions[errorNumber].detailMessage;
|
||||
}
|
||||
|
||||
return detail ? detailMessage : basicMessage;
|
||||
@@ -360,7 +370,7 @@ export default class Scorm2004API extends BaseAPI {
|
||||
nodes[i] = this.removeCorrectResponsePrefixes(nodes[i]);
|
||||
}
|
||||
|
||||
if (response.delimiter2 !== undefined) {
|
||||
if (response?.delimiter2) {
|
||||
const values = nodes[i].split(response.delimiter2);
|
||||
if (values.length === 2) {
|
||||
const matches = values[0].match(formatRegex);
|
||||
@@ -419,7 +429,7 @@ export default class Scorm2004API extends BaseAPI {
|
||||
if (langMatches) {
|
||||
const lang = langMatches[3];
|
||||
if (lang !== undefined && lang.length > 0) {
|
||||
if (valid_languages[lang.toLowerCase()] === undefined) {
|
||||
if (ValidLanguages[lang.toLowerCase()] === undefined) {
|
||||
this.throwSCORMError(scorm2004_error_codes.TYPE_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import * as Scorm12CMI from './scorm12_cmi';
|
||||
import {BaseCMI, CMIArray, CMIScore} from './common';
|
||||
import {aicc_constants} from '../constants/api_constants';
|
||||
import {aicc_regex} from '../constants/regex';
|
||||
import {scorm12_error_codes} from '../constants/error_codes';
|
||||
import APIConstants from '../constants/api_constants';
|
||||
import Regex from '../constants/regex';
|
||||
import ErrorCodes from '../constants/error_codes';
|
||||
import {
|
||||
check12ValidFormat,
|
||||
throwReadOnlyError,
|
||||
throwWriteOnlyError,
|
||||
} from './scorm12_cmi';
|
||||
|
||||
const constants = aicc_constants;
|
||||
const regex = aicc_regex;
|
||||
const aicc_constants = APIConstants.aicc;
|
||||
const aicc_regex = Regex.aicc;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
/**
|
||||
* CMI Class for AICC
|
||||
@@ -21,7 +22,7 @@ export class CMI extends Scorm12CMI.CMI {
|
||||
* @param {boolean} initialized
|
||||
*/
|
||||
constructor(initialized: boolean) {
|
||||
super(constants.cmi_children);
|
||||
super(aicc_constants.cmi_children);
|
||||
|
||||
if (initialized) this.initialize();
|
||||
|
||||
@@ -117,7 +118,7 @@ class CMIEvaluationComments extends CMIArray {
|
||||
* Constructor for AICC Evaluation Comments object
|
||||
*/
|
||||
constructor() {
|
||||
super(constants.comments_children,
|
||||
super(aicc_constants.comments_children,
|
||||
scorm12_error_codes.INVALID_SET_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -130,7 +131,7 @@ class AICCCMIStudentData extends Scorm12CMI.CMIStudentData {
|
||||
* Constructor for AICC StudentData object
|
||||
*/
|
||||
constructor() {
|
||||
super(constants.student_data_children);
|
||||
super(aicc_constants.student_data_children);
|
||||
|
||||
this.tries = new CMITries();
|
||||
}
|
||||
@@ -212,8 +213,8 @@ export class CMITriesObject extends BaseCMI {
|
||||
|
||||
this.score = new CMIScore(
|
||||
{
|
||||
score_children: constants.score_children,
|
||||
score_range: regex.score_range,
|
||||
score_children: aicc_constants.score_children,
|
||||
score_range: aicc_regex.score_range,
|
||||
invalidErrorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
invalidTypeCode: scorm12_error_codes.TYPE_MISMATCH,
|
||||
invalidRangeCode: scorm12_error_codes.VALUE_OUT_OF_RANGE,
|
||||
@@ -244,7 +245,7 @@ export class CMITriesObject extends BaseCMI {
|
||||
* @param {string} status
|
||||
*/
|
||||
set status(status) {
|
||||
if (check12ValidFormat(status, regex.CMIStatus2)) {
|
||||
if (check12ValidFormat(status, aicc_regex.CMIStatus2)) {
|
||||
this.#status = status;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +263,7 @@ export class CMITriesObject extends BaseCMI {
|
||||
* @param {string} time
|
||||
*/
|
||||
set time(time) {
|
||||
if (check12ValidFormat(time, regex.CMITime)) {
|
||||
if (check12ValidFormat(time, aicc_regex.CMITime)) {
|
||||
this.#time = time;
|
||||
}
|
||||
}
|
||||
@@ -317,7 +318,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
|
||||
* @param {string} content
|
||||
*/
|
||||
set content(content) {
|
||||
if (check12ValidFormat(content, regex.CMIString256)) {
|
||||
if (check12ValidFormat(content, aicc_regex.CMIString256)) {
|
||||
this.#content = content;
|
||||
}
|
||||
}
|
||||
@@ -335,7 +336,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
|
||||
* @param {string} location
|
||||
*/
|
||||
set location(location) {
|
||||
if (check12ValidFormat(location, regex.CMIString256)) {
|
||||
if (check12ValidFormat(location, aicc_regex.CMIString256)) {
|
||||
this.#location = location;
|
||||
}
|
||||
}
|
||||
@@ -353,7 +354,7 @@ export class CMIEvaluationCommentsObject extends BaseCMI {
|
||||
* @param {string} time
|
||||
*/
|
||||
set time(time) {
|
||||
if (check12ValidFormat(time, regex.CMITime)) {
|
||||
if (check12ValidFormat(time, aicc_regex.CMITime)) {
|
||||
this.#time = time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
// @flow
|
||||
import {scorm12_constants} from '../constants/api_constants';
|
||||
import {scorm12_error_codes} from '../constants/error_codes';
|
||||
import APIConstants from '../constants/api_constants';
|
||||
import ErrorCodes from '../constants/error_codes';
|
||||
import {ValidationError} from '../exceptions';
|
||||
import {scorm12_regex} from '../constants/regex';
|
||||
import Regex from '../constants/regex';
|
||||
|
||||
const scorm12_constants = APIConstants.scorm12;
|
||||
const scorm12_regex = Regex.scorm12;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
/**
|
||||
* Check if the value matches the proper format. If not, throw proper error code.
|
||||
|
||||
@@ -6,14 +6,15 @@ import {
|
||||
CMIArray,
|
||||
CMIScore,
|
||||
} from './common';
|
||||
import {scorm12_constants} from '../constants/api_constants';
|
||||
import {scorm12_error_codes} from '../constants/error_codes';
|
||||
import {scorm12_regex} from '../constants/regex';
|
||||
import APIConstants from '../constants/api_constants';
|
||||
import ErrorCodes from '../constants/error_codes';
|
||||
import Regex from '../constants/regex';
|
||||
import {ValidationError} from '../exceptions';
|
||||
import * as Utilities from '../utilities';
|
||||
|
||||
const constants = scorm12_constants;
|
||||
const regex = scorm12_regex;
|
||||
const scorm12_constants = APIConstants.scorm12;
|
||||
const scorm12_regex = Regex.scorm12;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
/**
|
||||
* Helper method for throwing Read Only error
|
||||
@@ -90,7 +91,7 @@ export class CMI extends BaseCMI {
|
||||
|
||||
if (initialized) this.initialize();
|
||||
|
||||
this.#_children = cmi_children ? cmi_children : 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();
|
||||
@@ -189,7 +190,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} suspend_data
|
||||
*/
|
||||
set suspend_data(suspend_data) {
|
||||
if (check12ValidFormat(suspend_data, regex.CMIString4096)) {
|
||||
if (check12ValidFormat(suspend_data, scorm12_regex.CMIString4096, true)) {
|
||||
this.#suspend_data = suspend_data;
|
||||
}
|
||||
}
|
||||
@@ -223,7 +224,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} comments
|
||||
*/
|
||||
set comments(comments) {
|
||||
if (check12ValidFormat(comments, regex.CMIString4096)) {
|
||||
if (check12ValidFormat(comments, scorm12_regex.CMIString4096)) {
|
||||
this.#comments = comments;
|
||||
}
|
||||
}
|
||||
@@ -269,8 +270,8 @@ class CMICore extends BaseCMI {
|
||||
|
||||
this.score = new CMIScore(
|
||||
{
|
||||
score_children: constants.score_children,
|
||||
score_range: regex.score_range,
|
||||
score_children: scorm12_constants.score_children,
|
||||
score_range: scorm12_regex.score_range,
|
||||
invalidErrorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
invalidTypeCode: scorm12_error_codes.TYPE_MISMATCH,
|
||||
invalidRangeCode: scorm12_error_codes.VALUE_OUT_OF_RANGE,
|
||||
@@ -285,7 +286,7 @@ class CMICore extends BaseCMI {
|
||||
this.score?.initialize();
|
||||
}
|
||||
|
||||
#_children = constants.core_children;
|
||||
#_children = scorm12_constants.core_children;
|
||||
#student_id = '';
|
||||
#student_name = '';
|
||||
#lesson_location = '';
|
||||
@@ -362,7 +363,7 @@ class CMICore extends BaseCMI {
|
||||
* @param {string} lesson_location
|
||||
*/
|
||||
set lesson_location(lesson_location) {
|
||||
if (check12ValidFormat(lesson_location, regex.CMIString256, true)) {
|
||||
if (check12ValidFormat(lesson_location, scorm12_regex.CMIString256, true)) {
|
||||
this.#lesson_location = lesson_location;
|
||||
}
|
||||
}
|
||||
@@ -396,7 +397,7 @@ class CMICore extends BaseCMI {
|
||||
* @param {string} lesson_status
|
||||
*/
|
||||
set lesson_status(lesson_status) {
|
||||
if (check12ValidFormat(lesson_status, regex.CMIStatus)) {
|
||||
if (check12ValidFormat(lesson_status, scorm12_regex.CMIStatus)) {
|
||||
this.#lesson_status = lesson_status;
|
||||
}
|
||||
}
|
||||
@@ -462,7 +463,7 @@ class CMICore extends BaseCMI {
|
||||
* @param {string} exit
|
||||
*/
|
||||
set exit(exit) {
|
||||
if (check12ValidFormat(exit, regex.CMIExit, true)) {
|
||||
if (check12ValidFormat(exit, scorm12_regex.CMIExit, true)) {
|
||||
this.#exit = exit;
|
||||
}
|
||||
}
|
||||
@@ -480,7 +481,7 @@ class CMICore extends BaseCMI {
|
||||
* @param {string} session_time
|
||||
*/
|
||||
set session_time(session_time) {
|
||||
if (check12ValidFormat(session_time, regex.CMITimespan)) {
|
||||
if (check12ValidFormat(session_time, scorm12_regex.CMITimespan)) {
|
||||
this.#session_time = session_time;
|
||||
}
|
||||
}
|
||||
@@ -545,7 +546,7 @@ class CMIObjectives extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.objectives_children,
|
||||
children: scorm12_constants.objectives_children,
|
||||
errorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
});
|
||||
}
|
||||
@@ -570,7 +571,7 @@ export class CMIStudentData extends BaseCMI {
|
||||
|
||||
this.#_children = student_data_children ?
|
||||
student_data_children :
|
||||
constants.student_data_children;
|
||||
scorm12_constants.student_data_children;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -680,7 +681,7 @@ class CMIStudentPreference extends BaseCMI {
|
||||
super();
|
||||
}
|
||||
|
||||
#_children = constants.student_preference_children;
|
||||
#_children = scorm12_constants.student_preference_children;
|
||||
#audio = '';
|
||||
#language = '';
|
||||
#speed = '';
|
||||
@@ -717,8 +718,8 @@ class CMIStudentPreference extends BaseCMI {
|
||||
* @param {string} audio
|
||||
*/
|
||||
set audio(audio) {
|
||||
if (check12ValidFormat(audio, regex.CMISInteger) &&
|
||||
check12ValidRange(audio, regex.audio_range)) {
|
||||
if (check12ValidFormat(audio, scorm12_regex.CMISInteger) &&
|
||||
check12ValidRange(audio, scorm12_regex.audio_range)) {
|
||||
this.#audio = audio;
|
||||
}
|
||||
}
|
||||
@@ -736,7 +737,7 @@ class CMIStudentPreference extends BaseCMI {
|
||||
* @param {string} language
|
||||
*/
|
||||
set language(language) {
|
||||
if (check12ValidFormat(language, regex.CMIString256)) {
|
||||
if (check12ValidFormat(language, scorm12_regex.CMIString256)) {
|
||||
this.#language = language;
|
||||
}
|
||||
}
|
||||
@@ -754,8 +755,8 @@ class CMIStudentPreference extends BaseCMI {
|
||||
* @param {string} speed
|
||||
*/
|
||||
set speed(speed) {
|
||||
if (check12ValidFormat(speed, regex.CMISInteger) &&
|
||||
check12ValidRange(speed, regex.speed_range)) {
|
||||
if (check12ValidFormat(speed, scorm12_regex.CMISInteger) &&
|
||||
check12ValidRange(speed, scorm12_regex.speed_range)) {
|
||||
this.#speed = speed;
|
||||
}
|
||||
}
|
||||
@@ -773,8 +774,8 @@ class CMIStudentPreference extends BaseCMI {
|
||||
* @param {string} text
|
||||
*/
|
||||
set text(text) {
|
||||
if (check12ValidFormat(text, regex.CMISInteger) &&
|
||||
check12ValidRange(text, regex.text_range)) {
|
||||
if (check12ValidFormat(text, scorm12_regex.CMISInteger) &&
|
||||
check12ValidRange(text, scorm12_regex.text_range)) {
|
||||
this.#text = text;
|
||||
}
|
||||
}
|
||||
@@ -814,7 +815,7 @@ class CMIInteractions extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.interactions_children,
|
||||
children: scorm12_constants.interactions_children,
|
||||
errorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
});
|
||||
}
|
||||
@@ -833,11 +834,11 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
|
||||
this.objectives = new CMIArray({
|
||||
errorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
children: constants.objectives_children,
|
||||
children: scorm12_constants.objectives_children,
|
||||
});
|
||||
this.correct_responses = new CMIArray({
|
||||
errorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
children: constants.correct_responses_children,
|
||||
children: scorm12_constants.correct_responses_children,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -871,7 +872,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check12ValidFormat(id, regex.CMIIdentifier)) {
|
||||
if (check12ValidFormat(id, scorm12_regex.CMIIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -889,7 +890,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} time
|
||||
*/
|
||||
set time(time) {
|
||||
if (check12ValidFormat(time, regex.CMITime)) {
|
||||
if (check12ValidFormat(time, scorm12_regex.CMITime)) {
|
||||
this.#time = time;
|
||||
}
|
||||
}
|
||||
@@ -907,7 +908,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} type
|
||||
*/
|
||||
set type(type) {
|
||||
if (check12ValidFormat(type, regex.CMIType)) {
|
||||
if (check12ValidFormat(type, scorm12_regex.CMIType)) {
|
||||
this.#type = type;
|
||||
}
|
||||
}
|
||||
@@ -927,8 +928,8 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} weighting
|
||||
*/
|
||||
set weighting(weighting) {
|
||||
if (check12ValidFormat(weighting, regex.CMIDecimal) &&
|
||||
check12ValidRange(weighting, regex.weighting_range)) {
|
||||
if (check12ValidFormat(weighting, scorm12_regex.CMIDecimal) &&
|
||||
check12ValidRange(weighting, scorm12_regex.weighting_range)) {
|
||||
this.#weighting = weighting;
|
||||
}
|
||||
}
|
||||
@@ -946,7 +947,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} student_response
|
||||
*/
|
||||
set student_response(student_response) {
|
||||
if (check12ValidFormat(student_response, regex.CMIFeedback, true)) {
|
||||
if (check12ValidFormat(student_response, scorm12_regex.CMIFeedback, true)) {
|
||||
this.#student_response = student_response;
|
||||
}
|
||||
}
|
||||
@@ -964,7 +965,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} result
|
||||
*/
|
||||
set result(result) {
|
||||
if (check12ValidFormat(result, regex.CMIResult)) {
|
||||
if (check12ValidFormat(result, scorm12_regex.CMIResult)) {
|
||||
this.#result = result;
|
||||
}
|
||||
}
|
||||
@@ -982,7 +983,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} latency
|
||||
*/
|
||||
set latency(latency) {
|
||||
if (check12ValidFormat(latency, regex.CMITimespan)) {
|
||||
if (check12ValidFormat(latency, scorm12_regex.CMITimespan)) {
|
||||
this.#latency = latency;
|
||||
}
|
||||
}
|
||||
@@ -1035,8 +1036,8 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
|
||||
this.score = new CMIScore(
|
||||
{
|
||||
score_children: constants.score_children,
|
||||
score_range: regex.score_range,
|
||||
score_children: scorm12_constants.score_children,
|
||||
score_range: scorm12_regex.score_range,
|
||||
invalidErrorCode: scorm12_error_codes.INVALID_SET_VALUE,
|
||||
invalidTypeCode: scorm12_error_codes.TYPE_MISMATCH,
|
||||
invalidRangeCode: scorm12_error_codes.VALUE_OUT_OF_RANGE,
|
||||
@@ -1059,7 +1060,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check12ValidFormat(id, regex.CMIIdentifier)) {
|
||||
if (check12ValidFormat(id, scorm12_regex.CMIIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1078,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} status
|
||||
*/
|
||||
set status(status) {
|
||||
if (check12ValidFormat(status, regex.CMIStatus2)) {
|
||||
if (check12ValidFormat(status, scorm12_regex.CMIStatus2)) {
|
||||
this.#status = status;
|
||||
}
|
||||
}
|
||||
@@ -1131,7 +1132,7 @@ export class CMIInteractionsObjectivesObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check12ValidFormat(id, regex.CMIIdentifier)) {
|
||||
if (check12ValidFormat(id, scorm12_regex.CMIIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -1181,7 +1182,7 @@ export class CMIInteractionsCorrectResponsesObject extends BaseCMI {
|
||||
* @param {string} pattern
|
||||
*/
|
||||
set pattern(pattern) {
|
||||
if (check12ValidFormat(pattern, regex.CMIFeedback, true)) {
|
||||
if (check12ValidFormat(pattern, scorm12_regex.CMIFeedback, true)) {
|
||||
this.#pattern = pattern;
|
||||
}
|
||||
}
|
||||
@@ -1230,7 +1231,7 @@ export class NAV extends BaseCMI {
|
||||
* @param {string} event
|
||||
*/
|
||||
set event(event) {
|
||||
if (check12ValidFormat(event, regex.NAVEvent)) {
|
||||
if (check12ValidFormat(event, scorm12_regex.NAVEvent)) {
|
||||
this.#event = event;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,15 +6,18 @@ import {
|
||||
CMIArray,
|
||||
CMIScore,
|
||||
} from './common';
|
||||
import {scorm2004_constants} from '../constants/api_constants';
|
||||
import {scorm2004_regex} from '../constants/regex';
|
||||
import {scorm2004_error_codes} from '../constants/error_codes';
|
||||
import {learner_responses} from '../constants/response_constants';
|
||||
import APIConstants from '../constants/api_constants';
|
||||
import Regex from '../constants/regex';
|
||||
import ErrorCodes from '../constants/error_codes';
|
||||
import Responses from '../constants/response_constants';
|
||||
import {ValidationError} from '../exceptions';
|
||||
import * as Util from '../utilities';
|
||||
|
||||
const constants = scorm2004_constants;
|
||||
const regex = scorm2004_regex;
|
||||
const scorm2004_constants = APIConstants.scorm2004;
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
const learner_responses = Responses.learner;
|
||||
|
||||
const scorm2004_regex = Regex.scorm2004;
|
||||
|
||||
/**
|
||||
* Helper method for throwing Read Only error
|
||||
@@ -85,7 +88,7 @@ export class CMI extends BaseCMI {
|
||||
}
|
||||
|
||||
#_version = '1.0';
|
||||
#_children = constants.cmi_children;
|
||||
#_children = scorm2004_constants.cmi_children;
|
||||
#completion_status = 'unknown';
|
||||
#completion_threshold = '';
|
||||
#credit = 'credit';
|
||||
@@ -167,7 +170,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} completion_status
|
||||
*/
|
||||
set completion_status(completion_status) {
|
||||
if (check2004ValidFormat(completion_status, regex.CMICStatus)) {
|
||||
if (check2004ValidFormat(completion_status, scorm2004_regex.CMICStatus)) {
|
||||
this.#completion_status = completion_status;
|
||||
}
|
||||
}
|
||||
@@ -235,7 +238,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} exit
|
||||
*/
|
||||
set exit(exit) {
|
||||
if (check2004ValidFormat(exit, regex.CMIExit, true)) {
|
||||
if (check2004ValidFormat(exit, scorm2004_regex.CMIExit, true)) {
|
||||
this.#exit = exit;
|
||||
}
|
||||
}
|
||||
@@ -303,7 +306,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} location
|
||||
*/
|
||||
set location(location) {
|
||||
if (check2004ValidFormat(location, regex.CMIString1000)) {
|
||||
if (check2004ValidFormat(location, scorm2004_regex.CMIString1000)) {
|
||||
this.#location = location;
|
||||
}
|
||||
}
|
||||
@@ -355,8 +358,8 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} progress_measure
|
||||
*/
|
||||
set progress_measure(progress_measure) {
|
||||
if (check2004ValidFormat(progress_measure, regex.CMIDecimal) &&
|
||||
check2004ValidRange(progress_measure, regex.progress_range)) {
|
||||
if (check2004ValidFormat(progress_measure, scorm2004_regex.CMIDecimal) &&
|
||||
check2004ValidRange(progress_measure, scorm2004_regex.progress_range)) {
|
||||
this.#progress_measure = progress_measure;
|
||||
}
|
||||
}
|
||||
@@ -392,7 +395,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} session_time
|
||||
*/
|
||||
set session_time(session_time) {
|
||||
if (check2004ValidFormat(session_time, regex.CMITimespan)) {
|
||||
if (check2004ValidFormat(session_time, scorm2004_regex.CMITimespan)) {
|
||||
this.#session_time = session_time;
|
||||
}
|
||||
}
|
||||
@@ -410,7 +413,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} success_status
|
||||
*/
|
||||
set success_status(success_status) {
|
||||
if (check2004ValidFormat(success_status, regex.CMISStatus)) {
|
||||
if (check2004ValidFormat(success_status, scorm2004_regex.CMISStatus)) {
|
||||
this.#success_status = success_status;
|
||||
}
|
||||
}
|
||||
@@ -428,7 +431,7 @@ export class CMI extends BaseCMI {
|
||||
* @param {string} suspend_data
|
||||
*/
|
||||
set suspend_data(suspend_data) {
|
||||
if (check2004ValidFormat(suspend_data, regex.CMIString64000, true)) {
|
||||
if (check2004ValidFormat(suspend_data, scorm2004_regex.CMIString64000, true)) {
|
||||
this.#suspend_data = suspend_data;
|
||||
}
|
||||
}
|
||||
@@ -547,7 +550,7 @@ export class CMI extends BaseCMI {
|
||||
* Class for SCORM 2004's cmi.learner_preference object
|
||||
*/
|
||||
class CMILearnerPreference extends BaseCMI {
|
||||
#_children = constants.student_preference_children;
|
||||
#_children = scorm2004_constants.student_preference_children;
|
||||
#audio_level = '1';
|
||||
#language = '';
|
||||
#delivery_speed = '1';
|
||||
@@ -591,8 +594,8 @@ class CMILearnerPreference extends BaseCMI {
|
||||
* @param {string} audio_level
|
||||
*/
|
||||
set audio_level(audio_level) {
|
||||
if (check2004ValidFormat(audio_level, regex.CMIDecimal) &&
|
||||
check2004ValidRange(audio_level, regex.audio_range)) {
|
||||
if (check2004ValidFormat(audio_level, scorm2004_regex.CMIDecimal) &&
|
||||
check2004ValidRange(audio_level, scorm2004_regex.audio_range)) {
|
||||
this.#audio_level = audio_level;
|
||||
}
|
||||
}
|
||||
@@ -610,7 +613,7 @@ class CMILearnerPreference extends BaseCMI {
|
||||
* @param {string} language
|
||||
*/
|
||||
set language(language) {
|
||||
if (check2004ValidFormat(language, regex.CMILang)) {
|
||||
if (check2004ValidFormat(language, scorm2004_regex.CMILang)) {
|
||||
this.#language = language;
|
||||
}
|
||||
}
|
||||
@@ -628,8 +631,8 @@ class CMILearnerPreference extends BaseCMI {
|
||||
* @param {string} delivery_speed
|
||||
*/
|
||||
set delivery_speed(delivery_speed) {
|
||||
if (check2004ValidFormat(delivery_speed, regex.CMIDecimal) &&
|
||||
check2004ValidRange(delivery_speed, regex.speed_range)) {
|
||||
if (check2004ValidFormat(delivery_speed, scorm2004_regex.CMIDecimal) &&
|
||||
check2004ValidRange(delivery_speed, scorm2004_regex.speed_range)) {
|
||||
this.#delivery_speed = delivery_speed;
|
||||
}
|
||||
}
|
||||
@@ -647,8 +650,8 @@ class CMILearnerPreference extends BaseCMI {
|
||||
* @param {string} audio_captioning
|
||||
*/
|
||||
set audio_captioning(audio_captioning) {
|
||||
if (check2004ValidFormat(audio_captioning, regex.CMISInteger) &&
|
||||
check2004ValidRange(audio_captioning, regex.text_range)) {
|
||||
if (check2004ValidFormat(audio_captioning, scorm2004_regex.CMISInteger) &&
|
||||
check2004ValidRange(audio_captioning, scorm2004_regex.text_range)) {
|
||||
this.#audio_captioning = audio_captioning;
|
||||
}
|
||||
}
|
||||
@@ -687,7 +690,7 @@ class CMIInteractions extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.interactions_children,
|
||||
children: scorm2004_constants.interactions_children,
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
});
|
||||
}
|
||||
@@ -702,7 +705,7 @@ class CMIObjectives extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.objectives_children,
|
||||
children: scorm2004_constants.objectives_children,
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
});
|
||||
}
|
||||
@@ -717,7 +720,7 @@ class CMICommentsFromLMS extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.comments_children,
|
||||
children: scorm2004_constants.comments_children,
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
});
|
||||
}
|
||||
@@ -732,7 +735,7 @@ class CMICommentsFromLearner extends CMIArray {
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
children: constants.comments_children,
|
||||
children: scorm2004_constants.comments_children,
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
});
|
||||
}
|
||||
@@ -759,11 +762,11 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
|
||||
this.objectives = new CMIArray({
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
children: constants.objectives_children,
|
||||
children: scorm2004_constants.objectives_children,
|
||||
});
|
||||
this.correct_responses = new CMIArray({
|
||||
errorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
children: constants.correct_responses_children,
|
||||
children: scorm2004_constants.correct_responses_children,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -789,7 +792,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check2004ValidFormat(id, regex.CMILongIdentifier)) {
|
||||
if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -807,7 +810,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} type
|
||||
*/
|
||||
set type(type) {
|
||||
if (check2004ValidFormat(type, regex.CMIType)) {
|
||||
if (check2004ValidFormat(type, scorm2004_regex.CMIType)) {
|
||||
this.#type = type;
|
||||
}
|
||||
}
|
||||
@@ -825,7 +828,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} timestamp
|
||||
*/
|
||||
set timestamp(timestamp) {
|
||||
if (check2004ValidFormat(timestamp, regex.CMITime)) {
|
||||
if (check2004ValidFormat(timestamp, scorm2004_regex.CMITime)) {
|
||||
this.#timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -843,7 +846,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} weighting
|
||||
*/
|
||||
set weighting(weighting) {
|
||||
if (check2004ValidFormat(weighting, regex.CMIDecimal)) {
|
||||
if (check2004ValidFormat(weighting, scorm2004_regex.CMIDecimal)) {
|
||||
this.#weighting = weighting;
|
||||
}
|
||||
}
|
||||
@@ -868,44 +871,48 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
} else {
|
||||
let nodes = [];
|
||||
const response_type = learner_responses[this.type];
|
||||
if (response_type.delimiter !== '') {
|
||||
nodes = learner_response.split(response_type.delimiter);
|
||||
} else {
|
||||
nodes[0] = learner_response;
|
||||
}
|
||||
if (response_type) {
|
||||
if (response_type?.delimiter) {
|
||||
nodes = learner_response.split(response_type.delimiter);
|
||||
} else {
|
||||
nodes[0] = learner_response;
|
||||
}
|
||||
|
||||
if ((nodes.length > 0) && (nodes.length <= response_type.max)) {
|
||||
const formatRegex = new RegExp(response_type.format);
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (typeof response_type.delimiter2 !== 'undefined') {
|
||||
const values = nodes[i].split(response_type.delimiter2);
|
||||
if (values.length === 2) {
|
||||
if (!values[0].match(formatRegex)) {
|
||||
throwTypeMismatchError();
|
||||
} else {
|
||||
if (!values[1].match(new RegExp(response_type.format2))) {
|
||||
if ((nodes.length > 0) && (nodes.length <= response_type.max)) {
|
||||
const formatRegex = new RegExp(response_type.format);
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (response_type?.delimiter2) {
|
||||
const values = nodes[i].split(response_type.delimiter2);
|
||||
if (values.length === 2) {
|
||||
if (!values[0].match(formatRegex)) {
|
||||
throwTypeMismatchError();
|
||||
} else {
|
||||
if (!values[1].match(new RegExp(response_type.format2))) {
|
||||
throwTypeMismatchError();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throwTypeMismatchError();
|
||||
}
|
||||
} else {
|
||||
throwTypeMismatchError();
|
||||
}
|
||||
} else {
|
||||
if (!nodes[i].match(formatRegex)) {
|
||||
throwTypeMismatchError();
|
||||
} else {
|
||||
if (nodes[i] !== '' && response_type.unique) {
|
||||
for (let j = 0; j < i; j++) {
|
||||
if (nodes[i] === nodes[j]) {
|
||||
throwTypeMismatchError();
|
||||
if (!nodes[i].match(formatRegex)) {
|
||||
throwTypeMismatchError();
|
||||
} else {
|
||||
if (nodes[i] !== '' && response_type.unique) {
|
||||
for (let j = 0; j < i; j++) {
|
||||
if (nodes[i] === nodes[j]) {
|
||||
throwTypeMismatchError();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ValidationError(scorm2004_error_codes.GENERAL_SET_FAILURE);
|
||||
}
|
||||
} else {
|
||||
throw new ValidationError(scorm2004_error_codes.GENERAL_SET_FAILURE);
|
||||
throw new ValidationError(scorm2004_error_codes.TYPE_MISMATCH);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -923,7 +930,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} result
|
||||
*/
|
||||
set result(result) {
|
||||
if (check2004ValidFormat(result, regex.CMIResult)) {
|
||||
if (check2004ValidFormat(result, scorm2004_regex.CMIResult)) {
|
||||
this.#result = result;
|
||||
}
|
||||
}
|
||||
@@ -941,7 +948,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} latency
|
||||
*/
|
||||
set latency(latency) {
|
||||
if (check2004ValidFormat(latency, regex.CMITimespan)) {
|
||||
if (check2004ValidFormat(latency, scorm2004_regex.CMITimespan)) {
|
||||
this.#latency = latency;
|
||||
}
|
||||
}
|
||||
@@ -959,7 +966,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
||||
* @param {string} description
|
||||
*/
|
||||
set description(description) {
|
||||
if (check2004ValidFormat(description, regex.CMILangString250, true)) {
|
||||
if (check2004ValidFormat(description, scorm2004_regex.CMILangString250, true)) {
|
||||
this.#description = description;
|
||||
}
|
||||
}
|
||||
@@ -1041,7 +1048,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check2004ValidFormat(id, regex.CMILongIdentifier)) {
|
||||
if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -1059,7 +1066,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} success_status
|
||||
*/
|
||||
set success_status(success_status) {
|
||||
if (check2004ValidFormat(success_status, regex.CMISStatus)) {
|
||||
if (check2004ValidFormat(success_status, scorm2004_regex.CMISStatus)) {
|
||||
this.#success_status = success_status;
|
||||
}
|
||||
}
|
||||
@@ -1077,7 +1084,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} completion_status
|
||||
*/
|
||||
set completion_status(completion_status) {
|
||||
if (check2004ValidFormat(completion_status, regex.CMICStatus)) {
|
||||
if (check2004ValidFormat(completion_status, scorm2004_regex.CMICStatus)) {
|
||||
this.#completion_status = completion_status;
|
||||
}
|
||||
}
|
||||
@@ -1095,8 +1102,8 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} progress_measure
|
||||
*/
|
||||
set progress_measure(progress_measure) {
|
||||
if (check2004ValidFormat(progress_measure, regex.CMIDecimal) &&
|
||||
check2004ValidRange(progress_measure, regex.progress_range)) {
|
||||
if (check2004ValidFormat(progress_measure, scorm2004_regex.CMIDecimal) &&
|
||||
check2004ValidRange(progress_measure, scorm2004_regex.progress_range)) {
|
||||
this.#progress_measure = progress_measure;
|
||||
}
|
||||
}
|
||||
@@ -1114,7 +1121,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
||||
* @param {string} description
|
||||
*/
|
||||
set description(description) {
|
||||
if (check2004ValidFormat(description, regex.CMILangString250, true)) {
|
||||
if (check2004ValidFormat(description, scorm2004_regex.CMILangString250, true)) {
|
||||
this.#description = description;
|
||||
}
|
||||
}
|
||||
@@ -1160,7 +1167,7 @@ class Scorm2004CMIScore extends CMIScore {
|
||||
constructor() {
|
||||
super(
|
||||
{
|
||||
score_children: constants.score_children,
|
||||
score_children: scorm2004_constants.score_children,
|
||||
max: '',
|
||||
invalidErrorCode: scorm2004_error_codes.READ_ONLY_ELEMENT,
|
||||
invalidTypeCode: scorm2004_error_codes.TYPE_MISMATCH,
|
||||
@@ -1182,8 +1189,8 @@ class Scorm2004CMIScore extends CMIScore {
|
||||
* @param {string} scaled
|
||||
*/
|
||||
set scaled(scaled) {
|
||||
if (check2004ValidFormat(scaled, regex.CMIDecimal) &&
|
||||
check2004ValidRange(scaled, regex.scaled_range)) {
|
||||
if (check2004ValidFormat(scaled, scorm2004_regex.CMIDecimal) &&
|
||||
check2004ValidRange(scaled, scorm2004_regex.scaled_range)) {
|
||||
this.#scaled = scaled;
|
||||
}
|
||||
}
|
||||
@@ -1250,7 +1257,7 @@ export class CMICommentsObject extends BaseCMI {
|
||||
if (this.initialized && this.#readOnlyAfterInit) {
|
||||
throwReadOnlyError();
|
||||
} else {
|
||||
if (check2004ValidFormat(comment, regex.CMILangString4000, true)) {
|
||||
if (check2004ValidFormat(comment, scorm2004_regex.CMILangString4000, true)) {
|
||||
this.#comment = comment;
|
||||
}
|
||||
}
|
||||
@@ -1272,7 +1279,7 @@ export class CMICommentsObject extends BaseCMI {
|
||||
if (this.initialized && this.#readOnlyAfterInit) {
|
||||
throwReadOnlyError();
|
||||
} else {
|
||||
if (check2004ValidFormat(location, regex.CMIString250)) {
|
||||
if (check2004ValidFormat(location, scorm2004_regex.CMIString250)) {
|
||||
this.#location = location;
|
||||
}
|
||||
}
|
||||
@@ -1294,7 +1301,7 @@ export class CMICommentsObject extends BaseCMI {
|
||||
if (this.initialized && this.#readOnlyAfterInit) {
|
||||
throwReadOnlyError();
|
||||
} else {
|
||||
if (check2004ValidFormat(timestamp, regex.CMITime)) {
|
||||
if (check2004ValidFormat(timestamp, scorm2004_regex.CMITime)) {
|
||||
this.#timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -1348,7 +1355,7 @@ export class CMIInteractionsObjectivesObject extends BaseCMI {
|
||||
* @param {string} id
|
||||
*/
|
||||
set id(id) {
|
||||
if (check2004ValidFormat(id, regex.CMILongIdentifier)) {
|
||||
if (check2004ValidFormat(id, scorm2004_regex.CMILongIdentifier)) {
|
||||
this.#id = id;
|
||||
}
|
||||
}
|
||||
@@ -1397,7 +1404,7 @@ export class CMIInteractionsCorrectResponsesObject extends BaseCMI {
|
||||
* @param {string} pattern
|
||||
*/
|
||||
set pattern(pattern) {
|
||||
if (check2004ValidFormat(pattern, regex.CMIFeedback)) {
|
||||
if (check2004ValidFormat(pattern, scorm2004_regex.CMIFeedback)) {
|
||||
this.#pattern = pattern;
|
||||
}
|
||||
}
|
||||
@@ -1497,7 +1504,7 @@ class ADLNav extends BaseCMI {
|
||||
* @param {string} request
|
||||
*/
|
||||
set request(request) {
|
||||
if (check2004ValidFormat(request, regex.NAVEvent)) {
|
||||
if (check2004ValidFormat(request, scorm2004_regex.NAVEvent)) {
|
||||
this.#request = request;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
|
||||
export const global_constants = {
|
||||
const global = {
|
||||
SCORM_TRUE: 'true',
|
||||
SCORM_FALSE: 'false',
|
||||
STATE_NOT_INITIALIZED: 0,
|
||||
@@ -13,7 +13,7 @@ export const global_constants = {
|
||||
LOG_LEVEL_NONE: 5,
|
||||
};
|
||||
|
||||
export const scorm12_constants = {
|
||||
const scorm12 = {
|
||||
// Children lists
|
||||
cmi_children: 'core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions',
|
||||
core_children: 'student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time',
|
||||
@@ -69,15 +69,15 @@ export const scorm12_constants = {
|
||||
},
|
||||
};
|
||||
|
||||
export const aicc_constants = {
|
||||
...scorm12_constants, ...{
|
||||
const aicc = {
|
||||
...scorm12, ...{
|
||||
cmi_children: 'core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions,evaluation',
|
||||
student_data_children: 'attempt_number,tries,mastery_score,max_time_allowed,time_limit_action',
|
||||
tries_children: 'time,status,score',
|
||||
},
|
||||
};
|
||||
|
||||
export const scorm2004_constants = {
|
||||
const scorm2004 = {
|
||||
// Children lists
|
||||
cmi_children: '_version,comments_from_learner,comments_from_lms,completion_status,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time',
|
||||
comments_children: 'comment,timestamp,location',
|
||||
@@ -195,3 +195,12 @@ export const scorm2004_constants = {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const APIConstants = {
|
||||
global: global,
|
||||
scorm12: scorm12,
|
||||
aicc: aicc,
|
||||
scorm2004: scorm2004,
|
||||
};
|
||||
|
||||
export default APIConstants;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @flow
|
||||
export const error_codes = {
|
||||
const global = {
|
||||
GENERAL: 101,
|
||||
INITIALIZATION_FAILED: 101,
|
||||
INITIALIZED: 101,
|
||||
@@ -30,8 +30,8 @@ export const error_codes = {
|
||||
DEPENDENCY_NOT_ESTABLISHED: 101,
|
||||
};
|
||||
|
||||
export const scorm12_error_codes = {
|
||||
...error_codes, ...{
|
||||
const scorm12 = {
|
||||
...global, ...{
|
||||
RETRIEVE_BEFORE_INIT: 301,
|
||||
STORE_BEFORE_INIT: 301,
|
||||
COMMIT_BEFORE_INIT: 301,
|
||||
@@ -50,8 +50,8 @@ export const scorm12_error_codes = {
|
||||
},
|
||||
};
|
||||
|
||||
export const scorm2004_error_codes = {
|
||||
...error_codes, ...{
|
||||
const scorm2004 = {
|
||||
...global, ...{
|
||||
INITIALIZATION_FAILED: 102,
|
||||
INITIALIZED: 103,
|
||||
TERMINATED: 104,
|
||||
@@ -78,3 +78,10 @@ export const scorm2004_error_codes = {
|
||||
DEPENDENCY_NOT_ESTABLISHED: 408,
|
||||
},
|
||||
};
|
||||
|
||||
const ErrorCodes = {
|
||||
scorm12: scorm12,
|
||||
scorm2004: scorm2004,
|
||||
};
|
||||
|
||||
export default ErrorCodes;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const valid_languages = {
|
||||
const ValidLanguages = {
|
||||
'aa': 'aa', 'ab': 'ab', 'ae': 'ae', 'af': 'af', 'ak': 'ak', 'am': 'am',
|
||||
'an': 'an', 'ar': 'ar', 'as': 'as', 'av': 'av', 'ay': 'ay', 'az': 'az',
|
||||
'ba': 'ba', 'be': 'be', 'bg': 'bg', 'bh': 'bh', 'bi': 'bi', 'bm': 'bm',
|
||||
@@ -72,3 +72,5 @@ export const valid_languages = {
|
||||
'vol': 'vol', 'wln': 'wln', 'wol': 'wol', 'xho': 'xho', 'yid': 'yid',
|
||||
'yor': 'yor', 'zha': 'zha', 'chi': 'chi', 'zho': 'zho', 'zul': 'zul',
|
||||
};
|
||||
|
||||
export default ValidLanguages;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
|
||||
export const scorm12_regex = {
|
||||
const scorm12 = {
|
||||
CMIString256: '^.{0,255}$',
|
||||
CMIString4096: '^.{0,4096}$',
|
||||
CMITime: '^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$', // eslint-disable-line
|
||||
@@ -28,13 +28,13 @@ export const scorm12_regex = {
|
||||
text_range: '-1#1',
|
||||
};
|
||||
|
||||
export const aicc_regex = {
|
||||
...scorm12_regex, ...{
|
||||
const aicc = {
|
||||
...scorm12, ...{
|
||||
CMIIdentifier: '^\\w{1,255}$',
|
||||
},
|
||||
};
|
||||
|
||||
export const scorm2004_regex = {
|
||||
const scorm2004 = {
|
||||
CMIString200: '^[\\u0000-\\uFFFF]{0,200}$',
|
||||
CMIString250: '^[\\u0000-\\uFFFF]{0,250}$',
|
||||
CMIString1000: '^[\\u0000-\\uFFFF]{0,1000}$',
|
||||
@@ -74,3 +74,11 @@ export const scorm2004_regex = {
|
||||
text_range: '-1#1',
|
||||
progress_range: '0#1',
|
||||
};
|
||||
|
||||
const Regex = {
|
||||
aicc: aicc,
|
||||
scorm12: scorm12,
|
||||
scorm2004: scorm2004,
|
||||
};
|
||||
|
||||
export default Regex;
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// @flow
|
||||
import {scorm2004_regex} from './regex';
|
||||
import Regex from './regex';
|
||||
|
||||
export const learner_responses = {
|
||||
const scorm2004_regex = Regex.scorm2004;
|
||||
|
||||
const learner = {
|
||||
'true-false': {
|
||||
format: '^true$|^false$',
|
||||
max: 1,
|
||||
@@ -69,7 +71,7 @@ export const learner_responses = {
|
||||
},
|
||||
};
|
||||
|
||||
export const correct_responses = {
|
||||
const correct = {
|
||||
'true-false': {
|
||||
max: 1,
|
||||
delimiter: '',
|
||||
@@ -150,3 +152,10 @@ export const correct_responses = {
|
||||
limit: 1,
|
||||
},
|
||||
};
|
||||
|
||||
const Responses = {
|
||||
learner: learner,
|
||||
correct: correct,
|
||||
};
|
||||
|
||||
export default Responses;
|
||||
|
||||
@@ -143,10 +143,10 @@ export function addTwoDurations(
|
||||
first: String,
|
||||
second: String,
|
||||
durationRegex: RegExp) {
|
||||
const firstSeconds = getDurationAsSeconds(first, durationRegex);
|
||||
const secondSeconds = getDurationAsSeconds(second, durationRegex);
|
||||
|
||||
return getSecondsAsISODuration(firstSeconds + secondSeconds);
|
||||
return getSecondsAsISODuration(
|
||||
getDurationAsSeconds(first, durationRegex) +
|
||||
getDurationAsSeconds(second, durationRegex),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,9 +161,11 @@ export function addHHMMSSTimeStrings(
|
||||
first: String,
|
||||
second: String,
|
||||
timeRegex: RegExp) {
|
||||
const firstSeconds = getTimeAsSeconds(first, timeRegex);
|
||||
const secondSeconds = getTimeAsSeconds(second, timeRegex);
|
||||
return getSecondsAsHHMMSS(firstSeconds + secondSeconds);
|
||||
return getSecondsAsHHMMSS(
|
||||
getTimeAsSeconds(first, timeRegex) +
|
||||
getTimeAsSeconds(
|
||||
second, timeRegex),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm12_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import AICC from '../src/AICC';
|
||||
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const api = () => {
|
||||
const API = new AICC();
|
||||
API.apiLogLevel = 1;
|
||||
|
||||
@@ -2,9 +2,11 @@ import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import Scorm12API from '../src/Scorm12API';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm12_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import {scorm12_values} from './field_values';
|
||||
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const api = (settings = {}) => {
|
||||
const API = new Scorm12API(settings);
|
||||
API.apiLogLevel = 1;
|
||||
@@ -278,6 +280,11 @@ describe('SCORM 1.2 API Tests', () => {
|
||||
fieldName: 'cmi.interactions.0.id',
|
||||
valueToTest: 'AAA',
|
||||
});
|
||||
h.checkLMSSetValue({
|
||||
api: apiInitialized(),
|
||||
fieldName: 'cmi.interactions.0.correct_responses.0.pattern',
|
||||
valueToTest: 't',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -307,6 +314,24 @@ describe('SCORM 1.2 API Tests', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('renderCommitCMI()', () => {
|
||||
it('if the user passes, should calculate total time when terminateCommit passed',
|
||||
() => {
|
||||
const scorm12API = api();
|
||||
scorm12API.cmi.core.score.max = '100';
|
||||
scorm12API.cmi.core.score.min = '0';
|
||||
scorm12API.cmi.core.score.raw = '100';
|
||||
scorm12API.cmi.core.exit = 'suspend';
|
||||
scorm12API.cmi.core.lesson_status = 'completed';
|
||||
scorm12API.cmi.core.total_time = '0000:00:00';
|
||||
scorm12API.cmi.core.session_time = '23:59:59';
|
||||
const cmiExport = scorm12API.renderCommitCMI(true);
|
||||
expect(
|
||||
cmiExport.cmi.core.total_time,
|
||||
).to.equal('23:59:59');
|
||||
});
|
||||
});
|
||||
|
||||
describe('storeData()', () => {
|
||||
it('should set cmi.core.lesson_status to "completed"', () => {
|
||||
const scorm12API = api();
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as h from './api_helpers';
|
||||
import {scorm2004_error_codes} from '../src/constants/error_codes';
|
||||
import ErrorCodes from '../src/constants/error_codes';
|
||||
import Scorm2004API from '../src/Scorm2004API';
|
||||
import {scorm2004_values} from './field_values';
|
||||
|
||||
const api = () => {
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
|
||||
const api = (startingData) => {
|
||||
const API = new Scorm2004API();
|
||||
API.apiLogLevel = 1;
|
||||
if (startingData) {
|
||||
API.startingData = startingData;
|
||||
}
|
||||
return API;
|
||||
};
|
||||
const apiInitialized = () => {
|
||||
const apiInitialized = (startingData) => {
|
||||
const API = api();
|
||||
if (startingData) {
|
||||
API.startingData = startingData;
|
||||
}
|
||||
API.lmsInitialize();
|
||||
return API;
|
||||
};
|
||||
@@ -288,6 +296,15 @@ describe('SCORM 2004 API Tests', () => {
|
||||
valueToTest: scorm2004_values.validTimestamps[0],
|
||||
errorThrown: false,
|
||||
});
|
||||
it('should allow cmi.interactions.0.correct_responses.0.pattern to be set',
|
||||
() => {
|
||||
const scorm2004API = apiInitialized();
|
||||
scorm2004API.setCMIValue('cmi.interactions.0.type', 'true-false');
|
||||
scorm2004API.setCMIValue('cmi.interactions.0.correct_responses.0.pattern', 'true');
|
||||
expect(
|
||||
String(scorm2004API.lmsGetLastError())
|
||||
).to.equal(String(0));
|
||||
});
|
||||
});
|
||||
|
||||
describe('Initialized - Should Fail', () => {
|
||||
@@ -323,7 +340,7 @@ describe('SCORM 2004 API Tests', () => {
|
||||
scorm2004API.cmi.session_time = 'PT23H59M59S';
|
||||
const cmiExport = scorm2004API.renderCommitCMI(true);
|
||||
expect(
|
||||
cmiExport.cmi.total_time
|
||||
cmiExport.cmi.total_time,
|
||||
).to.equal('P1DT12H34M55S');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, it} from 'mocha';
|
||||
import {aicc_constants} from '../../src/constants/api_constants';
|
||||
import {scorm12_error_codes} from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import {
|
||||
CMI,
|
||||
CMIEvaluationCommentsObject,
|
||||
@@ -15,6 +15,9 @@ import {
|
||||
import {expect} from 'chai';
|
||||
import {scorm12_values} from '../field_values';
|
||||
|
||||
const aicc_constants = APIConstants.aicc;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||
const write_only = scorm12_error_codes.WRITE_ONLY_ELEMENT;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import {scorm12_constants} from '../../src/constants/api_constants';
|
||||
import {scorm12_error_codes} from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import {
|
||||
CMI,
|
||||
CMIInteractionsCorrectResponsesObject,
|
||||
@@ -12,6 +12,9 @@ import {
|
||||
import * as h from '../cmi_helpers';
|
||||
import {scorm12_values} from '../field_values';
|
||||
|
||||
const scorm12 = APIConstants.scorm12;
|
||||
const scorm12_error_codes = ErrorCodes.scorm12;
|
||||
|
||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||
const write_only = scorm12_error_codes.WRITE_ONLY_ELEMENT;
|
||||
@@ -101,7 +104,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi._children',
|
||||
expectedValue: scorm12_constants.cmi_children,
|
||||
expectedValue: scorm12.cmi_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkFieldConstraintSize({
|
||||
@@ -131,7 +134,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.core._children',
|
||||
expectedValue: scorm12_constants.core_children,
|
||||
expectedValue: scorm12.core_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadAndWrite({
|
||||
@@ -206,7 +209,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.core.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
@@ -247,7 +250,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.objectives._children',
|
||||
expectedValue: scorm12_constants.objectives_children,
|
||||
expectedValue: scorm12.objectives_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -263,7 +266,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.student_data._children',
|
||||
expectedValue: scorm12_constants.student_data_children,
|
||||
expectedValue: scorm12.student_data_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadAndWrite({
|
||||
@@ -285,7 +288,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.student_preference._children',
|
||||
expectedValue: scorm12_constants.student_preference_children,
|
||||
expectedValue: scorm12.student_preference_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
@@ -333,7 +336,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmi(),
|
||||
fieldName: 'cmi.interactions._children',
|
||||
expectedValue: scorm12_constants.interactions_children,
|
||||
expectedValue: scorm12.interactions_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -357,7 +360,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi._children',
|
||||
expectedValue: scorm12_constants.cmi_children,
|
||||
expectedValue: scorm12.cmi_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkFieldConstraintSize({
|
||||
@@ -366,6 +369,11 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
limit: 4096,
|
||||
expectedError: type_mismatch,
|
||||
});
|
||||
h.checkWrite({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.suspend_data',
|
||||
valueToTest: '',
|
||||
});
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.launch_data',
|
||||
@@ -389,7 +397,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.core._children',
|
||||
expectedValue: scorm12_constants.core_children,
|
||||
expectedValue: scorm12.core_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -470,7 +478,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.core.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkValidValues({
|
||||
@@ -498,7 +506,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.objectives._children',
|
||||
expectedValue: scorm12_constants.objectives_children,
|
||||
expectedValue: scorm12.objectives_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -514,7 +522,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.student_data._children',
|
||||
expectedValue: scorm12_constants.student_data_children,
|
||||
expectedValue: scorm12.student_data_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -539,7 +547,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.student_preference._children',
|
||||
expectedValue: scorm12_constants.student_preference_children,
|
||||
expectedValue: scorm12.student_preference_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkValidValues({
|
||||
@@ -573,7 +581,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: cmiInitialized(),
|
||||
fieldName: 'cmi.interactions._children',
|
||||
expectedValue: scorm12_constants.interactions_children,
|
||||
expectedValue: scorm12.interactions_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkReadOnly({
|
||||
@@ -768,7 +776,7 @@ describe('SCORM 1.2 CMI Tests', () => {
|
||||
h.checkReadOnly({
|
||||
cmi: objective(),
|
||||
fieldName: 'cmi.score._children',
|
||||
expectedValue: scorm12_constants.score_children,
|
||||
expectedValue: scorm12.score_children,
|
||||
expectedError: invalid_set,
|
||||
});
|
||||
h.checkRead({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {describe, it} from 'mocha';
|
||||
import {scorm2004_error_codes} from '../../src/constants/error_codes';
|
||||
import {scorm2004_constants} from '../../src/constants/api_constants';
|
||||
import ErrorCodes from '../../src/constants/error_codes';
|
||||
import APIConstants from '../../src/constants/api_constants';
|
||||
import {
|
||||
ADL,
|
||||
CMI,
|
||||
@@ -14,6 +14,9 @@ import * as h from '../cmi_helpers';
|
||||
import {expect} from 'chai';
|
||||
import {scorm2004_values} from '../field_values';
|
||||
|
||||
const scorm2004_constants = APIConstants.scorm2004;
|
||||
const scorm2004_error_codes = ErrorCodes.scorm2004;
|
||||
|
||||
const read_only = scorm2004_error_codes.READ_ONLY_ELEMENT;
|
||||
const write_only = scorm2004_error_codes.WRITE_ONLY_ELEMENT;
|
||||
const type_mismatch = scorm2004_error_codes.TYPE_MISMATCH;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {expect} from 'chai';
|
||||
import {describe, it} from 'mocha';
|
||||
import * as Utilities from '../src/utilities';
|
||||
import {scorm12_regex, scorm2004_regex} from '../src/constants/regex';
|
||||
import Regex from '../src/constants/regex';
|
||||
|
||||
const scorm12_regex = Regex.scorm12;
|
||||
const scorm2004_regex = Regex.scorm2004;
|
||||
|
||||
describe('Utility Tests', () => {
|
||||
describe('getSecondsAsHHMMSS()', () => {
|
||||
|
||||
Reference in New Issue
Block a user