More tests and fixes
This commit is contained in:
@@ -10,6 +10,7 @@ import {scorm12_constants} from '../constants/api_constants';
|
||||
import {scorm12_error_codes} from '../constants/error_codes';
|
||||
import {scorm12_regex} from '../constants/regex';
|
||||
import {ValidationError} from '../exceptions';
|
||||
import * as Utilities from '../utilities';
|
||||
|
||||
const constants = scorm12_constants;
|
||||
const regex = scorm12_regex;
|
||||
@@ -244,6 +245,15 @@ export class CMI extends BaseCMI {
|
||||
this.#comments_from_lms = comments_from_lms :
|
||||
throwReadOnlyError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current session time to the existing total time.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getCurrentTotalTime() {
|
||||
return this.core.getCurrentTotalTime();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,6 +485,19 @@ class CMICore extends BaseCMI {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current session time to the existing total time.
|
||||
*
|
||||
* @return {string}
|
||||
*/
|
||||
getCurrentTotalTime() {
|
||||
return Utilities.addHHMMSSTimeStrings(
|
||||
this.#total_time,
|
||||
this.#session_time,
|
||||
new RegExp(scorm12_regex.CMITimespan)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* toJSON for cmi.core
|
||||
*
|
||||
|
||||
@@ -11,6 +11,7 @@ import {scorm2004_regex} from '../constants/regex';
|
||||
import {scorm2004_error_codes} from '../constants/error_codes';
|
||||
import {learner_responses} from '../constants/response_constants';
|
||||
import {ValidationError} from '../exceptions';
|
||||
import * as Util from '../utilities';
|
||||
|
||||
const constants = scorm2004_constants;
|
||||
const regex = scorm2004_regex;
|
||||
@@ -466,6 +467,19 @@ export class CMI extends BaseCMI {
|
||||
!this.initialized ? this.#total_time = total_time : throwReadOnlyError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current session time to the existing total time.
|
||||
*
|
||||
* @return {string} ISO8601 Duration
|
||||
*/
|
||||
getCurrentTotalTime() {
|
||||
return Util.addTwoDurations(
|
||||
this.#total_time,
|
||||
this.#session_time,
|
||||
scorm2004_regex.CMITimespan,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* toJSON for cmi
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user