More test cases and breaking out valid/invalid values to be reusable
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
|||||||
import * as Utilities from './utilities';
|
import * as Utilities from './utilities';
|
||||||
import {scorm12_constants} from './constants/api_constants';
|
import {scorm12_constants} from './constants/api_constants';
|
||||||
import {scorm12_error_codes} from './constants/error_codes';
|
import {scorm12_error_codes} from './constants/error_codes';
|
||||||
import {scorm12_regex} from './regex';
|
import {scorm12_regex} from './constants/regex';
|
||||||
|
|
||||||
const constants = scorm12_constants;
|
const constants = scorm12_constants;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {scorm2004_constants} from './constants/api_constants';
|
|||||||
import {scorm2004_error_codes} from './constants/error_codes';
|
import {scorm2004_error_codes} from './constants/error_codes';
|
||||||
import {correct_responses} from './constants/response_constants';
|
import {correct_responses} from './constants/response_constants';
|
||||||
import {valid_languages} from './constants/language_constants';
|
import {valid_languages} from './constants/language_constants';
|
||||||
import {scorm2004_regex} from './regex';
|
import {scorm2004_regex} from './constants/regex';
|
||||||
|
|
||||||
const constants = scorm2004_constants;
|
const constants = scorm2004_constants;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as Scorm12CMI from './scorm12_cmi';
|
import * as Scorm12CMI from './scorm12_cmi';
|
||||||
import {BaseCMI, CMIArray, CMIScore} from './common';
|
import {BaseCMI, CMIArray, CMIScore} from './common';
|
||||||
import {aicc_constants} from '../constants/api_constants';
|
import {aicc_constants} from '../constants/api_constants';
|
||||||
import {aicc_regex} from '../regex';
|
import {aicc_regex} from '../constants/regex';
|
||||||
import {scorm12_error_codes} from '../constants/error_codes';
|
import {scorm12_error_codes} from '../constants/error_codes';
|
||||||
import {
|
import {
|
||||||
check12ValidFormat,
|
check12ValidFormat,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import {scorm12_constants} from '../constants/api_constants';
|
import {scorm12_constants} from '../constants/api_constants';
|
||||||
import {scorm12_error_codes} from '../constants/error_codes';
|
import {scorm12_error_codes} from '../constants/error_codes';
|
||||||
import {ValidationError} from '../exceptions';
|
import {ValidationError} from '../exceptions';
|
||||||
import {scorm12_regex} from '../regex';
|
import {scorm12_regex} from '../constants/regex';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the value matches the proper format. If not, throw proper error code.
|
* Check if the value matches the proper format. If not, throw proper error code.
|
||||||
@@ -10,12 +10,20 @@ import {scorm12_regex} from '../regex';
|
|||||||
* @param {string} value
|
* @param {string} value
|
||||||
* @param {string} regexPattern
|
* @param {string} regexPattern
|
||||||
* @param {number} errorCode
|
* @param {number} errorCode
|
||||||
|
* @param {boolean} allowEmptyString
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
export function checkValidFormat(
|
export function checkValidFormat(
|
||||||
value: String, regexPattern: String, errorCode: number) {
|
value: String,
|
||||||
|
regexPattern: String,
|
||||||
|
errorCode: number,
|
||||||
|
allowEmptyString?: boolean) {
|
||||||
const formatRegex = new RegExp(regexPattern);
|
const formatRegex = new RegExp(regexPattern);
|
||||||
if (!value || !value.match(formatRegex)) {
|
const matches = value.match(formatRegex);
|
||||||
|
if (allowEmptyString && value === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (value === undefined || !matches || matches[0] === '') {
|
||||||
throw new ValidationError(errorCode);
|
throw new ValidationError(errorCode);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -97,7 +105,7 @@ export class CMIScore extends BaseCMI {
|
|||||||
score_children :
|
score_children :
|
||||||
scorm12_constants.score_children;
|
scorm12_constants.score_children;
|
||||||
this.#_score_range = !score_range ? false : scorm12_regex.score_range;
|
this.#_score_range = !score_range ? false : scorm12_regex.score_range;
|
||||||
this.#max = max ? max : '100';
|
this.#max = (max || max === '') ? max : '100';
|
||||||
this.#_invalid_error_code = invalidErrorCode ?
|
this.#_invalid_error_code = invalidErrorCode ?
|
||||||
invalidErrorCode :
|
invalidErrorCode :
|
||||||
scorm12_error_codes.INVALID_SET_VALUE;
|
scorm12_error_codes.INVALID_SET_VALUE;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from './common';
|
} from './common';
|
||||||
import {scorm12_constants} from '../constants/api_constants';
|
import {scorm12_constants} from '../constants/api_constants';
|
||||||
import {scorm12_error_codes} from '../constants/error_codes';
|
import {scorm12_error_codes} from '../constants/error_codes';
|
||||||
import {scorm12_regex} from '../regex';
|
import {scorm12_regex} from '../constants/regex';
|
||||||
import {ValidationError} from '../exceptions';
|
import {ValidationError} from '../exceptions';
|
||||||
|
|
||||||
const constants = scorm12_constants;
|
const constants = scorm12_constants;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
CMIScore,
|
CMIScore,
|
||||||
} from './common';
|
} from './common';
|
||||||
import {scorm2004_constants} from '../constants/api_constants';
|
import {scorm2004_constants} from '../constants/api_constants';
|
||||||
import {scorm2004_regex} from '../regex';
|
import {scorm2004_regex} from '../constants/regex';
|
||||||
import {scorm2004_error_codes} from '../constants/error_codes';
|
import {scorm2004_error_codes} from '../constants/error_codes';
|
||||||
import {learner_responses} from '../constants/response_constants';
|
import {learner_responses} from '../constants/response_constants';
|
||||||
import {ValidationError} from '../exceptions';
|
import {ValidationError} from '../exceptions';
|
||||||
@@ -40,11 +40,15 @@ function throwTypeMismatchError() {
|
|||||||
* Helper method, no reason to have to pass the same error codes every time
|
* Helper method, no reason to have to pass the same error codes every time
|
||||||
* @param {*} value
|
* @param {*} value
|
||||||
* @param {string} regexPattern
|
* @param {string} regexPattern
|
||||||
|
* @param {boolean} allowEmptyString
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
function check2004ValidFormat(value: String, regexPattern: String) {
|
function check2004ValidFormat(
|
||||||
|
value: String,
|
||||||
|
regexPattern: String,
|
||||||
|
allowEmptyString?: boolean) {
|
||||||
return checkValidFormat(value, regexPattern,
|
return checkValidFormat(value, regexPattern,
|
||||||
scorm2004_error_codes.TYPE_MISMATCH);
|
scorm2004_error_codes.TYPE_MISMATCH, allowEmptyString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -943,7 +947,7 @@ export class CMIInteractionsObject extends BaseCMI {
|
|||||||
* @param {string} description
|
* @param {string} description
|
||||||
*/
|
*/
|
||||||
set description(description) {
|
set description(description) {
|
||||||
if (check2004ValidFormat(description, regex.CMILangString250)) {
|
if (check2004ValidFormat(description, regex.CMILangString250, true)) {
|
||||||
this.#description = description;
|
this.#description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1098,7 +1102,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
|||||||
* @param {string} description
|
* @param {string} description
|
||||||
*/
|
*/
|
||||||
set description(description) {
|
set description(description) {
|
||||||
if (check2004ValidFormat(description, regex.CMILangString250)) {
|
if (check2004ValidFormat(description, regex.CMILangString250, true)) {
|
||||||
this.#description = description;
|
this.#description = description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1112,7 +1116,8 @@ export class CMIObjectivesObject extends BaseCMI {
|
|||||||
* success_status: string,
|
* success_status: string,
|
||||||
* completion_status: string,
|
* completion_status: string,
|
||||||
* progress_measure: string,
|
* progress_measure: string,
|
||||||
* description: string
|
* description: string,
|
||||||
|
* score: Scorm2004CMIScore
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
@@ -1124,6 +1129,7 @@ export class CMIObjectivesObject extends BaseCMI {
|
|||||||
'completion_status': this.completion_status,
|
'completion_status': this.completion_status,
|
||||||
'progress_measure': this.progress_measure,
|
'progress_measure': this.progress_measure,
|
||||||
'description': this.description,
|
'description': this.description,
|
||||||
|
'score': this.score,
|
||||||
};
|
};
|
||||||
delete this.jsonString;
|
delete this.jsonString;
|
||||||
return result;
|
return result;
|
||||||
@@ -1186,9 +1192,9 @@ class Scorm2004CMIScore extends CMIScore {
|
|||||||
this.jsonString = true;
|
this.jsonString = true;
|
||||||
const result = {
|
const result = {
|
||||||
'scaled': this.scaled,
|
'scaled': this.scaled,
|
||||||
'raw': this.raw,
|
'raw': super.raw,
|
||||||
'min': this.min,
|
'min': super.min,
|
||||||
'max': this.max,
|
'max': super.max,
|
||||||
};
|
};
|
||||||
delete this.jsonString;
|
delete this.jsonString;
|
||||||
return result;
|
return result;
|
||||||
@@ -1208,6 +1214,9 @@ export class CMICommentsFromLearnerObject extends BaseCMI {
|
|||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
this.#comment = '';
|
||||||
|
this.#location = '';
|
||||||
|
this.#timestamp = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1223,7 +1232,7 @@ export class CMICommentsFromLearnerObject extends BaseCMI {
|
|||||||
* @param {string} comment
|
* @param {string} comment
|
||||||
*/
|
*/
|
||||||
set comment(comment) {
|
set comment(comment) {
|
||||||
if (check2004ValidFormat(comment, regex.CMILangString4000)) {
|
if (check2004ValidFormat(comment, regex.CMILangString4000, true)) {
|
||||||
this.#comment = comment;
|
this.#comment = comment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1263,6 +1272,27 @@ export class CMICommentsFromLearnerObject extends BaseCMI {
|
|||||||
this.#timestamp = timestamp;
|
this.#timestamp = timestamp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toJSON for cmi.comments_from_learner.n object
|
||||||
|
* @return {
|
||||||
|
* {
|
||||||
|
* comment: string,
|
||||||
|
* location: string,
|
||||||
|
* timestamp: string
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
this.jsonString = true;
|
||||||
|
const result = {
|
||||||
|
'comment': this.comment,
|
||||||
|
'location': this.location,
|
||||||
|
'timestamp': this.timestamp,
|
||||||
|
};
|
||||||
|
delete this.jsonString;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1276,12 +1306,28 @@ export class CMICommentsFromLMSObject extends CMICommentsFromLearnerObject {
|
|||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for #comment
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
get comment() {
|
||||||
|
return super.comment;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for #comment. Can only be called before initialization.
|
* Setter for #comment. Can only be called before initialization.
|
||||||
* @param {string} comment
|
* @param {string} comment
|
||||||
*/
|
*/
|
||||||
set comment(comment) {
|
set comment(comment) {
|
||||||
!this.initialized ? this.comment = comment : throwReadOnlyError();
|
!this.initialized ? super.comment = comment : throwReadOnlyError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for #location
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
get location() {
|
||||||
|
return super.location;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1289,7 +1335,15 @@ export class CMICommentsFromLMSObject extends CMICommentsFromLearnerObject {
|
|||||||
* @param {string} location
|
* @param {string} location
|
||||||
*/
|
*/
|
||||||
set location(location) {
|
set location(location) {
|
||||||
!this.initialized ? this.location = location : throwReadOnlyError();
|
!this.initialized ? super.location = location : throwReadOnlyError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for #timestamp
|
||||||
|
* @return {string}
|
||||||
|
*/
|
||||||
|
get timestamp() {
|
||||||
|
return super.timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1297,7 +1351,21 @@ export class CMICommentsFromLMSObject extends CMICommentsFromLearnerObject {
|
|||||||
* @param {string} timestamp
|
* @param {string} timestamp
|
||||||
*/
|
*/
|
||||||
set timestamp(timestamp) {
|
set timestamp(timestamp) {
|
||||||
!this.initialized ? this.timestamp = timestamp : throwReadOnlyError();
|
!this.initialized ? super.timestamp = timestamp : throwReadOnlyError();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toJSON for cmi.comments_from_lms.n
|
||||||
|
* @return {
|
||||||
|
* {
|
||||||
|
* comment: string,
|
||||||
|
* location: string,
|
||||||
|
* timestamp: string
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
return super.toJSON();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1331,6 +1399,23 @@ export class CMIInteractionsObjectivesObject extends BaseCMI {
|
|||||||
this.#id = id;
|
this.#id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toJSON for cmi.interactions.n.objectives.n
|
||||||
|
* @return {
|
||||||
|
* {
|
||||||
|
* id: string
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
this.jsonString = true;
|
||||||
|
const result = {
|
||||||
|
'id': this.id,
|
||||||
|
};
|
||||||
|
delete this.jsonString;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1363,6 +1448,23 @@ export class CMIInteractionsCorrectResponsesObject extends BaseCMI {
|
|||||||
this.#pattern = pattern;
|
this.#pattern = pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* toJSON cmi.interactions.n.correct_responses.n object
|
||||||
|
* @return {
|
||||||
|
* {
|
||||||
|
* pattern: string
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
toJSON() {
|
||||||
|
this.jsonString = true;
|
||||||
|
const result = {
|
||||||
|
'pattern': this.pattern,
|
||||||
|
};
|
||||||
|
delete this.jsonString;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
334
src/constants/field_values.js
Normal file
334
src/constants/field_values.js
Normal file
@@ -0,0 +1,334 @@
|
|||||||
|
const common_values = {
|
||||||
|
validResult: [
|
||||||
|
'correct',
|
||||||
|
'wrong',
|
||||||
|
'unanticipated',
|
||||||
|
'neutral',
|
||||||
|
],
|
||||||
|
invalidResult: [
|
||||||
|
'-10000',
|
||||||
|
'10000',
|
||||||
|
'invalid',
|
||||||
|
],
|
||||||
|
|
||||||
|
valid0To1Range: [
|
||||||
|
'0.0',
|
||||||
|
'0.25',
|
||||||
|
'0.5',
|
||||||
|
'1.0',
|
||||||
|
],
|
||||||
|
invalid0To1Range: [
|
||||||
|
'-1',
|
||||||
|
'-0.1',
|
||||||
|
'1.1',
|
||||||
|
'.25',
|
||||||
|
],
|
||||||
|
|
||||||
|
valid0To100Range: [
|
||||||
|
'1',
|
||||||
|
'50',
|
||||||
|
'100',
|
||||||
|
],
|
||||||
|
invalid0To100Range: [
|
||||||
|
'invalid',
|
||||||
|
'a100',
|
||||||
|
'-1',
|
||||||
|
],
|
||||||
|
|
||||||
|
validScaledRange: [
|
||||||
|
'1',
|
||||||
|
'0.5',
|
||||||
|
'0',
|
||||||
|
'-0.5',
|
||||||
|
'-1',
|
||||||
|
],
|
||||||
|
invalidScaledRange: [
|
||||||
|
'-101',
|
||||||
|
'25.1',
|
||||||
|
'50.5',
|
||||||
|
'75',
|
||||||
|
'100',
|
||||||
|
],
|
||||||
|
|
||||||
|
validIntegerScaledRange: [
|
||||||
|
'1',
|
||||||
|
'0',
|
||||||
|
'-1',
|
||||||
|
],
|
||||||
|
invalidIntegerScaledRange: [
|
||||||
|
'-101',
|
||||||
|
'-0.5',
|
||||||
|
'0.5',
|
||||||
|
'25.1',
|
||||||
|
'50.5',
|
||||||
|
'75',
|
||||||
|
'100',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const scorm12_values = {
|
||||||
|
...common_values, ...{
|
||||||
|
validLessonStatus: [
|
||||||
|
'passed',
|
||||||
|
'completed',
|
||||||
|
'failed',
|
||||||
|
'incomplete',
|
||||||
|
'browsed',
|
||||||
|
],
|
||||||
|
invalidLessonStatus: [
|
||||||
|
'Passed',
|
||||||
|
'P',
|
||||||
|
'F',
|
||||||
|
'p',
|
||||||
|
'true',
|
||||||
|
'false',
|
||||||
|
'complete',
|
||||||
|
],
|
||||||
|
|
||||||
|
validExit: [
|
||||||
|
'time-out',
|
||||||
|
'suspend',
|
||||||
|
'logout',
|
||||||
|
],
|
||||||
|
invalidExit: [
|
||||||
|
'close',
|
||||||
|
'exit',
|
||||||
|
'crash',
|
||||||
|
],
|
||||||
|
|
||||||
|
validType: [
|
||||||
|
'true-false',
|
||||||
|
'choice',
|
||||||
|
'fill-in',
|
||||||
|
'matching',
|
||||||
|
'performance',
|
||||||
|
'sequencing',
|
||||||
|
'likert',
|
||||||
|
'numeric',
|
||||||
|
],
|
||||||
|
invalidType: [
|
||||||
|
'correct',
|
||||||
|
'wrong',
|
||||||
|
'logout',
|
||||||
|
],
|
||||||
|
|
||||||
|
validSpeedRange: [
|
||||||
|
'1',
|
||||||
|
'50',
|
||||||
|
'100',
|
||||||
|
'-1',
|
||||||
|
'-50',
|
||||||
|
'-100',
|
||||||
|
],
|
||||||
|
invalidSpeedRange: [
|
||||||
|
'invalid',
|
||||||
|
'a100',
|
||||||
|
'-101',
|
||||||
|
'101',
|
||||||
|
'-100000',
|
||||||
|
'100000',
|
||||||
|
],
|
||||||
|
|
||||||
|
validScoreRange: [
|
||||||
|
'1',
|
||||||
|
'50.25',
|
||||||
|
'100',
|
||||||
|
],
|
||||||
|
invalidScoreRange: [
|
||||||
|
'invalid',
|
||||||
|
'a100',
|
||||||
|
'-1',
|
||||||
|
'101',
|
||||||
|
'-100000',
|
||||||
|
'100000',
|
||||||
|
],
|
||||||
|
invalid0To100Range: [
|
||||||
|
'invalid',
|
||||||
|
'a100',
|
||||||
|
'-2',
|
||||||
|
],
|
||||||
|
|
||||||
|
validTime: [
|
||||||
|
'10:06:57',
|
||||||
|
'23:59:59',
|
||||||
|
'00:00:00',
|
||||||
|
],
|
||||||
|
invalidTime: [
|
||||||
|
'47:59:59',
|
||||||
|
'00:00:01.56',
|
||||||
|
'06:5:13',
|
||||||
|
'23:59:59.123',
|
||||||
|
'P1DT23H59M59S',
|
||||||
|
],
|
||||||
|
|
||||||
|
validTimestamp: [
|
||||||
|
'10:06:57',
|
||||||
|
'00:00:01.56',
|
||||||
|
'23:59:59',
|
||||||
|
'47:59:59',
|
||||||
|
],
|
||||||
|
invalidTimestamp: [
|
||||||
|
'06:5:13',
|
||||||
|
'23:59:59.123',
|
||||||
|
'P1DT23H59M59S',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const scorm2004_values = {
|
||||||
|
...common_values, ...{
|
||||||
|
// valid field values
|
||||||
|
validTimestamps: [
|
||||||
|
'2019-06-25',
|
||||||
|
'2019-06-25T23:59',
|
||||||
|
'2019-06-25T23:59:59.99',
|
||||||
|
'1970-01-01',
|
||||||
|
],
|
||||||
|
invalidTimestamps: [
|
||||||
|
'2019-06-25T',
|
||||||
|
'2019-06-25T23:59:59.999',
|
||||||
|
'2019-06-25T25:59:59.99',
|
||||||
|
'2019-13-31',
|
||||||
|
'1969-12-31',
|
||||||
|
'-00:00:30',
|
||||||
|
'0:50:30',
|
||||||
|
'23:00:30.',
|
||||||
|
],
|
||||||
|
|
||||||
|
validCStatus: [
|
||||||
|
'completed',
|
||||||
|
'incomplete',
|
||||||
|
'not attempted',
|
||||||
|
'unknown',
|
||||||
|
],
|
||||||
|
invalidCStatus: [
|
||||||
|
'complete',
|
||||||
|
'passed',
|
||||||
|
'failed',
|
||||||
|
],
|
||||||
|
|
||||||
|
validSStatus: [
|
||||||
|
'passed',
|
||||||
|
'failed',
|
||||||
|
'unknown',
|
||||||
|
],
|
||||||
|
invalidSStatus: [
|
||||||
|
'complete',
|
||||||
|
'incomplete',
|
||||||
|
'P',
|
||||||
|
'f',
|
||||||
|
],
|
||||||
|
|
||||||
|
validExit: [
|
||||||
|
'time-out',
|
||||||
|
'suspend',
|
||||||
|
'logout',
|
||||||
|
'normal',
|
||||||
|
],
|
||||||
|
invalidExit: [
|
||||||
|
'close',
|
||||||
|
'exit',
|
||||||
|
'crash',
|
||||||
|
],
|
||||||
|
|
||||||
|
validType: [
|
||||||
|
'true-false',
|
||||||
|
'choice',
|
||||||
|
'fill-in',
|
||||||
|
'long-fill-in',
|
||||||
|
'matching',
|
||||||
|
'performance',
|
||||||
|
'sequencing',
|
||||||
|
'likert',
|
||||||
|
'numeric',
|
||||||
|
'other',
|
||||||
|
],
|
||||||
|
invalidType: [
|
||||||
|
'correct',
|
||||||
|
'wrong',
|
||||||
|
'logout',
|
||||||
|
],
|
||||||
|
|
||||||
|
validScoreRange: [
|
||||||
|
'1',
|
||||||
|
'50',
|
||||||
|
'100',
|
||||||
|
'-10000',
|
||||||
|
'-1',
|
||||||
|
'10000',
|
||||||
|
],
|
||||||
|
invalidScoreRange: [
|
||||||
|
'invalid',
|
||||||
|
'a100',
|
||||||
|
'-100000',
|
||||||
|
'100000',
|
||||||
|
],
|
||||||
|
|
||||||
|
validISO8601Durations: [
|
||||||
|
'P1Y34DT23H45M15S',
|
||||||
|
'PT1M45S',
|
||||||
|
'P0S',
|
||||||
|
'PT75M',
|
||||||
|
],
|
||||||
|
invalidISO8601Durations: [
|
||||||
|
'00:08:45',
|
||||||
|
'-P1H',
|
||||||
|
'1y45D',
|
||||||
|
'0',
|
||||||
|
],
|
||||||
|
|
||||||
|
validComment: [
|
||||||
|
'{lang=en-98} learner comment',
|
||||||
|
'{lang=eng-98-9} learner comment',
|
||||||
|
'{lang=eng-98-9fhgj}' + 'x'.repeat(4000),
|
||||||
|
'learner comment',
|
||||||
|
'learner comment}',
|
||||||
|
'{lang=i-xx}',
|
||||||
|
'{lang=i}',
|
||||||
|
'',
|
||||||
|
],
|
||||||
|
invalidComment: [
|
||||||
|
'{lang=i-}',
|
||||||
|
'{lang=i-x}',
|
||||||
|
'{lang=eng-98-9fhgj}{ learner comment',
|
||||||
|
'{learner comment',
|
||||||
|
'{lang=eng-98-9fhgj}' + 'x'.repeat(4001),
|
||||||
|
'{lang=eng-98-9fhgj}{' + 'x'.repeat(3999),
|
||||||
|
],
|
||||||
|
|
||||||
|
validDescription: [
|
||||||
|
'{lang=en-98} learner comment',
|
||||||
|
'{lang=eng-98-9} learner comment',
|
||||||
|
'{lang=eng-98-9fhgj}' + 'x'.repeat(250),
|
||||||
|
'learner comment',
|
||||||
|
'learner comment}',
|
||||||
|
'{lang=i-xx}',
|
||||||
|
'{lang=i}',
|
||||||
|
'',
|
||||||
|
],
|
||||||
|
invalidDescription: [
|
||||||
|
'{lang=i-}',
|
||||||
|
'{lang=i-x}',
|
||||||
|
'{lang=eng-98-9fhgj}{ learner comment',
|
||||||
|
'{learner comment',
|
||||||
|
'{lang=eng-98-9fhgj}' + 'x'.repeat(251),
|
||||||
|
'{lang=eng-98-9fhgj}{' + 'x'.repeat(249),
|
||||||
|
],
|
||||||
|
|
||||||
|
validNavRequest: [
|
||||||
|
'previous',
|
||||||
|
'continue',
|
||||||
|
'exit',
|
||||||
|
'exitAll',
|
||||||
|
'abandon',
|
||||||
|
'abandonAll',
|
||||||
|
'suspendAll',
|
||||||
|
],
|
||||||
|
invalidNavRequest: [
|
||||||
|
'close',
|
||||||
|
'quit',
|
||||||
|
'next',
|
||||||
|
'before',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
import {scorm12_values, scorm2004_values} from './field_values';
|
||||||
|
|
||||||
export const scorm12_regex = {
|
export const scorm12_regex = {
|
||||||
CMIString256: '^.{0,255}$',
|
CMIString256: '^.{0,255}$',
|
||||||
CMIString4096: '^.{0,4096}$',
|
CMIString4096: '^.{0,4096}$',
|
||||||
@@ -13,11 +15,11 @@ export const scorm12_regex = {
|
|||||||
CMIIndex: '[._](\\d+).',
|
CMIIndex: '[._](\\d+).',
|
||||||
|
|
||||||
// Vocabulary Data Type Definition
|
// Vocabulary Data Type Definition
|
||||||
CMIStatus: '^(passed|completed|failed|incomplete|browsed)$',
|
CMIStatus: '^(' + scorm12_values.validLessonStatus.join('|') + ')$',
|
||||||
CMIStatus2: '^(passed|completed|failed|incomplete|browsed|not attempted)$',
|
CMIStatus2: '^(' + scorm12_values.validLessonStatus.join('|') + '|not attempted)$',
|
||||||
CMIExit: '^(time-out|suspend|logout|)$',
|
CMIExit: '^(' + scorm12_values.validExit.join('|') + '|)$',
|
||||||
CMIType: '^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$',
|
CMIType: '^(' + scorm12_values.validType.join('|') + ')$',
|
||||||
CMIResult: '^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$', // eslint-disable-line
|
CMIResult: '^(' + scorm12_values.validResult.join('|') + '|([0-9]{0,3})?(\\.[0-9]*)?)$', // eslint-disable-line
|
||||||
NAVEvent: '^(previous|continue)$',
|
NAVEvent: '^(previous|continue)$',
|
||||||
|
|
||||||
// Data ranges
|
// Data ranges
|
||||||
@@ -41,10 +43,10 @@ export const scorm2004_regex = {
|
|||||||
CMIString4000: '^[\\u0000-\\uFFFF]{0,4000}$',
|
CMIString4000: '^[\\u0000-\\uFFFF]{0,4000}$',
|
||||||
CMIString64000: '^[\\u0000-\\uFFFF]{0,64000}$',
|
CMIString64000: '^[\\u0000-\\uFFFF]{0,64000}$',
|
||||||
CMILang: '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$', // eslint-disable-line
|
CMILang: '^([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?$|^$', // eslint-disable-line
|
||||||
CMILangString250: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,250}$)?', // eslint-disable-line
|
CMILangString250: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?((?!\{.*$).{0,250}$)?$', // eslint-disable-line
|
||||||
CMILangcr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\}))(.*?)$', // eslint-disable-line
|
CMILangcr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\}))(.*?)$', // eslint-disable-line
|
||||||
CMILangString250cr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\})?(.{0,250})?)?$', // eslint-disable-line
|
CMILangString250cr: '^((\{lang=([a-zA-Z]{2,3}|i|x)?(\-[a-zA-Z0-9\-]{2,8})?\})?(.{0,250})?)?$', // eslint-disable-line
|
||||||
CMILangString4000: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?([^\{].{0,4000}$)?', // eslint-disable-line
|
CMILangString4000: '^(\{lang=([a-zA-Z]{2,3}|i|x)(\-[a-zA-Z0-9\-]{2,8})?\})?((?!\{.*$).{0,4000}$)?$', // eslint-disable-line
|
||||||
CMITime: '^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$',
|
CMITime: '^(19[7-9]{1}[0-9]{1}|20[0-2]{1}[0-9]{1}|203[0-8]{1})((-(0[1-9]{1}|1[0-2]{1}))((-(0[1-9]{1}|[1-2]{1}[0-9]{1}|3[0-1]{1}))(T([0-1]{1}[0-9]{1}|2[0-3]{1})((:[0-5]{1}[0-9]{1})((:[0-5]{1}[0-9]{1})((\\.[0-9]{1,2})((Z|([+|-]([0-1]{1}[0-9]{1}|2[0-3]{1})))(:[0-5]{1}[0-9]{1})?)?)?)?)?)?)?)?$',
|
||||||
CMITimespan: '^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$',
|
CMITimespan: '^P(?:([.,\\d]+)Y)?(?:([.,\\d]+)M)?(?:([.,\\d]+)W)?(?:([.,\\d]+)D)?(?:T?(?:([.,\\d]+)H)?(?:([.,\\d]+)M)?(?:([.,\\d]+)S)?)?$',
|
||||||
CMIInteger: '^\\d+$',
|
CMIInteger: '^\\d+$',
|
||||||
@@ -58,12 +60,12 @@ export const scorm2004_regex = {
|
|||||||
CMIIndexStore: '.N(\\d+).',
|
CMIIndexStore: '.N(\\d+).',
|
||||||
|
|
||||||
// Vocabulary Data Type Definition
|
// Vocabulary Data Type Definition
|
||||||
CMICStatus: '^(completed|incomplete|not attempted|unknown)$',
|
CMICStatus: '^(' + scorm2004_values.validCStatus.join('|') + ')$',
|
||||||
CMISStatus: '^(passed|failed|unknown)$',
|
CMISStatus: '^(' + scorm2004_values.validSStatus.join('|') + ')$',
|
||||||
CMIExit: '^(time-out|suspend|logout|normal|)$',
|
CMIExit: '^(' + scorm2004_values.validExit.join('|') + ')$',
|
||||||
CMIType: '^(true-false|choice|(long-)?fill-in|matching|performance|sequencing|likert|numeric|other)$',
|
CMIType: '^(' + scorm2004_values.validType.join('|') + ')$',
|
||||||
CMIResult: '^(correct|incorrect|unanticipated|neutral|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$',
|
CMIResult: '^(' + scorm2004_values.validResult.join('|') + '|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$',
|
||||||
NAVEvent: '^(previous|continue|exit|exitAll|abandon|abandonAll|suspendAll|\{target=\\S{0,200}[a-zA-Z0-9]\}choice|jump)$', // eslint-disable-line
|
NAVEvent: '^(' + scorm2004_values.validNavRequest.join('|') + '|\{target=\\S{0,200}[a-zA-Z0-9]\}choice|jump)$', // eslint-disable-line
|
||||||
NAVBoolean: '^(unknown|true|false$)',
|
NAVBoolean: '^(unknown|true|false$)',
|
||||||
NAVTarget: '^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$',
|
NAVTarget: '^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$',
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import {scorm2004_regex} from '../regex';
|
import {scorm2004_regex} from './regex';
|
||||||
|
|
||||||
export const learner_responses = {
|
export const learner_responses = {
|
||||||
'true-false': {
|
'true-false': {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
CMIObjectivesObject,
|
CMIObjectivesObject,
|
||||||
} from '../../src/cmi/scorm12_cmi';
|
} from '../../src/cmi/scorm12_cmi';
|
||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
|
import {scorm12_values} from '../../src/constants/field_values';
|
||||||
|
|
||||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||||
@@ -94,22 +95,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.lesson_status',
|
fieldName: 'cmi.core.lesson_status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus,
|
||||||
'passed',
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'Passed',
|
|
||||||
'P',
|
|
||||||
'F',
|
|
||||||
'p',
|
|
||||||
'true',
|
|
||||||
'false',
|
|
||||||
'complete',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadAndWrite({
|
h.checkReadAndWrite({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -132,14 +119,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.exit',
|
fieldName: 'cmi.core.exit',
|
||||||
validValues: [
|
validValues: scorm12_values.validExit,
|
||||||
'time-out',
|
invalidValues: scorm12_values.invalidExit,
|
||||||
'suspend',
|
|
||||||
'logout',
|
|
||||||
], invalidValues: [
|
|
||||||
'complete',
|
|
||||||
'exit',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
@@ -151,17 +132,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.session_time',
|
fieldName: 'cmi.core.session_time',
|
||||||
validValues: [
|
validValues: scorm12_values.validTimestamp,
|
||||||
'10:06:57',
|
invalidValues: scorm12_values.invalidTimestamp,
|
||||||
'00:00:01.56',
|
|
||||||
'23:59:59',
|
|
||||||
'47:59:59',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'06:5:13',
|
|
||||||
'23:59:59.123',
|
|
||||||
'P1DT23H59M59S',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,47 +149,20 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.raw',
|
fieldName: 'cmi.core.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.min',
|
fieldName: 'cmi.core.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.max',
|
fieldName: 'cmi.core.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -273,26 +218,10 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.audio',
|
fieldName: 'cmi.student_preference.audio',
|
||||||
validValues: [
|
validValues: scorm12_values.valid0To100Range.concat([
|
||||||
'1',
|
|
||||||
'-1',
|
'-1',
|
||||||
'50',
|
]),
|
||||||
'100',
|
invalidValues: scorm12_values.invalid0To100Range,
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.audio',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkFieldConstraintSize({
|
h.checkFieldConstraintSize({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -303,48 +232,14 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.speed',
|
fieldName: 'cmi.student_preference.speed',
|
||||||
validValues: [
|
validValues: scorm12_values.validSpeedRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidSpeedRange,
|
||||||
'-100',
|
|
||||||
'50',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.speed',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'-101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.text',
|
fieldName: 'cmi.student_preference.text',
|
||||||
validValues: [
|
validValues: scorm12_values.validIntegerScaledRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidIntegerScaledRange,
|
||||||
'-1',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.text',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'2',
|
|
||||||
'-2',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -443,22 +338,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.lesson_status',
|
fieldName: 'cmi.core.lesson_status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus,
|
||||||
'passed',
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'Passed',
|
|
||||||
'P',
|
|
||||||
'F',
|
|
||||||
'p',
|
|
||||||
'true',
|
|
||||||
'false',
|
|
||||||
'complete',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadOnly({
|
h.checkReadOnly({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -484,14 +365,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.exit',
|
fieldName: 'cmi.core.exit',
|
||||||
validValues: [
|
validValues: scorm12_values.validExit,
|
||||||
'time-out',
|
invalidValues: scorm12_values.invalidExit,
|
||||||
'suspend',
|
|
||||||
'logout',
|
|
||||||
], invalidValues: [
|
|
||||||
'complete',
|
|
||||||
'exit',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -502,17 +377,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.session_time',
|
fieldName: 'cmi.core.session_time',
|
||||||
validValues: [
|
validValues: scorm12_values.validTimestamp,
|
||||||
'10:06:57',
|
invalidValues: scorm12_values.invalidTimestamp,
|
||||||
'00:00:01.56',
|
|
||||||
'23:59:59',
|
|
||||||
'47:59:59',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'06:5:13',
|
|
||||||
'23:59:59.123',
|
|
||||||
'P1DT23H59M59S',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -527,47 +393,20 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.raw',
|
fieldName: 'cmi.core.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.min',
|
fieldName: 'cmi.core.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.max',
|
fieldName: 'cmi.core.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -627,26 +466,10 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.audio',
|
fieldName: 'cmi.student_preference.audio',
|
||||||
validValues: [
|
validValues: scorm12_values.valid0To100Range.concat([
|
||||||
'1',
|
|
||||||
'-1',
|
'-1',
|
||||||
'50',
|
]),
|
||||||
'100',
|
invalidValues: scorm12_values.invalid0To100Range,
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.audio',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkFieldConstraintSize({
|
h.checkFieldConstraintSize({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -657,48 +480,14 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.speed',
|
fieldName: 'cmi.student_preference.speed',
|
||||||
validValues: [
|
validValues: scorm12_values.validSpeedRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidSpeedRange,
|
||||||
'-100',
|
|
||||||
'50',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.speed',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'-101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.text',
|
fieldName: 'cmi.student_preference.text',
|
||||||
validValues: [
|
validValues: scorm12_values.validIntegerScaledRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidIntegerScaledRange,
|
||||||
'-1',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.text',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'2',
|
|
||||||
'-2',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -756,21 +545,10 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
fieldName: 'cmi.status',
|
fieldName: 'cmi.status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus.concat([
|
||||||
'passed',
|
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
'not attempted',
|
'not attempted',
|
||||||
],
|
]),
|
||||||
invalidValues: [
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'P',
|
|
||||||
'f',
|
|
||||||
'complete',
|
|
||||||
'started',
|
|
||||||
'in progress',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadAndWrite({
|
h.checkReadAndWrite({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
@@ -781,16 +559,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
fieldName: 'cmi.time',
|
fieldName: 'cmi.time',
|
||||||
validValues: [
|
validValues: scorm12_values.validTime,
|
||||||
'15:00:30',
|
invalidValues: scorm12_values.invalidTime,
|
||||||
'00:50:30',
|
|
||||||
'23:00:30',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-00:00:30',
|
|
||||||
'0:50:30',
|
|
||||||
'23:00:30.',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -805,47 +575,20 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
fieldName: 'cmi.score.raw',
|
fieldName: 'cmi.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
fieldName: 'cmi.score.min',
|
fieldName: 'cmi.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: triesObject(),
|
cmi: triesObject(),
|
||||||
fieldName: 'cmi.score.max',
|
fieldName: 'cmi.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export JSON', () => {
|
it('should export JSON', () => {
|
||||||
@@ -888,16 +631,8 @@ describe('AICC CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: evaluationComment(),
|
cmi: evaluationComment(),
|
||||||
fieldName: 'cmi.time',
|
fieldName: 'cmi.time',
|
||||||
validValues: [
|
validValues: scorm12_values.validTime,
|
||||||
'15:00:30',
|
invalidValues: scorm12_values.invalidTime,
|
||||||
'00:50:30',
|
|
||||||
'23:00:30',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-00:00:30',
|
|
||||||
'0:50:30',
|
|
||||||
'23:00:30.',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export JSON', () => {
|
it('should export JSON', () => {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
CMIObjectivesObject,
|
CMIObjectivesObject,
|
||||||
} from '../../src/cmi/scorm12_cmi';
|
} from '../../src/cmi/scorm12_cmi';
|
||||||
import * as h from '../helpers';
|
import * as h from '../helpers';
|
||||||
|
import {scorm12_values} from '../../src/constants/field_values';
|
||||||
|
|
||||||
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
const invalid_set = scorm12_error_codes.INVALID_SET_VALUE;
|
||||||
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
const type_mismatch = scorm12_error_codes.TYPE_MISMATCH;
|
||||||
@@ -93,22 +94,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.lesson_status',
|
fieldName: 'cmi.core.lesson_status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus,
|
||||||
'passed',
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'Passed',
|
|
||||||
'P',
|
|
||||||
'F',
|
|
||||||
'p',
|
|
||||||
'true',
|
|
||||||
'false',
|
|
||||||
'complete',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadAndWrite({
|
h.checkReadAndWrite({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -131,14 +118,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.exit',
|
fieldName: 'cmi.core.exit',
|
||||||
validValues: [
|
validValues: scorm12_values.validExit,
|
||||||
'time-out',
|
invalidValues: scorm12_values.invalidExit,
|
||||||
'suspend',
|
|
||||||
'logout',
|
|
||||||
], invalidValues: [
|
|
||||||
'complete',
|
|
||||||
'exit',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -149,17 +130,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.session_time',
|
fieldName: 'cmi.core.session_time',
|
||||||
validValues: [
|
validValues: scorm12_values.validHHMMSS,
|
||||||
'10:06:57',
|
invalidValues: scorm12_values.invalidHHMMSS,
|
||||||
'00:00:01.56',
|
|
||||||
'23:59:59',
|
|
||||||
'47:59:59',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'06:5:13',
|
|
||||||
'23:59:59.123',
|
|
||||||
'P1DT23H59M59S',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,17 +150,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.raw',
|
fieldName: 'cmi.core.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkRead({
|
h.checkRead({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -197,17 +160,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.min',
|
fieldName: 'cmi.core.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkRead({
|
h.checkRead({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -217,17 +171,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.max',
|
fieldName: 'cmi.core.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -284,19 +229,10 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.audio',
|
fieldName: 'cmi.student_preference.audio',
|
||||||
validValues: [
|
validValues: scorm12_values.valid0To100Range.concat([
|
||||||
'1',
|
|
||||||
'-1',
|
'-1',
|
||||||
'50',
|
]),
|
||||||
'100',
|
invalidValues: scorm12_values.invalid0To100Range,
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
'101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkFieldConstraintSize({
|
h.checkFieldConstraintSize({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -311,20 +247,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.speed',
|
fieldName: 'cmi.student_preference.speed',
|
||||||
validValues: [
|
validValues: scorm12_values.validSpeedRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidSpeedRange,
|
||||||
'-100',
|
|
||||||
'50',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
'101',
|
|
||||||
'-101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkRead({
|
h.checkRead({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -333,23 +257,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.text',
|
fieldName: 'cmi.student_preference.text',
|
||||||
validValues: [
|
validValues: scorm12_values.validIntegerScaledRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidIntegerScaledRange,
|
||||||
'-1',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.text',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'2',
|
|
||||||
'-2',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -451,22 +360,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.lesson_status',
|
fieldName: 'cmi.core.lesson_status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus,
|
||||||
'passed',
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'Passed',
|
|
||||||
'P',
|
|
||||||
'F',
|
|
||||||
'p',
|
|
||||||
'true',
|
|
||||||
'false',
|
|
||||||
'complete',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadOnly({
|
h.checkReadOnly({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -492,14 +387,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.exit',
|
fieldName: 'cmi.core.exit',
|
||||||
validValues: [
|
validValues: scorm12_values.validExit,
|
||||||
'time-out',
|
invalidValues: scorm12_values.invalidExit,
|
||||||
'suspend',
|
|
||||||
'logout',
|
|
||||||
], invalidValues: [
|
|
||||||
'complete',
|
|
||||||
'exit',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -510,17 +399,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.session_time',
|
fieldName: 'cmi.core.session_time',
|
||||||
validValues: [
|
validValues: scorm12_values.validHHMMSS,
|
||||||
'10:06:57',
|
invalidValues: scorm12_values.invalidHHMMSS,
|
||||||
'00:00:01.56',
|
|
||||||
'23:59:59',
|
|
||||||
'47:59:59',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'06:5:13',
|
|
||||||
'23:59:59.123',
|
|
||||||
'P1DT23H59M59S',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -535,47 +415,20 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.raw',
|
fieldName: 'cmi.core.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.min',
|
fieldName: 'cmi.core.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.core.score.max',
|
fieldName: 'cmi.core.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -631,26 +484,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.audio',
|
fieldName: 'cmi.student_preference.audio',
|
||||||
validValues: [
|
validValues: scorm12_values.valid0To100Range.concat(['-1']),
|
||||||
'1',
|
invalidValues: scorm12_values.invalid0To100Range,
|
||||||
'-1',
|
|
||||||
'50',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.audio',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkFieldConstraintSize({
|
h.checkFieldConstraintSize({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
@@ -661,48 +496,14 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.speed',
|
fieldName: 'cmi.student_preference.speed',
|
||||||
validValues: [
|
validValues: scorm12_values.validSpeedRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidSpeedRange,
|
||||||
'-100',
|
|
||||||
'50',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.speed',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'101',
|
|
||||||
'-101',
|
|
||||||
'5000000',
|
|
||||||
'-500',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: cmi(),
|
cmi: cmi(),
|
||||||
fieldName: 'cmi.student_preference.text',
|
fieldName: 'cmi.student_preference.text',
|
||||||
validValues: [
|
validValues: scorm12_values.validIntegerScaledRange,
|
||||||
'1',
|
invalidValues: scorm12_values.invalidIntegerScaledRange,
|
||||||
'-1',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'invalid',
|
|
||||||
'a100',
|
|
||||||
],
|
|
||||||
});
|
|
||||||
h.checkValidValues({
|
|
||||||
cmi: cmi(),
|
|
||||||
fieldName: 'cmi.student_preference.text',
|
|
||||||
validValues: [],
|
|
||||||
invalidValues: [
|
|
||||||
'2',
|
|
||||||
'-2',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -727,7 +528,10 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
cmiObj.interactions.childArray.push(new CMIInteractionsObject());
|
cmiObj.interactions.childArray.push(new CMIInteractionsObject());
|
||||||
expect(
|
expect(
|
||||||
JSON.stringify(cmiObj),
|
JSON.stringify(cmiObj),
|
||||||
).to.equal('{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"","entry":"","total_time":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":""},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}}}');
|
).
|
||||||
|
to.
|
||||||
|
equal(
|
||||||
|
'{"suspend_data":"","launch_data":"","comments":"","comments_from_lms":"","core":{"student_id":"","student_name":"","lesson_location":"","credit":"","lesson_status":"","entry":"","total_time":"","lesson_mode":"normal","exit":"","session_time":"00:00:00","score":{"raw":"","min":"","max":"100"}},"objectives":{"0":{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}},"student_data":{"mastery_score":"","max_time_allowed":"","time_limit_action":""},"student_preference":{"audio":"","language":"","speed":"","text":""},"interactions":{"0":{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{},"correct_responses":{}}}}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -763,16 +567,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
fieldName: 'cmi.time',
|
fieldName: 'cmi.time',
|
||||||
validValues: [
|
validValues: scorm12_values.validTime,
|
||||||
'15:00:30',
|
invalidValues: scorm12_values.invalidTime,
|
||||||
'00:50:30',
|
|
||||||
'23:00:30',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-00:00:30',
|
|
||||||
'0:50:30',
|
|
||||||
'23:00:30.',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
@@ -783,21 +579,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
fieldName: 'cmi.type',
|
fieldName: 'cmi.type',
|
||||||
validValues: [
|
validValues: scorm12_values.validType,
|
||||||
'true-false',
|
invalidValues: scorm12_values.invalidType,
|
||||||
'choice',
|
|
||||||
'fill-in',
|
|
||||||
'matching',
|
|
||||||
'performance',
|
|
||||||
'sequencing',
|
|
||||||
'likert',
|
|
||||||
'numeric',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'correct',
|
|
||||||
'wrong',
|
|
||||||
'logout',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkReadOnly({
|
h.checkReadOnly({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
@@ -820,17 +603,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
fieldName: 'cmi.weighting',
|
fieldName: 'cmi.weighting',
|
||||||
validValues: [
|
validValues: scorm12_values.validSpeedRange,
|
||||||
'-100',
|
invalidValues: scorm12_values.invalidSpeedRange,
|
||||||
'-1',
|
|
||||||
'1',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-101',
|
|
||||||
'101',
|
|
||||||
'invalid',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
@@ -846,20 +620,12 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
fieldName: 'cmi.result',
|
fieldName: 'cmi.result',
|
||||||
validValues: [
|
validValues: scorm12_values.validResult.concat([
|
||||||
'correct',
|
|
||||||
'wrong',
|
|
||||||
'unanticipated',
|
|
||||||
'neutral',
|
|
||||||
'1',
|
'1',
|
||||||
'999',
|
'999',
|
||||||
'999.99999',
|
'999.99999',
|
||||||
],
|
]),
|
||||||
invalidValues: [
|
invalidValues: scorm12_values.invalidResult,
|
||||||
'-1',
|
|
||||||
'10000',
|
|
||||||
'invalid',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkWriteOnly({
|
h.checkWriteOnly({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
@@ -870,26 +636,21 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: interaction(),
|
cmi: interaction(),
|
||||||
fieldName: 'cmi.latency',
|
fieldName: 'cmi.latency',
|
||||||
validValues: [
|
validValues: scorm12_values.validTimestamp,
|
||||||
'10:06:57',
|
invalidValues: scorm12_values.invalidTimestamp,
|
||||||
'00:00:01.56',
|
|
||||||
'23:59:59',
|
|
||||||
'47:59:59',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'06:5:13',
|
|
||||||
'23:59:59.123',
|
|
||||||
'P1DT23H59M59S',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export JSON', () => {
|
it('should export JSON', () => {
|
||||||
const cmi = interaction();
|
const cmi = interaction();
|
||||||
cmi.objectives.childArray.push(new CMIInteractionsObjectivesObject());
|
cmi.objectives.childArray.push(new CMIInteractionsObjectivesObject());
|
||||||
cmi.correct_responses.childArray.push(new CMIInteractionsCorrectResponsesObject());
|
cmi.correct_responses.childArray.push(
|
||||||
|
new CMIInteractionsCorrectResponsesObject());
|
||||||
expect(
|
expect(
|
||||||
JSON.stringify(cmi),
|
JSON.stringify(cmi),
|
||||||
).to.equal('{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{"0":{"id":""}},"correct_responses":{"0":{"pattern":""}}}');
|
).
|
||||||
|
to.
|
||||||
|
equal(
|
||||||
|
'{"id":"","time":"","type":"","weighting":"","student_response":"","result":"","latency":"","objectives":{"0":{"id":""}},"correct_responses":{"0":{"pattern":""}}}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -955,21 +716,10 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
fieldName: 'cmi.status',
|
fieldName: 'cmi.status',
|
||||||
validValues: [
|
validValues: scorm12_values.validLessonStatus.concat([
|
||||||
'passed',
|
|
||||||
'completed',
|
|
||||||
'failed',
|
|
||||||
'incomplete',
|
|
||||||
'browsed',
|
|
||||||
'not attempted',
|
'not attempted',
|
||||||
],
|
]),
|
||||||
invalidValues: [
|
invalidValues: scorm12_values.invalidLessonStatus,
|
||||||
'P',
|
|
||||||
'f',
|
|
||||||
'complete',
|
|
||||||
'started',
|
|
||||||
'in progress',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -988,17 +738,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
fieldName: 'cmi.score.raw',
|
fieldName: 'cmi.score.raw',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkRead({
|
h.checkRead({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
@@ -1007,17 +748,8 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
fieldName: 'cmi.score.min',
|
fieldName: 'cmi.score.min',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
h.checkRead({
|
h.checkRead({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
@@ -1027,24 +759,18 @@ describe('SCORM 1.2 CMI Tests', () => {
|
|||||||
h.checkValidValues({
|
h.checkValidValues({
|
||||||
cmi: objective(),
|
cmi: objective(),
|
||||||
fieldName: 'cmi.score.max',
|
fieldName: 'cmi.score.max',
|
||||||
validValues: [
|
validValues: scorm12_values.validScoreRange,
|
||||||
'0',
|
invalidValues: scorm12_values.invalidScoreRange,
|
||||||
'25.1',
|
|
||||||
'50.5',
|
|
||||||
'75',
|
|
||||||
'100',
|
|
||||||
],
|
|
||||||
invalidValues: [
|
|
||||||
'-1',
|
|
||||||
'101',
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should export JSON', () => {
|
it('should export JSON', () => {
|
||||||
const cmi = objective();
|
const cmi = objective();
|
||||||
expect(
|
expect(
|
||||||
JSON.stringify(cmi),
|
JSON.stringify(cmi),
|
||||||
).to.equal('{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}');
|
).
|
||||||
|
to.
|
||||||
|
equal(
|
||||||
|
'{"id":"","status":"","score":{"raw":"","min":"","max":"100"}}');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {describe, it} from 'mocha';
|
import {describe, it} from 'mocha';
|
||||||
import * as Utilities from '../src/utilities';
|
import * as Utilities from '../src/utilities';
|
||||||
import {scorm12_regex, scorm2004_regex} from '../src/regex';
|
import {scorm12_regex, scorm2004_regex} from '../src/constants/regex';
|
||||||
|
|
||||||
describe('Utility Tests', () => {
|
describe('Utility Tests', () => {
|
||||||
describe('getSecondsAsHHMMSS()', () => {
|
describe('getSecondsAsHHMMSS()', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user