diff --git a/src/BaseAPI.js b/src/BaseAPI.js index d16add7..4bd4d80 100644 --- a/src/BaseAPI.js +++ b/src/BaseAPI.js @@ -722,7 +722,7 @@ class ScheduledCommit { #wrapper = () => { if (!_self.#cancelled) { - _self.#API.LMSCommit(); + _self.#API.commit(); } }; } diff --git a/src/Scorm12API.js b/src/Scorm12API.js index 8a760c3..126a9e5 100644 --- a/src/Scorm12API.js +++ b/src/Scorm12API.js @@ -8,7 +8,8 @@ import { CMIObjectivesObject, } from './cmi/scorm12_cmi'; import * as Utilities from './utilities'; -import {scorm12_constants, scorm12_error_codes} from './constants'; +import {scorm12_constants} from './constants/api_constants'; +import {scorm12_error_codes} from './constants/error_codes'; import {scorm12_regex} from './regex'; const constants = scorm12_constants; diff --git a/src/Scorm2004API.js b/src/Scorm2004API.js index 982be97..94920fb 100644 --- a/src/Scorm2004API.js +++ b/src/Scorm2004API.js @@ -11,15 +11,13 @@ import { CMIObjectivesObject, } from './cmi/scorm2004_cmi'; import * as Util from './utilities'; -import { - correct_responses, - scorm2004_constants, - scorm2004_error_codes, -} from './constants'; +import {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 './regex'; const constants = scorm2004_constants; -const valid_languages = constants.valid_languages; let _self; /** @@ -105,7 +103,7 @@ class Scorm2004API extends BaseAPI { * @return {string} */ LMSGetErrorString(CMIErrorCode) { - return _self.APIGetErrorString('GetErrorString', CMIErrorCode); + return _self.getErrorString('GetErrorString', CMIErrorCode); } /** @@ -115,7 +113,7 @@ class Scorm2004API extends BaseAPI { * @return {string} */ LMSGetDiagnostic(CMIErrorCode) { - return _self.APIGetDiagnostic('GetDiagnostic', CMIErrorCode); + return _self.getDiagnostic('GetDiagnostic', CMIErrorCode); } /** diff --git a/src/cmi/aicc_cmi.js b/src/cmi/aicc_cmi.js index 42f72e0..74e045c 100644 --- a/src/cmi/aicc_cmi.js +++ b/src/cmi/aicc_cmi.js @@ -1,6 +1,6 @@ import * as Scorm12CMI from './scorm12_cmi'; import {BaseCMI, CMIArray, CMIScore} from './common'; -import {aicc_constants, scorm12_error_codes} from '../constants'; +import {aicc_constants, scorm12_error_codes} from '../constants/api_constants'; import {aicc_regex} from '../regex'; const constants = aicc_constants; diff --git a/src/cmi/common.js b/src/cmi/common.js index 07c1e3e..5214ca7 100644 --- a/src/cmi/common.js +++ b/src/cmi/common.js @@ -1,90 +1,109 @@ -import {scorm12_constants, scorm12_error_codes} from "../constants"; +import {scorm12_constants} from '../constants/api_constants'; +import {scorm12_error_codes} from '../constants/error_codes'; export class BaseCMI { jsonString = false; API; constructor(API: any) { - this.API = API; + this.API = API; } } export class CMIScore extends BaseCMI { - constructor(API, score_children?, score_range?, invalidErrorCode) { - super(API); + constructor(API, score_children?, score_range?, invalidErrorCode) { + super(API); - this.#_children = score_children? score_children : scorm12_constants.score_children; - this.#_score_range = score_range? score_range : false; - this.#_invalid_error_code = invalidErrorCode ? invalidErrorCode : scorm12_error_codes.INVALID_SET_VALUE; - } + this.#_children = score_children? score_children : scorm12_constants.score_children; + this.#_score_range = score_range? score_range : false; + this.#_invalid_error_code = invalidErrorCode ? invalidErrorCode : scorm12_error_codes.INVALID_SET_VALUE; + } #_children; #_score_range; #_invalid_error_code; - #raw = ""; - #min = ""; - #max = "100"; + #raw = ''; + #min = ''; + #max = '100'; - get _children() { return this.#_children; } - set _children(_children) { this.API.throwSCORMError(this.#_invalid_error_code); } + get _children() { + return this.#_children; + } + set _children(_children) { + this.API.throwSCORMError(this.#_invalid_error_code); + } - get raw() { return this.#raw; } + get raw() { + return this.#raw; + } set raw(raw) { - if(this.API.checkValidFormat(raw, scorm12_constants.CMIDecimal) - && (!this.#_score_range || this.API.checkValidRange(raw, this.#_score_range))) { - this.#raw = raw; - } + if (this.API.checkValidFormat(raw, scorm12_constants.CMIDecimal) && + (!this.#_score_range || this.API.checkValidRange(raw, this.#_score_range))) { + this.#raw = raw; + } } - get min() { return this.#min; } + get min() { + return this.#min; + } set min(min) { - if(this.API.checkValidFormat(min, scorm12_constants.CMIDecimal) - && (!this.#_score_range || this.API.checkValidRange(min, this.#_score_range))) { - this.#min = min; - } + if (this.API.checkValidFormat(min, scorm12_constants.CMIDecimal) && + (!this.#_score_range || this.API.checkValidRange(min, this.#_score_range))) { + this.#min = min; + } } - get max() { return this.#max; } + get max() { + return this.#max; + } set max(max) { - if(this.API.checkValidFormat(max, scorm12_constants.CMIDecimal) - && (!this.#_score_range || this.API.checkValidRange(max, this.#_score_range))) { - this.#max = max; - } + if (this.API.checkValidFormat(max, scorm12_constants.CMIDecimal) && + (!this.#_score_range || this.API.checkValidRange(max, this.#_score_range))) { + this.#max = max; + } } toJSON = () => { - return { - 'raw': this.raw, - 'min': this.min, - 'max': this.max - } + return { + 'raw': this.raw, + 'min': this.min, + 'max': this.max, + }; } } export class CMIArray extends BaseCMI { - constructor({API, children, errorCode}) { - super(API); - this.#_children = children; - this.#errorCode = errorCode; - this.childArray = []; - } + constructor({API, children, errorCode}) { + super(API); + this.#_children = children; + this.#errorCode = errorCode; + this.childArray = []; + } #errorCode; #_children; - get _children() { return this.#_children; } - set _children(_children) { this.API.throwSCORMError(this.#errorCode); } + get _children() { + return this.#_children; + } + set _children(_children) { + this.API.throwSCORMError(this.#errorCode); + } - get _count() { return this.childArray.length; } - set _count(_count) { this.API.throwSCORMError(this.#errorCode); } + get _count() { + return this.childArray.length; + } + set _count(_count) { + this.API.throwSCORMError(this.#errorCode); + } toJSON = () => { - this.jsonString = true; - let result = {}; - for(let i = 0; i < this.childArray.length; i++) { - result[i + ''] = this.childArray[i]; - } - delete this.jsonString; - return result; + this.jsonString = true; + const result = {}; + for (let i = 0; i < this.childArray.length; i++) { + result[i + ''] = this.childArray[i]; + } + delete this.jsonString; + return result; } } diff --git a/src/cmi/scorm12_cmi.js b/src/cmi/scorm12_cmi.js index 2b748fa..a3f05b8 100644 --- a/src/cmi/scorm12_cmi.js +++ b/src/cmi/scorm12_cmi.js @@ -1,5 +1,6 @@ import {BaseCMI, CMIArray, CMIScore} from './common'; -import {scorm12_constants, scorm12_error_codes} from '../constants'; +import {scorm12_constants} from '../constants/api_constants'; +import {scorm12_error_codes} from '../constants/error_codes'; import {scorm12_regex} from '../regex'; const constants = scorm12_constants; diff --git a/src/cmi/scorm2004_cmi.js b/src/cmi/scorm2004_cmi.js index 50a9470..8fa95ed 100644 --- a/src/cmi/scorm2004_cmi.js +++ b/src/cmi/scorm2004_cmi.js @@ -1,5 +1,5 @@ import {BaseCMI, CMIArray, CMIScore} from './common'; -import {learner_responses, scorm2004_constants, scorm2004_error_codes} from "../constants"; +import {learner_responses, scorm2004_constants, scorm2004_error_codes} from "../constants/api_constants"; import {scorm2004_regex} from "../regex"; const constants = scorm2004_constants; diff --git a/src/constants.js b/src/constants.js deleted file mode 100644 index 1482f86..0000000 --- a/src/constants.js +++ /dev/null @@ -1,807 +0,0 @@ -// @flow -import {scorm2004_regex} from "./regex"; - -export const base_error_codes = { - GENERAL: 101, - INITIALIZATION_FAILED: 101, - INITIALIZED: 101, - TERMINATED: 101, - TERMINATION_FAILURE: 101, - TERMINATION_BEFORE_INIT: 101, - MULTIPLE_TERMINATION: 101, - RETRIEVE_BEFORE_INIT: 101, - RETRIEVE_AFTER_TERM: 101, - STORE_BEFORE_INIT: 101, - STORE_AFTER_TERM: 101, - COMMIT_BEFORE_INIT: 101, - COMMIT_AFTER_TERM: 101, - ARGUMENT_ERROR: 101, - CHILDREN_ERROR: 101, - COUNT_ERROR: 101, - GENERAL_GET_FAILURE: 101, - GENERAL_SET_FAILURE: 101, - GENERAL_COMMIT_FAILURE: 101, - UNDEFINED_DATA_MODEL: 101, - UNIMPLEMENTED_ELEMENT: 101, - VALUE_NOT_INITIALIZED: 101, - INVALID_SET_VALUE: 101, - READ_ONLY_ELEMENT: 101, - WRITE_ONLY_ELEMENT: 101, - TYPE_MISMATCH: 101, - VALUE_OUT_OF_RANGE: 101, - DEPENDENCY_NOT_ESTABLISHED: 101 -}; - -export const scorm12_error_codes = { - ...base_error_codes, ...{ - RETRIEVE_BEFORE_INIT: 301, - STORE_BEFORE_INIT: 301, - COMMIT_BEFORE_INIT: 301, - ARGUMENT_ERROR: 201, - CHILDREN_ERROR: 202, - COUNT_ERROR: 203, - UNDEFINED_DATA_MODEL: 401, - UNIMPLEMENTED_ELEMENT: 401, - VALUE_NOT_INITIALIZED: 301, - INVALID_SET_VALUE: 402, - READ_ONLY_ELEMENT: 403, - WRITE_ONLY_ELEMENT: 404, - TYPE_MISMATCH: 405, - VALUE_OUT_OF_RANGE: 407, - DEPENDENCY_NOT_ESTABLISHED: 408 - } -}; - -export const scorm2004_error_codes = { - ...base_error_codes, ...{ - INITIALIZATION_FAILED: 102, - INITIALIZED: 103, - TERMINATED: 104, - TERMINATION_FAILURE: 111, - TERMINATION_BEFORE_INIT: 112, - MULTIPLE_TERMINATIONS: 113, - RETRIEVE_BEFORE_INIT: 122, - RETRIEVE_AFTER_TERM: 123, - STORE_BEFORE_INIT: 132, - STORE_AFTER_TERM: 133, - COMMIT_BEFORE_INIT: 142, - COMMIT_AFTER_TERM: 143, - ARGUMENT_ERROR: 201, - GENERAL_GET_FAILURE: 301, - GENERAL_SET_FAILURE: 351, - GENERAL_COMMIT_FAILURE: 391, - UNDEFINED_DATA_MODEL: 401, - UNIMPLEMENTED_ELEMENT: 402, - VALUE_NOT_INITIALIZED: 403, - READ_ONLY_ELEMENT: 404, - WRITE_ONLY_ELEMENT: 405, - TYPE_MISMATCH: 406, - VALUE_OUT_OF_RANGE: 407, - DEPENDENCY_NOT_ESTABLISHED: 408 - } -}; - -export const scorm12_constants = { - // 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', - score_children: 'raw,min,max', - comments_children: 'content,location,time', - objectives_children: 'id,score,status', - correct_responses_children: 'pattern', - student_data_children: 'mastery_score,max_time_allowed,time_limit_action', - student_preference_children: 'audio,language,speed,text', - interactions_children: 'id,objectives,time,type,correct_responses,weighting,student_response,result,latency', - - error_descriptions: { - "101": { - basicMessage: "General Exception", - detailMessage: "No specific error code exists to describe the error. Use LMSGetDiagnostic for more information", - }, - "201": { - basicMessage: "Invalid argument error", - detailMessage: "Indicates that an argument represents an invalid data model element or is otherwise incorrect.", - }, - "202": { - basicMessage: "Element cannot have children", - detailMessage: "Indicates that LMSGetValue was called with a data model element name that ends in \"_children\" for a data model element that does not support the \"_children\" suffix.", - }, - "203": { - basicMessage: "Element not an array - cannot have count", - detailMessage: "Indicates that LMSGetValue was called with a data model element name that ends in \"_count\" for a data model element that does not support the \"_count\" suffix.", - }, - "301": { - basicMessage: "Not initialized", - detailMessage: "Indicates that an API call was made before the call to LMSInitialize.", - }, - "401": { - basicMessage: "Not implemented error", - detailMessage: "The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement.", - }, - "402": { - basicMessage: "Invalid set value, element is a keyword", - detailMessage: "Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in \"_children\" and \"_count\").", - }, - "403": { - basicMessage: "Element is read only", - detailMessage: "LMSSetValue was called with a data model element that can only be read.", - }, - "404": { - basicMessage: "Element is write only", - detailMessage: "LMSGetValue was called on a data model element that can only be written to.", - }, - "405": { - basicMessage: "Incorrect Data Type", - detailMessage: "LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element.", - } - } -}; - -export const aicc_constants = { - ...scorm12_constants, ...{ - 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 = { - // 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', - score_children: 'max,raw,scaled,min', - objectives_children: 'progress_measure,completion_status,success_status,description,score,id', - correct_responses_children: 'pattern', - student_data_children: 'mastery_score,max_time_allowed,time_limit_action', - student_preference_children: 'audio_level,audio_captioning,delivery_speed,language', - interactions_children: 'id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description', - - error_descriptions: { - "0": { - basicMessage: "No Error", - detailMessage: "No error occurred, the previous API call was successful.", - }, - "101": { - basicMessage: "General Exception", - detailMessage: "No specific error code exists to describe the error. Use GetDiagnostic for more information.", - }, - "102": { - basicMessage: "General Initialization Failure", - detailMessage: "Call to Initialize failed for an unknown reason.", - }, - "103": { - basicMessage: "Already Initialized", - detailMessage: "Call to Initialize failed because Initialize was already called.", - }, - "104": { - basicMessage: "Content Instance Terminated", - detailMessage: "Call to Initialize failed because Terminate was already called.", - }, - "111": { - basicMessage: "General Termination Failure", - detailMessage: "Call to Terminate failed for an unknown reason.", - }, - "112": { - basicMessage: "Termination Before Initialization", - detailMessage: "Call to Terminate failed because it was made before the call to Initialize.", - }, - "113": { - basicMessage: "Termination After Termination", - detailMessage: "Call to Terminate failed because Terminate was already called.", - }, - "122": { - basicMessage: "Retrieve Data Before Initialization", - detailMessage: "Call to GetValue failed because it was made before the call to Initialize.", - }, - "123": { - basicMessage: "Retrieve Data After Termination", - detailMessage: "Call to GetValue failed because it was made after the call to Terminate.", - }, - "132": { - basicMessage: "Store Data Before Initialization", - detailMessage: "Call to SetValue failed because it was made before the call to Initialize.", - }, - "133": { - basicMessage: "Store Data After Termination", - detailMessage: "Call to SetValue failed because it was made after the call to Terminate.", - }, - "142": { - basicMessage: "Commit Before Initialization", - detailMessage: "Call to Commit failed because it was made before the call to Initialize.", - }, - "143": { - basicMessage: "Commit After Termination", - detailMessage: "Call to Commit failed because it was made after the call to Terminate.", - }, - "201": { - basicMessage: "General Argument Error", - detailMessage: "An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument.", - }, - "301": { - basicMessage: "General Get Failure", - detailMessage: "Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.", - }, - "351": { - basicMessage: "General Set Failure", - detailMessage: "Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.", - }, - "391": { - basicMessage: "General Commit Failure", - detailMessage: "Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information.", - }, - "401": { - basicMessage: "Undefined Data Model Element", - detailMessage: "The data model element name passed to GetValue or SetValue is not a valid SCORM data model element.", - }, - "402": { - basicMessage: "Unimplemented Data Model Element", - detailMessage: "The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant.", - }, - "403": { - basicMessage: "Data Model Element Value Not Initialized", - detailMessage: "Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO.", - }, - "404": { - basicMessage: "Data Model Element Is Read Only", - detailMessage: "SetValue was called with a data model element that can only be read.", - }, - "405": { - basicMessage: "Data Model Element Is Write Only", - detailMessage: "GetValue was called on a data model element that can only be written to.", - }, - "406": { - basicMessage: "Data Model Element Type Mismatch", - detailMessage: "SetValue was called with a value that is not consistent with the data format of the supplied data model element.", - }, - "407": { - basicMessage: "Data Model Element Value Out Of Range", - detailMessage: "The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element.", - }, - "408": { - basicMessage: "Data Model Dependency Not Established", - detailMessage: "Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element.", - } - }, - - valid_languages: { - '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', - 'bn': 'bn', - 'bo': 'bo', - 'br': 'br', - 'bs': 'bs', - 'ca': 'ca', - 'ce': 'ce', - 'ch': 'ch', - 'co': 'co', - 'cr': 'cr', - 'cs': 'cs', - 'cu': 'cu', - 'cv': 'cv', - 'cy': 'cy', - 'da': 'da', - 'de': 'de', - 'dv': 'dv', - 'dz': 'dz', - 'ee': 'ee', - 'el': 'el', - 'en': 'en', - 'eo': 'eo', - 'es': 'es', - 'et': 'et', - 'eu': 'eu', - 'fa': 'fa', - 'ff': 'ff', - 'fi': 'fi', - 'fj': 'fj', - 'fo': 'fo', - 'fr': 'fr', - 'fy': 'fy', - 'ga': 'ga', - 'gd': 'gd', - 'gl': 'gl', - 'gn': 'gn', - 'gu': 'gu', - 'gv': 'gv', - 'ha': 'ha', - 'he': 'he', - 'hi': 'hi', - 'ho': 'ho', - 'hr': 'hr', - 'ht': 'ht', - 'hu': 'hu', - 'hy': 'hy', - 'hz': 'hz', - 'ia': 'ia', - 'id': 'id', - 'ie': 'ie', - 'ig': 'ig', - 'ii': 'ii', - 'ik': 'ik', - 'io': 'io', - 'is': 'is', - 'it': 'it', - 'iu': 'iu', - 'ja': 'ja', - 'jv': 'jv', - 'ka': 'ka', - 'kg': 'kg', - 'ki': 'ki', - 'kj': 'kj', - 'kk': 'kk', - 'kl': 'kl', - 'km': 'km', - 'kn': 'kn', - 'ko': 'ko', - 'kr': 'kr', - 'ks': 'ks', - 'ku': 'ku', - 'kv': 'kv', - 'kw': 'kw', - 'ky': 'ky', - 'la': 'la', - 'lb': 'lb', - 'lg': 'lg', - 'li': 'li', - 'ln': 'ln', - 'lo': 'lo', - 'lt': 'lt', - 'lu': 'lu', - 'lv': 'lv', - 'mg': 'mg', - 'mh': 'mh', - 'mi': 'mi', - 'mk': 'mk', - 'ml': 'ml', - 'mn': 'mn', - 'mo': 'mo', - 'mr': 'mr', - 'ms': 'ms', - 'mt': 'mt', - 'my': 'my', - 'na': 'na', - 'nb': 'nb', - 'nd': 'nd', - 'ne': 'ne', - 'ng': 'ng', - 'nl': 'nl', - 'nn': 'nn', - 'no': 'no', - 'nr': 'nr', - 'nv': 'nv', - 'ny': 'ny', - 'oc': 'oc', - 'oj': 'oj', - 'om': 'om', - 'or': 'or', - 'os': 'os', - 'pa': 'pa', - 'pi': 'pi', - 'pl': 'pl', - 'ps': 'ps', - 'pt': 'pt', - 'qu': 'qu', - 'rm': 'rm', - 'rn': 'rn', - 'ro': 'ro', - 'ru': 'ru', - 'rw': 'rw', - 'sa': 'sa', - 'sc': 'sc', - 'sd': 'sd', - 'se': 'se', - 'sg': 'sg', - 'sh': 'sh', - 'si': 'si', - 'sk': 'sk', - 'sl': 'sl', - 'sm': 'sm', - 'sn': 'sn', - 'so': 'so', - 'sq': 'sq', - 'sr': 'sr', - 'ss': 'ss', - 'st': 'st', - 'su': 'su', - 'sv': 'sv', - 'sw': 'sw', - 'ta': 'ta', - 'te': 'te', - 'tg': 'tg', - 'th': 'th', - 'ti': 'ti', - 'tk': 'tk', - 'tl': 'tl', - 'tn': 'tn', - 'to': 'to', - 'tr': 'tr', - 'ts': 'ts', - 'tt': 'tt', - 'tw': 'tw', - 'ty': 'ty', - 'ug': 'ug', - 'uk': 'uk', - 'ur': 'ur', - 'uz': 'uz', - 've': 've', - 'vi': 'vi', - 'vo': 'vo', - 'wa': 'wa', - 'wo': 'wo', - 'xh': 'xh', - 'yi': 'yi', - 'yo': 'yo', - 'za': 'za', - 'zh': 'zh', - 'zu': 'zu', - 'aar': 'aar', - 'abk': 'abk', - 'ave': 'ave', - 'afr': 'afr', - 'aka': 'aka', - 'amh': 'amh', - 'arg': 'arg', - 'ara': 'ara', - 'asm': 'asm', - 'ava': 'ava', - 'aym': 'aym', - 'aze': 'aze', - 'bak': 'bak', - 'bel': 'bel', - 'bul': 'bul', - 'bih': 'bih', - 'bis': 'bis', - 'bam': 'bam', - 'ben': 'ben', - 'tib': 'tib', - 'bod': 'bod', - 'bre': 'bre', - 'bos': 'bos', - 'cat': 'cat', - 'che': 'che', - 'cha': 'cha', - 'cos': 'cos', - 'cre': 'cre', - 'cze': 'cze', - 'ces': 'ces', - 'chu': 'chu', - 'chv': 'chv', - 'wel': 'wel', - 'cym': 'cym', - 'dan': 'dan', - 'ger': 'ger', - 'deu': 'deu', - 'div': 'div', - 'dzo': 'dzo', - 'ewe': 'ewe', - 'gre': 'gre', - 'ell': 'ell', - 'eng': 'eng', - 'epo': 'epo', - 'spa': 'spa', - 'est': 'est', - 'baq': 'baq', - 'eus': 'eus', - 'per': 'per', - 'fas': 'fas', - 'ful': 'ful', - 'fin': 'fin', - 'fij': 'fij', - 'fao': 'fao', - 'fre': 'fre', - 'fra': 'fra', - 'fry': 'fry', - 'gle': 'gle', - 'gla': 'gla', - 'glg': 'glg', - 'grn': 'grn', - 'guj': 'guj', - 'glv': 'glv', - 'hau': 'hau', - 'heb': 'heb', - 'hin': 'hin', - 'hmo': 'hmo', - 'hrv': 'hrv', - 'hat': 'hat', - 'hun': 'hun', - 'arm': 'arm', - 'hye': 'hye', - 'her': 'her', - 'ina': 'ina', - 'ind': 'ind', - 'ile': 'ile', - 'ibo': 'ibo', - 'iii': 'iii', - 'ipk': 'ipk', - 'ido': 'ido', - 'ice': 'ice', - 'isl': 'isl', - 'ita': 'ita', - 'iku': 'iku', - 'jpn': 'jpn', - 'jav': 'jav', - 'geo': 'geo', - 'kat': 'kat', - 'kon': 'kon', - 'kik': 'kik', - 'kua': 'kua', - 'kaz': 'kaz', - 'kal': 'kal', - 'khm': 'khm', - 'kan': 'kan', - 'kor': 'kor', - 'kau': 'kau', - 'kas': 'kas', - 'kur': 'kur', - 'kom': 'kom', - 'cor': 'cor', - 'kir': 'kir', - 'lat': 'lat', - 'ltz': 'ltz', - 'lug': 'lug', - 'lim': 'lim', - 'lin': 'lin', - 'lao': 'lao', - 'lit': 'lit', - 'lub': 'lub', - 'lav': 'lav', - 'mlg': 'mlg', - 'mah': 'mah', - 'mao': 'mao', - 'mri': 'mri', - 'mac': 'mac', - 'mkd': 'mkd', - 'mal': 'mal', - 'mon': 'mon', - 'mol': 'mol', - 'mar': 'mar', - 'may': 'may', - 'msa': 'msa', - 'mlt': 'mlt', - 'bur': 'bur', - 'mya': 'mya', - 'nau': 'nau', - 'nob': 'nob', - 'nde': 'nde', - 'nep': 'nep', - 'ndo': 'ndo', - 'dut': 'dut', - 'nld': 'nld', - 'nno': 'nno', - 'nor': 'nor', - 'nbl': 'nbl', - 'nav': 'nav', - 'nya': 'nya', - 'oci': 'oci', - 'oji': 'oji', - 'orm': 'orm', - 'ori': 'ori', - 'oss': 'oss', - 'pan': 'pan', - 'pli': 'pli', - 'pol': 'pol', - 'pus': 'pus', - 'por': 'por', - 'que': 'que', - 'roh': 'roh', - 'run': 'run', - 'rum': 'rum', - 'ron': 'ron', - 'rus': 'rus', - 'kin': 'kin', - 'san': 'san', - 'srd': 'srd', - 'snd': 'snd', - 'sme': 'sme', - 'sag': 'sag', - 'slo': 'slo', - 'sin': 'sin', - 'slk': 'slk', - 'slv': 'slv', - 'smo': 'smo', - 'sna': 'sna', - 'som': 'som', - 'alb': 'alb', - 'sqi': 'sqi', - 'srp': 'srp', - 'ssw': 'ssw', - 'sot': 'sot', - 'sun': 'sun', - 'swe': 'swe', - 'swa': 'swa', - 'tam': 'tam', - 'tel': 'tel', - 'tgk': 'tgk', - 'tha': 'tha', - 'tir': 'tir', - 'tuk': 'tuk', - 'tgl': 'tgl', - 'tsn': 'tsn', - 'ton': 'ton', - 'tur': 'tur', - 'tso': 'tso', - 'tat': 'tat', - 'twi': 'twi', - 'tah': 'tah', - 'uig': 'uig', - 'ukr': 'ukr', - 'urd': 'urd', - 'uzb': 'uzb', - 'ven': 'ven', - 'vie': 'vie', - 'vol': 'vol', - 'wln': 'wln', - 'wol': 'wol', - 'xho': 'xho', - 'yid': 'yid', - 'yor': 'yor', - 'zha': 'zha', - 'chi': 'chi', - 'zho': 'zho', - 'zul': 'zul' - } -}; - -export const learner_responses = { - 'true-false': { - format: '^true$|^false$', - max: 1, - delimiter: '', - unique: false - }, - 'choice': { - format: scorm2004_regex.CMIShortIdentifier, - max: 36, - delimiter: '[,]', - unique: true - }, - 'fill-in': { - format: scorm2004_regex.CMILangString250, - max: 10, - delimiter: '[,]', - unique: false - }, - 'long-fill-in': { - format: scorm2004_regex.CMILangString4000, - max: 1, - delimiter: '', - unique: false - }, - 'matching': { - format: scorm2004_regex.CMIShortIdentifier, - format2: scorm2004_regex.CMIShortIdentifier, - max: 36, - delimiter: '[,]', - delimiter2: '[.]', - unique: false - }, - 'performance': { - format: '^$|' + scorm2004_regex.CMIShortIdentifier, - format2: scorm2004_regex.CMIDecimal + '|^$|' + scorm2004_regex.CMIShortIdentifier, - max: 250, - delimiter: '[,]', - delimiter2: '[.]', - unique: false - }, - 'sequencing': { - format: scorm2004_regex.CMIShortIdentifier, - max: 36, - delimiter: '[,]', - unique: false - }, - 'likert': { - format: scorm2004_regex.CMIShortIdentifier, - max: 1, - delimiter: '', - unique: false - }, - 'numeric': { - format: scorm2004_regex.CMIDecimal, - max: 1, - delimiter: '', - unique: false - }, - 'other': { - format: scorm2004_regex.CMIString4000, - max: 1, - delimiter: '', - unique: false - } -}; - -export const correct_responses = { - 'true-false': { - max: 1, - delimiter: '', - unique: false, - duplicate: false, - format: '^true$|^false$', - limit: 1 - }, - 'choice': { - max: 36, - delimiter: '[,]', - unique: true, - duplicate: false, - format: scorm2004_regex.CMIShortIdentifier - }, - 'fill-in': { - max: 10, - delimiter: '[,]', - unique: false, - duplicate: false, - format: scorm2004_regex.CMILangString250cr - }, - 'long-fill-in': { - max: 1, - delimiter: '', - unique: false, - duplicate: true, - format: scorm2004_regex.CMILangString4000 - }, - 'matching': { - max: 36, - delimiter: '[,]', - delimiter2: '[.]', - unique: false, - duplicate: false, - format: scorm2004_regex.CMIShortIdentifier, - format2: scorm2004_regex.CMIShortIdentifier - }, - 'performance': { - max: 250, - delimiter: '[,]', - delimiter2: '[.]', - unique: false, - duplicate: false, - format: '^$|' + scorm2004_regex.CMIShortIdentifier, - format2: scorm2004_regex.CMIDecimal + '|^$|' + scorm2004_regex.CMIShortIdentifier - }, - 'sequencing': { - max: 36, - delimiter: '[,]', - unique: false, - duplicate: false, - format: scorm2004_regex.CMIShortIdentifier - }, - 'likert': { - max: 1, - delimiter: '', - unique: false, - duplicate: false, - format: scorm2004_regex.CMIShortIdentifier, - limit: 1 - }, - 'numeric': { - max: 2, - delimiter: '[:]', - unique: false, - duplicate: false, - format: scorm2004_regex.CMIDecimal, - limit: 1 - }, - 'other': { - max: 1, - delimiter: '', - unique: false, - duplicate: false, - format: scorm2004_regex.CMIString4000, - limit: 1 - } -}; \ No newline at end of file diff --git a/src/constants/api_constants.js b/src/constants/api_constants.js new file mode 100644 index 0000000..998be0a --- /dev/null +++ b/src/constants/api_constants.js @@ -0,0 +1,183 @@ +// @flow +export const scorm12_constants = { + // 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', + score_children: 'raw,min,max', + comments_children: 'content,location,time', + objectives_children: 'id,score,status', + correct_responses_children: 'pattern', + student_data_children: 'mastery_score,max_time_allowed,time_limit_action', + student_preference_children: 'audio,language,speed,text', + interactions_children: 'id,objectives,time,type,correct_responses,weighting,student_response,result,latency', + + error_descriptions: { + '101': { + basicMessage: 'General Exception', + detailMessage: 'No specific error code exists to describe the error. Use LMSGetDiagnostic for more information', + }, + '201': { + basicMessage: 'Invalid argument error', + detailMessage: 'Indicates that an argument represents an invalid data model element or is otherwise incorrect.', + }, + '202': { + basicMessage: 'Element cannot have children', + detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.', + }, + '203': { + basicMessage: 'Element not an array - cannot have count', + detailMessage: 'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.', + }, + '301': { + basicMessage: 'Not initialized', + detailMessage: 'Indicates that an API call was made before the call to LMSInitialize.', + }, + '401': { + basicMessage: 'Not implemented error', + detailMessage: 'The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement.', + }, + '402': { + basicMessage: 'Invalid set value, element is a keyword', + detailMessage: 'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").', + }, + '403': { + basicMessage: 'Element is read only', + detailMessage: 'LMSSetValue was called with a data model element that can only be read.', + }, + '404': { + basicMessage: 'Element is write only', + detailMessage: 'LMSGetValue was called on a data model element that can only be written to.', + }, + '405': { + basicMessage: 'Incorrect Data Type', + detailMessage: 'LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element.', + }, + }, +}; + +export const aicc_constants = { + ...scorm12_constants, ...{ + 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 = { + // 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', + score_children: 'max,raw,scaled,min', + objectives_children: 'progress_measure,completion_status,success_status,description,score,id', + correct_responses_children: 'pattern', + student_data_children: 'mastery_score,max_time_allowed,time_limit_action', + student_preference_children: 'audio_level,audio_captioning,delivery_speed,language', + interactions_children: 'id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description', + + error_descriptions: { + '0': { + basicMessage: 'No Error', + detailMessage: 'No error occurred, the previous API call was successful.', + }, + '101': { + basicMessage: 'General Exception', + detailMessage: 'No specific error code exists to describe the error. Use GetDiagnostic for more information.', + }, + '102': { + basicMessage: 'General Initialization Failure', + detailMessage: 'Call to Initialize failed for an unknown reason.', + }, + '103': { + basicMessage: 'Already Initialized', + detailMessage: 'Call to Initialize failed because Initialize was already called.', + }, + '104': { + basicMessage: 'Content Instance Terminated', + detailMessage: 'Call to Initialize failed because Terminate was already called.', + }, + '111': { + basicMessage: 'General Termination Failure', + detailMessage: 'Call to Terminate failed for an unknown reason.', + }, + '112': { + basicMessage: 'Termination Before Initialization', + detailMessage: 'Call to Terminate failed because it was made before the call to Initialize.', + }, + '113': { + basicMessage: 'Termination After Termination', + detailMessage: 'Call to Terminate failed because Terminate was already called.', + }, + '122': { + basicMessage: 'Retrieve Data Before Initialization', + detailMessage: 'Call to GetValue failed because it was made before the call to Initialize.', + }, + '123': { + basicMessage: 'Retrieve Data After Termination', + detailMessage: 'Call to GetValue failed because it was made after the call to Terminate.', + }, + '132': { + basicMessage: 'Store Data Before Initialization', + detailMessage: 'Call to SetValue failed because it was made before the call to Initialize.', + }, + '133': { + basicMessage: 'Store Data After Termination', + detailMessage: 'Call to SetValue failed because it was made after the call to Terminate.', + }, + '142': { + basicMessage: 'Commit Before Initialization', + detailMessage: 'Call to Commit failed because it was made before the call to Initialize.', + }, + '143': { + basicMessage: 'Commit After Termination', + detailMessage: 'Call to Commit failed because it was made after the call to Terminate.', + }, + '201': { + basicMessage: 'General Argument Error', + detailMessage: 'An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument.', + }, + '301': { + basicMessage: 'General Get Failure', + detailMessage: 'Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.', + }, + '351': { + basicMessage: 'General Set Failure', + detailMessage: 'Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information.', + }, + '391': { + basicMessage: 'General Commit Failure', + detailMessage: 'Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information.', + }, + '401': { + basicMessage: 'Undefined Data Model Element', + detailMessage: 'The data model element name passed to GetValue or SetValue is not a valid SCORM data model element.', + }, + '402': { + basicMessage: 'Unimplemented Data Model Element', + detailMessage: 'The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant.', + }, + '403': { + basicMessage: 'Data Model Element Value Not Initialized', + detailMessage: 'Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO.', + }, + '404': { + basicMessage: 'Data Model Element Is Read Only', + detailMessage: 'SetValue was called with a data model element that can only be read.', + }, + '405': { + basicMessage: 'Data Model Element Is Write Only', + detailMessage: 'GetValue was called on a data model element that can only be written to.', + }, + '406': { + basicMessage: 'Data Model Element Type Mismatch', + detailMessage: 'SetValue was called with a value that is not consistent with the data format of the supplied data model element.', + }, + '407': { + basicMessage: 'Data Model Element Value Out Of Range', + detailMessage: 'The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element.', + }, + '408': { + basicMessage: 'Data Model Dependency Not Established', + detailMessage: 'Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element.', + }, + }, +}; diff --git a/src/constants/error_codes.js b/src/constants/error_codes.js new file mode 100644 index 0000000..bae4b79 --- /dev/null +++ b/src/constants/error_codes.js @@ -0,0 +1,80 @@ +// @flow +export const error_codes = { + GENERAL: 101, + INITIALIZATION_FAILED: 101, + INITIALIZED: 101, + TERMINATED: 101, + TERMINATION_FAILURE: 101, + TERMINATION_BEFORE_INIT: 101, + MULTIPLE_TERMINATION: 101, + RETRIEVE_BEFORE_INIT: 101, + RETRIEVE_AFTER_TERM: 101, + STORE_BEFORE_INIT: 101, + STORE_AFTER_TERM: 101, + COMMIT_BEFORE_INIT: 101, + COMMIT_AFTER_TERM: 101, + ARGUMENT_ERROR: 101, + CHILDREN_ERROR: 101, + COUNT_ERROR: 101, + GENERAL_GET_FAILURE: 101, + GENERAL_SET_FAILURE: 101, + GENERAL_COMMIT_FAILURE: 101, + UNDEFINED_DATA_MODEL: 101, + UNIMPLEMENTED_ELEMENT: 101, + VALUE_NOT_INITIALIZED: 101, + INVALID_SET_VALUE: 101, + READ_ONLY_ELEMENT: 101, + WRITE_ONLY_ELEMENT: 101, + TYPE_MISMATCH: 101, + VALUE_OUT_OF_RANGE: 101, + DEPENDENCY_NOT_ESTABLISHED: 101, +}; + +export const scorm12_error_codes = { + ...error_codes, ...{ + RETRIEVE_BEFORE_INIT: 301, + STORE_BEFORE_INIT: 301, + COMMIT_BEFORE_INIT: 301, + ARGUMENT_ERROR: 201, + CHILDREN_ERROR: 202, + COUNT_ERROR: 203, + UNDEFINED_DATA_MODEL: 401, + UNIMPLEMENTED_ELEMENT: 401, + VALUE_NOT_INITIALIZED: 301, + INVALID_SET_VALUE: 402, + READ_ONLY_ELEMENT: 403, + WRITE_ONLY_ELEMENT: 404, + TYPE_MISMATCH: 405, + VALUE_OUT_OF_RANGE: 407, + DEPENDENCY_NOT_ESTABLISHED: 408, + }, +}; + +export const scorm2004_error_codes = { + ...error_codes, ...{ + INITIALIZATION_FAILED: 102, + INITIALIZED: 103, + TERMINATED: 104, + TERMINATION_FAILURE: 111, + TERMINATION_BEFORE_INIT: 112, + MULTIPLE_TERMINATIONS: 113, + RETRIEVE_BEFORE_INIT: 122, + RETRIEVE_AFTER_TERM: 123, + STORE_BEFORE_INIT: 132, + STORE_AFTER_TERM: 133, + COMMIT_BEFORE_INIT: 142, + COMMIT_AFTER_TERM: 143, + ARGUMENT_ERROR: 201, + GENERAL_GET_FAILURE: 301, + GENERAL_SET_FAILURE: 351, + GENERAL_COMMIT_FAILURE: 391, + UNDEFINED_DATA_MODEL: 401, + UNIMPLEMENTED_ELEMENT: 402, + VALUE_NOT_INITIALIZED: 403, + READ_ONLY_ELEMENT: 404, + WRITE_ONLY_ELEMENT: 405, + TYPE_MISMATCH: 406, + VALUE_OUT_OF_RANGE: 407, + DEPENDENCY_NOT_ESTABLISHED: 408, + }, +}; diff --git a/src/constants/language_constants.js b/src/constants/language_constants.js new file mode 100644 index 0000000..d31e65e --- /dev/null +++ b/src/constants/language_constants.js @@ -0,0 +1,74 @@ +export const valid_languages = { + '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', + 'bn': 'bn', 'bo': 'bo', 'br': 'br', 'bs': 'bs', 'ca': 'ca', 'ce': 'ce', + 'ch': 'ch', 'co': 'co', 'cr': 'cr', 'cs': 'cs', 'cu': 'cu', 'cv': 'cv', + 'cy': 'cy', 'da': 'da', 'de': 'de', 'dv': 'dv', 'dz': 'dz', 'ee': 'ee', + 'el': 'el', 'en': 'en', 'eo': 'eo', 'es': 'es', 'et': 'et', 'eu': 'eu', + 'fa': 'fa', 'ff': 'ff', 'fi': 'fi', 'fj': 'fj', 'fo': 'fo', 'fr': 'fr', + 'fy': 'fy', 'ga': 'ga', 'gd': 'gd', 'gl': 'gl', 'gn': 'gn', 'gu': 'gu', + 'gv': 'gv', 'ha': 'ha', 'he': 'he', 'hi': 'hi', 'ho': 'ho', 'hr': 'hr', + 'ht': 'ht', 'hu': 'hu', 'hy': 'hy', 'hz': 'hz', 'ia': 'ia', 'id': 'id', + 'ie': 'ie', 'ig': 'ig', 'ii': 'ii', 'ik': 'ik', 'io': 'io', 'is': 'is', + 'it': 'it', 'iu': 'iu', 'ja': 'ja', 'jv': 'jv', 'ka': 'ka', 'kg': 'kg', + 'ki': 'ki', 'kj': 'kj', 'kk': 'kk', 'kl': 'kl', 'km': 'km', 'kn': 'kn', + 'ko': 'ko', 'kr': 'kr', 'ks': 'ks', 'ku': 'ku', 'kv': 'kv', 'kw': 'kw', + 'ky': 'ky', 'la': 'la', 'lb': 'lb', 'lg': 'lg', 'li': 'li', 'ln': 'ln', + 'lo': 'lo', 'lt': 'lt', 'lu': 'lu', 'lv': 'lv', 'mg': 'mg', 'mh': 'mh', + 'mi': 'mi', 'mk': 'mk', 'ml': 'ml', 'mn': 'mn', 'mo': 'mo', 'mr': 'mr', + 'ms': 'ms', 'mt': 'mt', 'my': 'my', 'na': 'na', 'nb': 'nb', 'nd': 'nd', + 'ne': 'ne', 'ng': 'ng', 'nl': 'nl', 'nn': 'nn', 'no': 'no', 'nr': 'nr', + 'nv': 'nv', 'ny': 'ny', 'oc': 'oc', 'oj': 'oj', 'om': 'om', 'or': 'or', + 'os': 'os', 'pa': 'pa', 'pi': 'pi', 'pl': 'pl', 'ps': 'ps', 'pt': 'pt', + 'qu': 'qu', 'rm': 'rm', 'rn': 'rn', 'ro': 'ro', 'ru': 'ru', 'rw': 'rw', + 'sa': 'sa', 'sc': 'sc', 'sd': 'sd', 'se': 'se', 'sg': 'sg', 'sh': 'sh', + 'si': 'si', 'sk': 'sk', 'sl': 'sl', 'sm': 'sm', 'sn': 'sn', 'so': 'so', + 'sq': 'sq', 'sr': 'sr', 'ss': 'ss', 'st': 'st', 'su': 'su', 'sv': 'sv', + 'sw': 'sw', 'ta': 'ta', 'te': 'te', 'tg': 'tg', 'th': 'th', 'ti': 'ti', + 'tk': 'tk', 'tl': 'tl', 'tn': 'tn', 'to': 'to', 'tr': 'tr', 'ts': 'ts', + 'tt': 'tt', 'tw': 'tw', 'ty': 'ty', 'ug': 'ug', 'uk': 'uk', 'ur': 'ur', + 'uz': 'uz', 've': 've', 'vi': 'vi', 'vo': 'vo', 'wa': 'wa', 'wo': 'wo', + 'xh': 'xh', 'yi': 'yi', 'yo': 'yo', 'za': 'za', 'zh': 'zh', 'zu': 'zu', + 'aar': 'aar', 'abk': 'abk', 'ave': 'ave', 'afr': 'afr', 'aka': 'aka', + 'amh': 'amh', 'arg': 'arg', 'ara': 'ara', 'asm': 'asm', 'ava': 'ava', + 'aym': 'aym', 'aze': 'aze', 'bak': 'bak', 'bel': 'bel', 'bul': 'bul', + 'bih': 'bih', 'bis': 'bis', 'bam': 'bam', 'ben': 'ben', 'tib': 'tib', + 'bod': 'bod', 'bre': 'bre', 'bos': 'bos', 'cat': 'cat', 'che': 'che', + 'cha': 'cha', 'cos': 'cos', 'cre': 'cre', 'cze': 'cze', 'ces': 'ces', + 'chu': 'chu', 'chv': 'chv', 'wel': 'wel', 'cym': 'cym', 'dan': 'dan', + 'ger': 'ger', 'deu': 'deu', 'div': 'div', 'dzo': 'dzo', 'ewe': 'ewe', + 'gre': 'gre', 'ell': 'ell', 'eng': 'eng', 'epo': 'epo', 'spa': 'spa', + 'est': 'est', 'baq': 'baq', 'eus': 'eus', 'per': 'per', 'fas': 'fas', + 'ful': 'ful', 'fin': 'fin', 'fij': 'fij', 'fao': 'fao', 'fre': 'fre', + 'fra': 'fra', 'fry': 'fry', 'gle': 'gle', 'gla': 'gla', 'glg': 'glg', + 'grn': 'grn', 'guj': 'guj', 'glv': 'glv', 'hau': 'hau', 'heb': 'heb', + 'hin': 'hin', 'hmo': 'hmo', 'hrv': 'hrv', 'hat': 'hat', 'hun': 'hun', + 'arm': 'arm', 'hye': 'hye', 'her': 'her', 'ina': 'ina', 'ind': 'ind', + 'ile': 'ile', 'ibo': 'ibo', 'iii': 'iii', 'ipk': 'ipk', 'ido': 'ido', + 'ice': 'ice', 'isl': 'isl', 'ita': 'ita', 'iku': 'iku', 'jpn': 'jpn', + 'jav': 'jav', 'geo': 'geo', 'kat': 'kat', 'kon': 'kon', 'kik': 'kik', + 'kua': 'kua', 'kaz': 'kaz', 'kal': 'kal', 'khm': 'khm', 'kan': 'kan', + 'kor': 'kor', 'kau': 'kau', 'kas': 'kas', 'kur': 'kur', 'kom': 'kom', + 'cor': 'cor', 'kir': 'kir', 'lat': 'lat', 'ltz': 'ltz', 'lug': 'lug', + 'lim': 'lim', 'lin': 'lin', 'lao': 'lao', 'lit': 'lit', 'lub': 'lub', + 'lav': 'lav', 'mlg': 'mlg', 'mah': 'mah', 'mao': 'mao', 'mri': 'mri', + 'mac': 'mac', 'mkd': 'mkd', 'mal': 'mal', 'mon': 'mon', 'mol': 'mol', + 'mar': 'mar', 'may': 'may', 'msa': 'msa', 'mlt': 'mlt', 'bur': 'bur', + 'mya': 'mya', 'nau': 'nau', 'nob': 'nob', 'nde': 'nde', 'nep': 'nep', + 'ndo': 'ndo', 'dut': 'dut', 'nld': 'nld', 'nno': 'nno', 'nor': 'nor', + 'nbl': 'nbl', 'nav': 'nav', 'nya': 'nya', 'oci': 'oci', 'oji': 'oji', + 'orm': 'orm', 'ori': 'ori', 'oss': 'oss', 'pan': 'pan', 'pli': 'pli', + 'pol': 'pol', 'pus': 'pus', 'por': 'por', 'que': 'que', 'roh': 'roh', + 'run': 'run', 'rum': 'rum', 'ron': 'ron', 'rus': 'rus', 'kin': 'kin', + 'san': 'san', 'srd': 'srd', 'snd': 'snd', 'sme': 'sme', 'sag': 'sag', + 'slo': 'slo', 'sin': 'sin', 'slk': 'slk', 'slv': 'slv', 'smo': 'smo', + 'sna': 'sna', 'som': 'som', 'alb': 'alb', 'sqi': 'sqi', 'srp': 'srp', + 'ssw': 'ssw', 'sot': 'sot', 'sun': 'sun', 'swe': 'swe', 'swa': 'swa', + 'tam': 'tam', 'tel': 'tel', 'tgk': 'tgk', 'tha': 'tha', 'tir': 'tir', + 'tuk': 'tuk', 'tgl': 'tgl', 'tsn': 'tsn', 'ton': 'ton', 'tur': 'tur', + 'tso': 'tso', 'tat': 'tat', 'twi': 'twi', 'tah': 'tah', 'uig': 'uig', + 'ukr': 'ukr', 'urd': 'urd', 'uzb': 'uzb', 'ven': 'ven', 'vie': 'vie', + 'vol': 'vol', 'wln': 'wln', 'wol': 'wol', 'xho': 'xho', 'yid': 'yid', + 'yor': 'yor', 'zha': 'zha', 'chi': 'chi', 'zho': 'zho', 'zul': 'zul', +}; \ No newline at end of file diff --git a/src/constants/response_constants.js b/src/constants/response_constants.js new file mode 100644 index 0000000..9980ae5 --- /dev/null +++ b/src/constants/response_constants.js @@ -0,0 +1,152 @@ +// @flow +import {scorm2004_regex} from '../regex'; + +export const learner_responses = { + 'true-false': { + format: '^true$|^false$', + max: 1, + delimiter: '', + unique: false, + }, + 'choice': { + format: scorm2004_regex.CMIShortIdentifier, + max: 36, + delimiter: '[,]', + unique: true, + }, + 'fill-in': { + format: scorm2004_regex.CMILangString250, + max: 10, + delimiter: '[,]', + unique: false, + }, + 'long-fill-in': { + format: scorm2004_regex.CMILangString4000, + max: 1, + delimiter: '', + unique: false, + }, + 'matching': { + format: scorm2004_regex.CMIShortIdentifier, + format2: scorm2004_regex.CMIShortIdentifier, + max: 36, + delimiter: '[,]', + delimiter2: '[.]', + unique: false, + }, + 'performance': { + format: '^$|' + scorm2004_regex.CMIShortIdentifier, + format2: scorm2004_regex.CMIDecimal + '|^$|' + + scorm2004_regex.CMIShortIdentifier, + max: 250, + delimiter: '[,]', + delimiter2: '[.]', + unique: false, + }, + 'sequencing': { + format: scorm2004_regex.CMIShortIdentifier, + max: 36, + delimiter: '[,]', + unique: false, + }, + 'likert': { + format: scorm2004_regex.CMIShortIdentifier, + max: 1, + delimiter: '', + unique: false, + }, + 'numeric': { + format: scorm2004_regex.CMIDecimal, + max: 1, + delimiter: '', + unique: false, + }, + 'other': { + format: scorm2004_regex.CMIString4000, + max: 1, + delimiter: '', + unique: false, + }, +}; + +export const correct_responses = { + 'true-false': { + max: 1, + delimiter: '', + unique: false, + duplicate: false, + format: '^true$|^false$', + limit: 1, + }, + 'choice': { + max: 36, + delimiter: '[,]', + unique: true, + duplicate: false, + format: scorm2004_regex.CMIShortIdentifier, + }, + 'fill-in': { + max: 10, + delimiter: '[,]', + unique: false, + duplicate: false, + format: scorm2004_regex.CMILangString250cr, + }, + 'long-fill-in': { + max: 1, + delimiter: '', + unique: false, + duplicate: true, + format: scorm2004_regex.CMILangString4000, + }, + 'matching': { + max: 36, + delimiter: '[,]', + delimiter2: '[.]', + unique: false, + duplicate: false, + format: scorm2004_regex.CMIShortIdentifier, + format2: scorm2004_regex.CMIShortIdentifier, + }, + 'performance': { + max: 250, + delimiter: '[,]', + delimiter2: '[.]', + unique: false, + duplicate: false, + format: '^$|' + scorm2004_regex.CMIShortIdentifier, + format2: scorm2004_regex.CMIDecimal + '|^$|' + + scorm2004_regex.CMIShortIdentifier, + }, + 'sequencing': { + max: 36, + delimiter: '[,]', + unique: false, + duplicate: false, + format: scorm2004_regex.CMIShortIdentifier, + }, + 'likert': { + max: 1, + delimiter: '', + unique: false, + duplicate: false, + format: scorm2004_regex.CMIShortIdentifier, + limit: 1, + }, + 'numeric': { + max: 2, + delimiter: '[:]', + unique: false, + duplicate: false, + format: scorm2004_regex.CMIDecimal, + limit: 1, + }, + 'other': { + max: 1, + delimiter: '', + unique: false, + duplicate: false, + format: scorm2004_regex.CMIString4000, + limit: 1, + }, +}; diff --git a/test/Scorm12API.spec.js b/test/Scorm12API.spec.js index 974b07c..790a1e7 100644 --- a/test/Scorm12API.spec.js +++ b/test/Scorm12API.spec.js @@ -1,282 +1,283 @@ -import { expect, assert } from 'chai'; -import {describe, it, before, beforeEach, after, afterEach, } from "mocha"; -import Scorm12API from "../src/Scorm12API"; -import {scorm12_constants, scorm12_error_codes} from "../src/constants"; +import {expect, assert} from 'chai'; +import {describe, it, before, beforeEach, after, afterEach} from 'mocha'; +import Scorm12API from '../src/Scorm12API'; +import {scorm12_constants} from '../src/constants/api_constants'; +import {scorm12_error_codes} from '../src/constants/error_codes'; let API; const checkFieldConstraintSize = (fieldName: String, limit: Number, expectedValue: String = '') => { - describe(`Field: ${fieldName}`, () => { - it(`Should be able to read from ${fieldName}`, () => { - expect(eval(`API.${fieldName}`)).to.equal(expectedValue); - }); - - it(`Should be able to write upto ${limit} characters to ${fieldName}`, () => { - eval(`API.${fieldName} = 'x'.repeat(${limit})`); - expect(0).to.equal(API.lastErrorCode); - }); - - it(`Should fail to write more than ${limit} characters to ${fieldName}`, () => { - eval(`API.${fieldName} = 'x'.repeat(${limit + 1})`); - expect(scorm12_error_codes.TYPE_MISMATCH + '').to.equal(API.lastErrorCode); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should be able to read from ${fieldName}`, () => { + expect(eval(`API.${fieldName}`)).to.equal(expectedValue); }); + + it(`Should be able to write upto ${limit} characters to ${fieldName}`, () => { + eval(`API.${fieldName} = 'x'.repeat(${limit})`); + expect(0).to.equal(API.lastErrorCode); + }); + + it(`Should fail to write more than ${limit} characters to ${fieldName}`, () => { + eval(`API.${fieldName} = 'x'.repeat(${limit + 1})`); + expect(scorm12_error_codes.TYPE_MISMATCH + '').to.equal(API.lastErrorCode); + }); + }); }; const checkInvalidSet = (fieldName: String, expectedValue: String = '') => { - describe(`Field: ${fieldName}`, () => { - it(`Should be able to read from ${fieldName}`, () => { - expect(eval(`API.${fieldName}`)).to.equal(expectedValue); - }); - - it(`Should fail to write to ${fieldName}`, () => { - eval(`API.${fieldName} = 'xxx'`); - expect(API.lastErrorCode).to.equal(scorm12_error_codes.INVALID_SET_VALUE + ''); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should be able to read from ${fieldName}`, () => { + expect(eval(`API.${fieldName}`)).to.equal(expectedValue); }); + + it(`Should fail to write to ${fieldName}`, () => { + eval(`API.${fieldName} = 'xxx'`); + expect(API.lastErrorCode).to.equal(scorm12_error_codes.INVALID_SET_VALUE + ''); + }); + }); }; const checkReadOnly = (fieldName: String, expectedValue: String = '') => { - describe(`Field: ${fieldName}`, () => { - it(`Should be able to read from ${fieldName}`, () => { - expect(eval(`API.${fieldName}`)).to.equal(expectedValue); - }); - - it(`Should fail to write to ${fieldName}`, () => { - eval(`API.${fieldName} = 'xxx'`); - expect(API.lastErrorCode).to.equal(scorm12_error_codes.READ_ONLY_ELEMENT + ''); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should be able to read from ${fieldName}`, () => { + expect(eval(`API.${fieldName}`)).to.equal(expectedValue); }); + + it(`Should fail to write to ${fieldName}`, () => { + eval(`API.${fieldName} = 'xxx'`); + expect(API.lastErrorCode).to.equal(scorm12_error_codes.READ_ONLY_ELEMENT + ''); + }); + }); }; const checkRead = (fieldName: String, expectedValue: String = '') => { - describe(`Field: ${fieldName}`, () => { - it(`Should be able to read from ${fieldName}`, () => { - expect(eval(`API.${fieldName}`)).to.equal(expectedValue); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should be able to read from ${fieldName}`, () => { + expect(eval(`API.${fieldName}`)).to.equal(expectedValue); }); + }); }; const checkWriteOnly = (fieldName: String, valueToTest: String = 'xxx') => { - describe(`Field: ${fieldName}`, () => { - it(`Should fail to read from ${fieldName}`, () => { - eval(`API.${fieldName}`); - expect(API.lastErrorCode).to.equal(scorm12_error_codes.WRITE_ONLY_ELEMENT + ''); - }); - - it(`Should successfully write to ${fieldName}`, () => { - eval(`API.${fieldName} = '${valueToTest}'`); - expect(API.lastErrorCode).to.equal(0); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should fail to read from ${fieldName}`, () => { + eval(`API.${fieldName}`); + expect(API.lastErrorCode).to.equal(scorm12_error_codes.WRITE_ONLY_ELEMENT + ''); }); + + it(`Should successfully write to ${fieldName}`, () => { + eval(`API.${fieldName} = '${valueToTest}'`); + expect(API.lastErrorCode).to.equal(0); + }); + }); }; const checkWrite = (fieldName: String, valueToTest: String = 'xxx') => { - describe(`Field: ${fieldName}`, () => { - it(`Should successfully write to ${fieldName}`, () => { - eval(`API.${fieldName} = '${valueToTest}'`); - expect(API.lastErrorCode).to.equal(0); - }); + describe(`Field: ${fieldName}`, () => { + it(`Should successfully write to ${fieldName}`, () => { + eval(`API.${fieldName} = '${valueToTest}'`); + expect(API.lastErrorCode).to.equal(0); }); + }); }; const checkValidValues = (fieldName: String, expectedError: Number, validValues: Array, invalidValues: Array) => { - describe(`Field: ${fieldName}`, () => { - for(let idx in validValues) { - it(`Should successfully write '${validValues[idx]}' to ${fieldName}`, () => { - eval(`API.${fieldName} = '${validValues[idx]}'`); - expect(API.lastErrorCode).to.equal(0); - }); - } + describe(`Field: ${fieldName}`, () => { + for (const idx in validValues) { + it(`Should successfully write '${validValues[idx]}' to ${fieldName}`, () => { + eval(`API.${fieldName} = '${validValues[idx]}'`); + expect(API.lastErrorCode).to.equal(0); + }); + } - for(let idx in invalidValues) { - it(`Should fail to write '${invalidValues[idx]}' to ${fieldName}`, () => { - eval(`API.${fieldName} = '${invalidValues[idx]}'`); - expect(API.lastErrorCode).to.equal(expectedError + ''); - }); - } - }); + for (const idx in invalidValues) { + it(`Should fail to write '${invalidValues[idx]}' to ${fieldName}`, () => { + eval(`API.${fieldName} = '${invalidValues[idx]}'`); + expect(API.lastErrorCode).to.equal(expectedError + ''); + }); + } + }); }; describe('SCORM 1.2 API Tests', () => { - describe('CMI Spec Tests', () => { - describe('Post-LMSInitialize Tests', () => { - beforeEach('Create the API object', () => { - API = new Scorm12API(); - API.LMSInitialize(); - }); - afterEach('Destroy API object', () => { - API = null; - }); + describe('CMI Spec Tests', () => { + describe('Post-LMSInitialize Tests', () => { + beforeEach('Create the API object', () => { + API = new Scorm12API(); + API.LMSInitialize(); + }); + afterEach('Destroy API object', () => { + API = null; + }); - it('LMSInitialize should create CMI object', () => { - assert(API.cmi !== undefined, 'CMI object is created'); - }); + it('LMSInitialize should create CMI object', () => { + assert(API.cmi !== undefined, 'CMI object is created'); + }); - it('Exporting CMI to JSON produces proper Object', () => { - expect( - JSON.parse(API.renderCMIToJSON()) - ).to.hasOwnProperty('core') - }); + it('Exporting CMI to JSON produces proper Object', () => { + expect( + JSON.parse(API.renderCMIToJSON()) + ).to.hasOwnProperty('core'); + }); - /** + /** * Base CMI Properties */ - checkInvalidSet('cmi._version', '3.4'); - checkInvalidSet('cmi._children', scorm12_constants.cmi_children); - checkFieldConstraintSize('cmi.suspend_data', 4096); - checkReadOnly('cmi.launch_data'); - checkFieldConstraintSize('cmi.comments', 4096); - checkReadOnly('cmi.comments_from_lms'); + checkInvalidSet('cmi._version', '3.4'); + checkInvalidSet('cmi._children', scorm12_constants.cmi_children); + checkFieldConstraintSize('cmi.suspend_data', 4096); + checkReadOnly('cmi.launch_data'); + checkFieldConstraintSize('cmi.comments', 4096); + checkReadOnly('cmi.comments_from_lms'); - /** + /** * cmi.core Properties */ - checkInvalidSet('cmi.core._children', scorm12_constants.core_children); - checkReadOnly('cmi.core.student_id'); - checkReadOnly('cmi.core.student_name'); - checkFieldConstraintSize('cmi.core.lesson_location', 255); - checkReadOnly('cmi.core.credit'); - checkRead('cmi.core.lesson_status'); - checkValidValues('cmi.core.lesson_status', scorm12_error_codes.TYPE_MISMATCH, [ - 'passed', - 'completed', - 'failed', - 'incomplete', - 'browsed' - ], [ - 'Passed', - 'P', - 'F', - 'p', - 'true', - 'false', - 'complete' - ]); - checkReadOnly('cmi.core.entry'); - checkReadOnly('cmi.core.total_time'); - checkReadOnly('cmi.core.lesson_mode', 'normal'); - checkWrite('cmi.core.exit', 'suspend'); - checkValidValues('cmi.core.exit', scorm12_error_codes.TYPE_MISMATCH, [ - 'time-out', - 'suspend', - 'logout', - ], [ - 'complete', - 'exit' - ]); - checkWriteOnly('cmi.core.session_time', '00:00:00'); - checkValidValues('cmi.core.session_time', scorm12_error_codes.TYPE_MISMATCH, [ - '10:06:57', - '00:00:01.56', - '23:59:59', - '47:59:59', - ], [ - '06:5:13', - '23:59:59.123', - 'P1DT23H59M59S' - ]); + checkInvalidSet('cmi.core._children', scorm12_constants.core_children); + checkReadOnly('cmi.core.student_id'); + checkReadOnly('cmi.core.student_name'); + checkFieldConstraintSize('cmi.core.lesson_location', 255); + checkReadOnly('cmi.core.credit'); + checkRead('cmi.core.lesson_status'); + checkValidValues('cmi.core.lesson_status', scorm12_error_codes.TYPE_MISMATCH, [ + 'passed', + 'completed', + 'failed', + 'incomplete', + 'browsed', + ], [ + 'Passed', + 'P', + 'F', + 'p', + 'true', + 'false', + 'complete', + ]); + checkReadOnly('cmi.core.entry'); + checkReadOnly('cmi.core.total_time'); + checkReadOnly('cmi.core.lesson_mode', 'normal'); + checkWrite('cmi.core.exit', 'suspend'); + checkValidValues('cmi.core.exit', scorm12_error_codes.TYPE_MISMATCH, [ + 'time-out', + 'suspend', + 'logout', + ], [ + 'complete', + 'exit', + ]); + checkWriteOnly('cmi.core.session_time', '00:00:00'); + checkValidValues('cmi.core.session_time', scorm12_error_codes.TYPE_MISMATCH, [ + '10:06:57', + '00:00:01.56', + '23:59:59', + '47:59:59', + ], [ + '06:5:13', + '23:59:59.123', + 'P1DT23H59M59S', + ]); - /** + /** * cmi.core.score Properties */ - checkInvalidSet('cmi.core.score._children', scorm12_constants.score_children); - checkValidValues('cmi.core.score.raw', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ - '0', - '25.1', - '50.5', - '75', - '100', - ], [ - '-1', - '101' - ]); - checkValidValues('cmi.core.score.min', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ - '0', - '25.1', - '50.5', - '75', - '100', - ], [ - '-1', - '101' - ]); - checkValidValues('cmi.core.score.max', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ - '0', - '25.1', - '50.5', - '75', - '100', - ], [ - '-1', - '101' - ]); + checkInvalidSet('cmi.core.score._children', scorm12_constants.score_children); + checkValidValues('cmi.core.score.raw', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ + '0', + '25.1', + '50.5', + '75', + '100', + ], [ + '-1', + '101', + ]); + checkValidValues('cmi.core.score.min', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ + '0', + '25.1', + '50.5', + '75', + '100', + ], [ + '-1', + '101', + ]); + checkValidValues('cmi.core.score.max', scorm12_error_codes.VALUE_OUT_OF_RANGE, [ + '0', + '25.1', + '50.5', + '75', + '100', + ], [ + '-1', + '101', + ]); - /** + /** * cmi.objectives Properties */ - checkInvalidSet('cmi.objectives._children', scorm12_constants.objectives_children); - checkInvalidSet('cmi.objectives._count', 0); + checkInvalidSet('cmi.objectives._children', scorm12_constants.objectives_children); + checkInvalidSet('cmi.objectives._count', 0); - /** + /** * cmi.student_data Properties */ - checkInvalidSet('cmi.student_data._children', scorm12_constants.student_data_children); - checkReadOnly('cmi.student_data.mastery_score'); - checkReadOnly('cmi.student_data.max_time_allowed'); - checkReadOnly('cmi.student_data.time_limit_action'); + checkInvalidSet('cmi.student_data._children', scorm12_constants.student_data_children); + checkReadOnly('cmi.student_data.mastery_score'); + checkReadOnly('cmi.student_data.max_time_allowed'); + checkReadOnly('cmi.student_data.time_limit_action'); - /** + /** * cmi.student_preference Properties */ - checkInvalidSet('cmi.student_preference._children', scorm12_constants.student_preference_children); - checkValidValues('cmi.student_preference.audio', scorm12_error_codes.TYPE_MISMATCH, [ - '1', - '-1', - '50', - '100', - ], [ - 'invalid', - 'a100' - ]); - checkValidValues('cmi.student_preference.audio', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ - '101', - '5000000', - '-500' - ]); - checkFieldConstraintSize('cmi.student_preference.language', 255); - checkValidValues('cmi.student_preference.speed', scorm12_error_codes.TYPE_MISMATCH, [ - '1', - '-100', - '50', - '100', - ], [ - 'invalid', - 'a100' - ]); - checkValidValues('cmi.student_preference.speed', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ - '101', - '-101', - '5000000', - '-500' - ]); - checkValidValues('cmi.student_preference.text', scorm12_error_codes.TYPE_MISMATCH, [ - '1', - '-1' - ], [ - 'invalid', - 'a100' - ]); - checkValidValues('cmi.student_preference.text', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ - '2', - '-2' - ]); + checkInvalidSet('cmi.student_preference._children', scorm12_constants.student_preference_children); + checkValidValues('cmi.student_preference.audio', scorm12_error_codes.TYPE_MISMATCH, [ + '1', + '-1', + '50', + '100', + ], [ + 'invalid', + 'a100', + ]); + checkValidValues('cmi.student_preference.audio', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ + '101', + '5000000', + '-500', + ]); + checkFieldConstraintSize('cmi.student_preference.language', 255); + checkValidValues('cmi.student_preference.speed', scorm12_error_codes.TYPE_MISMATCH, [ + '1', + '-100', + '50', + '100', + ], [ + 'invalid', + 'a100', + ]); + checkValidValues('cmi.student_preference.speed', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ + '101', + '-101', + '5000000', + '-500', + ]); + checkValidValues('cmi.student_preference.text', scorm12_error_codes.TYPE_MISMATCH, [ + '1', + '-1', + ], [ + 'invalid', + 'a100', + ]); + checkValidValues('cmi.student_preference.text', scorm12_error_codes.VALUE_OUT_OF_RANGE, [], [ + '2', + '-2', + ]); - /** + /** * cmi.interactions Properties */ - checkInvalidSet('cmi.interactions._children', scorm12_constants.interactions_children); - checkInvalidSet('cmi.interactions._count', 0); - }); - }); -}); \ No newline at end of file + checkInvalidSet('cmi.interactions._children', scorm12_constants.interactions_children); + checkInvalidSet('cmi.interactions._count', 0); + }); + }); +});