Moving field values to test src

This commit is contained in:
Jonathan Putney
2020-01-09 09:36:08 -05:00
parent 8d8831954e
commit d460053cbb
10 changed files with 29 additions and 32 deletions

View File

@@ -106,6 +106,8 @@ export default class BaseAPI {
if (this.checkState(checkTerminated,
this.#error_codes.TERMINATION_BEFORE_INIT,
this.#error_codes.MULTIPLE_TERMINATION)) {
this.currentState = global_constants.STATE_TERMINATED;
const result = this.storeData(true);
if (result.errorCode && result.errorCode > 0) {
this.throwSCORMError(result.errorCode);
@@ -114,7 +116,7 @@ export default class BaseAPI {
result.result : global_constants.SCORM_FALSE;
if (checkTerminated) this.lastErrorCode = 0;
this.currentState = global_constants.STATE_TERMINATED;
returnValue = global_constants.SCORM_TRUE;
this.processListeners(callbackName);
}
@@ -906,7 +908,8 @@ export default class BaseAPI {
*/
scheduleCommit(when: number) {
this.#timeout = new ScheduledCommit(this, when);
this.apiLog('scheduleCommit', '', 'scheduled', global_constants.LOG_LEVEL_DEBUG);
this.apiLog('scheduleCommit', '', 'scheduled',
global_constants.LOG_LEVEL_DEBUG);
}
/**

View File

@@ -473,10 +473,6 @@ export default class Scorm2004API extends BaseAPI {
renderCommitCMI(terminateCommit: boolean) {
const cmiExport = this.renderCMIToJSONObject();
if (terminateCommit) {
cmiExport.cmi.total_time = this.cmi.getCurrentTotalTime();
}
const result = [];
const flattened = Utilities.flatten(cmiExport);
switch (this.settings.dataCommitFormat) {

View File

@@ -526,7 +526,7 @@ class CMICore extends BaseCMI {
'credit': this.credit,
'lesson_status': this.lesson_status,
'entry': this.entry,
'total_time': this.total_time,
'total_time': this.getCurrentTotalTime(),
'lesson_mode': this.lesson_mode,
'exit': this.exit,
'session_time': this.session_time,

View File

@@ -103,7 +103,7 @@ export class CMI extends BaseCMI {
#success_status = 'unknown';
#suspend_data = '';
#time_limit_action = 'continue,no message';
#total_time = '0';
#total_time = '';
/**
* Called when the API has been initialized after the CMI has been created
@@ -538,7 +538,7 @@ export class CMI extends BaseCMI {
'success_status': this.success_status,
'suspend_data': this.suspend_data,
'time_limit_action': this.time_limit_action,
'total_time': this.total_time,
'total_time': this.getCurrentTotalTime(),
};
delete this.jsonString;
return result;

View File

@@ -1,334 +0,0 @@
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',
],
validTimespan: [
'10:06:57',
'00:00:01.56',
'23:59:59',
'47:59:59',
],
invalidTimespan: [
'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',
],
},
};

View File

@@ -1,7 +1,5 @@
// @flow
import {scorm12_values, scorm2004_values} from './field_values';
export const scorm12_regex = {
CMIString256: '^.{0,255}$',
CMIString4096: '^.{0,4096}$',
@@ -15,11 +13,11 @@ export const scorm12_regex = {
CMIIndex: '[._](\\d+).',
// Vocabulary Data Type Definition
CMIStatus: '^(' + scorm12_values.validLessonStatus.join('|') + ')$',
CMIStatus2: '^(' + scorm12_values.validLessonStatus.join('|') + '|not attempted)$',
CMIExit: '^(' + scorm12_values.validExit.join('|') + '|)$',
CMIType: '^(' + scorm12_values.validType.join('|') + ')$',
CMIResult: '^(' + scorm12_values.validResult.join('|') + '|([0-9]{0,3})?(\\.[0-9]*)?)$', // eslint-disable-line
CMIStatus: '^(passed|completed|failed|incomplete|browsed)$',
CMIStatus2: '^(passed|completed|failed|incomplete|browsed|not attempted)$',
CMIExit: '^(time-out|suspend|logout|)$',
CMIType: '^(true-false|choice|fill-in|matching|performance|sequencing|likert|numeric)$',
CMIResult: '^(correct|wrong|unanticipated|neutral|([0-9]{0,3})?(\\.[0-9]*)?)$', // eslint-disable-line
NAVEvent: '^(previous|continue)$',
// Data ranges
@@ -60,12 +58,12 @@ export const scorm2004_regex = {
CMIIndexStore: '.N(\\d+).',
// Vocabulary Data Type Definition
CMICStatus: '^(' + scorm2004_values.validCStatus.join('|') + ')$',
CMISStatus: '^(' + scorm2004_values.validSStatus.join('|') + ')$',
CMIExit: '^(' + scorm2004_values.validExit.join('|') + ')$',
CMIType: '^(' + scorm2004_values.validType.join('|') + ')$',
CMIResult: '^(' + scorm2004_values.validResult.join('|') + '|-?([0-9]{1,4})(\\.[0-9]{1,18})?)$',
NAVEvent: '^(' + scorm2004_values.validNavRequest.join('|') + '|\{target=\\S{0,200}[a-zA-Z0-9]\}choice|jump)$', // eslint-disable-line
CMICStatus: '^(completed|incomplete|not attempted|unknown)$',
CMISStatus: '^(passed|failed|unknown)$',
CMIExit: '^(time-out|suspend|logout|normal)$',
CMIType: '^(true-false|choice|fill-in|long-fill-in|matching|performance|sequencing|likert|numeric|other)$',
CMIResult: '^(correct|wrong|unanticipated|neutral|-?([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
NAVBoolean: '^(unknown|true|false$)',
NAVTarget: '^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$',