scorm-again
Version:
A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004
1,421 lines (1,296 loc) • 287 kB
JavaScript
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 916:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
AICC: function() { return /* binding */ AICCImpl; }
});
// EXTERNAL MODULE: ./node_modules/tslib/tslib.es6.mjs
var tslib_es6 = __webpack_require__(635);
// EXTERNAL MODULE: ./src/Scorm12API.ts
var Scorm12API = __webpack_require__(941);
// EXTERNAL MODULE: ./src/cmi/scorm12/cmi.ts + 1 modules
var cmi = __webpack_require__(989);
// EXTERNAL MODULE: ./src/constants/api_constants.ts
var api_constants = __webpack_require__(340);
// EXTERNAL MODULE: ./src/cmi/common/array.ts
var array = __webpack_require__(589);
// EXTERNAL MODULE: ./src/exceptions.ts
var exceptions = __webpack_require__(784);
;// ./src/exceptions/aicc_exceptions.ts
var aicc_errors = api_constants.aicc_constants.error_descriptions;
var AICCValidationError = (function (_super) {
(0,tslib_es6.__extends)(AICCValidationError, _super);
function AICCValidationError(errorCode) {
var _this = this;
var _a, _b, _c, _d;
if ({}.hasOwnProperty.call(aicc_errors, String(errorCode))) {
_this = _super.call(this, errorCode, ((_a = aicc_errors[String(errorCode)]) === null || _a === void 0 ? void 0 : _a.basicMessage) || "Unknown rror", (_b = aicc_errors[String(errorCode)]) === null || _b === void 0 ? void 0 : _b.detailMessage) || this;
}
else {
_this = _super.call(this, 101, ((_c = aicc_errors["101"]) === null || _c === void 0 ? void 0 : _c.basicMessage) || "General error", (_d = aicc_errors["101"]) === null || _d === void 0 ? void 0 : _d.detailMessage) || this;
}
return _this;
}
return AICCValidationError;
}(exceptions.ValidationError));
// EXTERNAL MODULE: ./src/cmi/common/base_cmi.ts
var base_cmi = __webpack_require__(319);
// EXTERNAL MODULE: ./src/constants/error_codes.ts
var error_codes = __webpack_require__(797);
// EXTERNAL MODULE: ./src/cmi/common/validation.ts
var validation = __webpack_require__(449);
;// ./src/cmi/aicc/validation.ts
function checkAICCValidFormat(value, regexPattern, allowEmptyString) {
return (0,validation.checkValidFormat)(value, regexPattern, error_codes.scorm12_errors.TYPE_MISMATCH, AICCValidationError, allowEmptyString);
}
// EXTERNAL MODULE: ./src/constants/regex.ts
var regex = __webpack_require__(417);
;// ./src/cmi/aicc/evaluation.ts
var CMIEvaluation = (function (_super) {
(0,tslib_es6.__extends)(CMIEvaluation, _super);
function CMIEvaluation() {
var _this = _super.call(this) || this;
_this.comments = new CMIEvaluationComments();
return _this;
}
CMIEvaluation.prototype.initialize = function () {
var _a;
_super.prototype.initialize.call(this);
(_a = this.comments) === null || _a === void 0 ? void 0 : _a.initialize();
};
CMIEvaluation.prototype.reset = function () {
var _a;
this._initialized = false;
(_a = this.comments) === null || _a === void 0 ? void 0 : _a.reset();
};
CMIEvaluation.prototype.toJSON = function () {
this.jsonString = true;
var result = {
comments: this.comments,
};
delete this.jsonString;
return result;
};
return CMIEvaluation;
}(base_cmi.BaseCMI));
var CMIEvaluationComments = (function (_super) {
(0,tslib_es6.__extends)(CMIEvaluationComments, _super);
function CMIEvaluationComments() {
return _super.call(this, {
children: api_constants.aicc_constants.comments_children,
errorCode: error_codes.scorm12_errors.INVALID_SET_VALUE,
errorClass: AICCValidationError,
}) || this;
}
return CMIEvaluationComments;
}(array.CMIArray));
var CMIEvaluationCommentsObject = (function (_super) {
(0,tslib_es6.__extends)(CMIEvaluationCommentsObject, _super);
function CMIEvaluationCommentsObject() {
var _this = _super.call(this) || this;
_this._content = "";
_this._location = "";
_this._time = "";
return _this;
}
CMIEvaluationCommentsObject.prototype.reset = function () {
this._initialized = false;
this._content = "";
this._location = "";
this._time = "";
};
Object.defineProperty(CMIEvaluationCommentsObject.prototype, "content", {
get: function () {
return this._content;
},
set: function (content) {
if (checkAICCValidFormat(content, regex.aicc_regex.CMIString256)) {
this._content = content;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIEvaluationCommentsObject.prototype, "location", {
get: function () {
return this._location;
},
set: function (location) {
if (checkAICCValidFormat(location, regex.aicc_regex.CMIString256)) {
this._location = location;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIEvaluationCommentsObject.prototype, "time", {
get: function () {
return this._time;
},
set: function (time) {
if (checkAICCValidFormat(time, regex.aicc_regex.CMITime)) {
this._time = time;
}
},
enumerable: false,
configurable: true
});
CMIEvaluationCommentsObject.prototype.toJSON = function () {
this.jsonString = true;
var result = {
content: this.content,
location: this.location,
time: this.time,
};
delete this.jsonString;
return result;
};
return CMIEvaluationCommentsObject;
}(base_cmi.BaseCMI));
// EXTERNAL MODULE: ./src/cmi/scorm12/student_preference.ts
var student_preference = __webpack_require__(181);
;// ./src/cmi/aicc/student_preferences.ts
var AICCStudentPreferences = (function (_super) {
(0,tslib_es6.__extends)(AICCStudentPreferences, _super);
function AICCStudentPreferences() {
var _this = _super.call(this, api_constants.aicc_constants.student_preference_children) || this;
_this._lesson_type = "";
_this._text_color = "";
_this._text_location = "";
_this._text_size = "";
_this._video = "";
_this.windows = new array.CMIArray({
errorCode: error_codes.scorm12_errors.INVALID_SET_VALUE,
errorClass: AICCValidationError,
children: "",
});
return _this;
}
AICCStudentPreferences.prototype.initialize = function () {
var _a;
_super.prototype.initialize.call(this);
(_a = this.windows) === null || _a === void 0 ? void 0 : _a.initialize();
};
Object.defineProperty(AICCStudentPreferences.prototype, "lesson_type", {
get: function () {
return this._lesson_type;
},
set: function (lesson_type) {
if (checkAICCValidFormat(lesson_type, regex.aicc_regex.CMIString256)) {
this._lesson_type = lesson_type;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(AICCStudentPreferences.prototype, "text_color", {
get: function () {
return this._text_color;
},
set: function (text_color) {
if (checkAICCValidFormat(text_color, regex.aicc_regex.CMIString256)) {
this._text_color = text_color;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(AICCStudentPreferences.prototype, "text_location", {
get: function () {
return this._text_location;
},
set: function (text_location) {
if (checkAICCValidFormat(text_location, regex.aicc_regex.CMIString256)) {
this._text_location = text_location;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(AICCStudentPreferences.prototype, "text_size", {
get: function () {
return this._text_size;
},
set: function (text_size) {
if (checkAICCValidFormat(text_size, regex.aicc_regex.CMIString256)) {
this._text_size = text_size;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(AICCStudentPreferences.prototype, "video", {
get: function () {
return this._video;
},
set: function (video) {
if (checkAICCValidFormat(video, regex.aicc_regex.CMIString256)) {
this._video = video;
}
},
enumerable: false,
configurable: true
});
AICCStudentPreferences.prototype.toJSON = function () {
this.jsonString = true;
var result = {
audio: this.audio,
language: this.language,
lesson_type: this.lesson_type,
speed: this.speed,
text: this.text,
text_color: this.text_color,
text_location: this.text_location,
text_size: this.text_size,
video: this.video,
windows: this.windows,
};
delete this.jsonString;
return result;
};
return AICCStudentPreferences;
}(student_preference.CMIStudentPreference));
;// ./src/cmi/aicc/student_demographics.ts
var CMIStudentDemographics = (function (_super) {
(0,tslib_es6.__extends)(CMIStudentDemographics, _super);
function CMIStudentDemographics() {
var _this = _super.call(this) || this;
_this.__children = api_constants.aicc_constants.student_demographics_children;
_this._city = "";
_this._class = "";
_this._company = "";
_this._country = "";
_this._experience = "";
_this._familiar_name = "";
_this._instructor_name = "";
_this._title = "";
_this._native_language = "";
_this._state = "";
_this._street_address = "";
_this._telephone = "";
_this._years_experience = "";
return _this;
}
CMIStudentDemographics.prototype.reset = function () {
this._initialized = false;
};
Object.defineProperty(CMIStudentDemographics.prototype, "_children", {
get: function () {
return this.__children;
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "city", {
get: function () {
return this._city;
},
set: function (city) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._city = city;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "class", {
get: function () {
return this._class;
},
set: function (clazz) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._class = clazz;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "company", {
get: function () {
return this._company;
},
set: function (company) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._company = company;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "country", {
get: function () {
return this._country;
},
set: function (country) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._country = country;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "experience", {
get: function () {
return this._experience;
},
set: function (experience) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._experience = experience;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "familiar_name", {
get: function () {
return this._familiar_name;
},
set: function (familiar_name) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._familiar_name = familiar_name;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "instructor_name", {
get: function () {
return this._instructor_name;
},
set: function (instructor_name) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._instructor_name = instructor_name;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "title", {
get: function () {
return this._title;
},
set: function (title) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._title = title;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "native_language", {
get: function () {
return this._native_language;
},
set: function (native_language) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._native_language = native_language;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "state", {
get: function () {
return this._state;
},
set: function (state) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._state = state;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "street_address", {
get: function () {
return this._street_address;
},
set: function (street_address) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._street_address = street_address;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "telephone", {
get: function () {
return this._telephone;
},
set: function (telephone) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._telephone = telephone;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIStudentDemographics.prototype, "years_experience", {
get: function () {
return this._years_experience;
},
set: function (years_experience) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._years_experience = years_experience;
}
},
enumerable: false,
configurable: true
});
CMIStudentDemographics.prototype.toJSON = function () {
this.jsonString = true;
var result = {
city: this.city,
class: this.class,
company: this.company,
country: this.country,
experience: this.experience,
familiar_name: this.familiar_name,
instructor_name: this.instructor_name,
title: this.title,
native_language: this.native_language,
state: this.state,
street_address: this.street_address,
telephone: this.telephone,
years_experience: this.years_experience,
};
delete this.jsonString;
return result;
};
return CMIStudentDemographics;
}(base_cmi.BaseCMI));
// EXTERNAL MODULE: ./src/cmi/common/score.ts
var score = __webpack_require__(434);
;// ./src/cmi/aicc/tries.ts
var CMITries = (function (_super) {
(0,tslib_es6.__extends)(CMITries, _super);
function CMITries() {
return _super.call(this, {
children: api_constants.aicc_constants.tries_children,
}) || this;
}
return CMITries;
}(array.CMIArray));
var CMITriesObject = (function (_super) {
(0,tslib_es6.__extends)(CMITriesObject, _super);
function CMITriesObject() {
var _this = _super.call(this) || this;
_this._status = "";
_this._time = "";
_this.score = new score.CMIScore({
score_children: api_constants.aicc_constants.score_children,
score_range: regex.aicc_regex.score_range,
invalidErrorCode: error_codes.scorm12_errors.INVALID_SET_VALUE,
invalidTypeCode: error_codes.scorm12_errors.TYPE_MISMATCH,
invalidRangeCode: error_codes.scorm12_errors.VALUE_OUT_OF_RANGE,
errorClass: AICCValidationError,
});
return _this;
}
CMITriesObject.prototype.initialize = function () {
var _a;
_super.prototype.initialize.call(this);
(_a = this.score) === null || _a === void 0 ? void 0 : _a.initialize();
};
CMITriesObject.prototype.reset = function () {
var _a;
this._initialized = false;
this._status = "";
this._time = "";
(_a = this.score) === null || _a === void 0 ? void 0 : _a.reset();
};
Object.defineProperty(CMITriesObject.prototype, "status", {
get: function () {
return this._status;
},
set: function (status) {
if (checkAICCValidFormat(status, regex.aicc_regex.CMIStatus2)) {
this._status = status;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMITriesObject.prototype, "time", {
get: function () {
return this._time;
},
set: function (time) {
if (checkAICCValidFormat(time, regex.aicc_regex.CMITime)) {
this._time = time;
}
},
enumerable: false,
configurable: true
});
CMITriesObject.prototype.toJSON = function () {
this.jsonString = true;
var result = {
status: this.status,
time: this.time,
score: this.score,
};
delete this.jsonString;
return result;
};
return CMITriesObject;
}(base_cmi.BaseCMI));
// EXTERNAL MODULE: ./src/cmi/scorm12/student_data.ts
var student_data = __webpack_require__(532);
;// ./src/cmi/aicc/attempts.ts
var CMIAttemptRecords = (function (_super) {
(0,tslib_es6.__extends)(CMIAttemptRecords, _super);
function CMIAttemptRecords() {
return _super.call(this, {
children: api_constants.aicc_constants.attempt_records_children,
}) || this;
}
return CMIAttemptRecords;
}(array.CMIArray));
var CMIAttemptRecordsObject = (function (_super) {
(0,tslib_es6.__extends)(CMIAttemptRecordsObject, _super);
function CMIAttemptRecordsObject() {
var _this = _super.call(this) || this;
_this._lesson_status = "";
_this.score = new score.CMIScore({
score_children: api_constants.aicc_constants.score_children,
score_range: regex.aicc_regex.score_range,
invalidErrorCode: error_codes.scorm12_errors.INVALID_SET_VALUE,
invalidTypeCode: error_codes.scorm12_errors.TYPE_MISMATCH,
invalidRangeCode: error_codes.scorm12_errors.VALUE_OUT_OF_RANGE,
errorClass: AICCValidationError,
});
return _this;
}
CMIAttemptRecordsObject.prototype.initialize = function () {
var _a;
_super.prototype.initialize.call(this);
this._lesson_status = "";
(_a = this.score) === null || _a === void 0 ? void 0 : _a.initialize();
};
CMIAttemptRecordsObject.prototype.reset = function () {
var _a;
this._initialized = false;
(_a = this.score) === null || _a === void 0 ? void 0 : _a.reset();
};
Object.defineProperty(CMIAttemptRecordsObject.prototype, "lesson_status", {
get: function () {
return this._lesson_status;
},
set: function (lesson_status) {
if (checkAICCValidFormat(lesson_status, regex.aicc_regex.CMIStatus2)) {
this._lesson_status = lesson_status;
}
},
enumerable: false,
configurable: true
});
CMIAttemptRecordsObject.prototype.toJSON = function () {
this.jsonString = true;
var result = {
lesson_status: this.lesson_status,
score: this.score,
};
delete this.jsonString;
return result;
};
return CMIAttemptRecordsObject;
}(base_cmi.BaseCMI));
;// ./src/cmi/aicc/student_data.ts
var AICCCMIStudentData = (function (_super) {
(0,tslib_es6.__extends)(AICCCMIStudentData, _super);
function AICCCMIStudentData() {
var _this = _super.call(this, api_constants.aicc_constants.student_data_children) || this;
_this._tries_during_lesson = "";
_this.tries = new CMITries();
_this.attempt_records = new CMIAttemptRecords();
return _this;
}
AICCCMIStudentData.prototype.initialize = function () {
var _a, _b;
_super.prototype.initialize.call(this);
(_a = this.tries) === null || _a === void 0 ? void 0 : _a.initialize();
(_b = this.attempt_records) === null || _b === void 0 ? void 0 : _b.initialize();
};
AICCCMIStudentData.prototype.reset = function () {
var _a, _b;
this._initialized = false;
(_a = this.tries) === null || _a === void 0 ? void 0 : _a.reset(true);
(_b = this.attempt_records) === null || _b === void 0 ? void 0 : _b.reset(true);
};
Object.defineProperty(AICCCMIStudentData.prototype, "tries_during_lesson", {
get: function () {
return this._tries_during_lesson;
},
set: function (tries_during_lesson) {
if (this.initialized) {
throw new AICCValidationError(error_codes.scorm12_errors.READ_ONLY_ELEMENT);
}
else {
this._tries_during_lesson = tries_during_lesson;
}
},
enumerable: false,
configurable: true
});
AICCCMIStudentData.prototype.toJSON = function () {
this.jsonString = true;
var result = {
mastery_score: this.mastery_score,
max_time_allowed: this.max_time_allowed,
time_limit_action: this.time_limit_action,
tries: this.tries,
attempt_records: this.attempt_records,
};
delete this.jsonString;
return result;
};
return AICCCMIStudentData;
}(student_data.CMIStudentData));
;// ./src/cmi/aicc/paths.ts
var CMIPaths = (function (_super) {
(0,tslib_es6.__extends)(CMIPaths, _super);
function CMIPaths() {
return _super.call(this, {
children: api_constants.aicc_constants.paths_children,
}) || this;
}
return CMIPaths;
}(array.CMIArray));
var CMIPathsObject = (function (_super) {
(0,tslib_es6.__extends)(CMIPathsObject, _super);
function CMIPathsObject() {
var _this = _super.call(this) || this;
_this._location_id = "";
_this._date = "";
_this._time = "";
_this._status = "";
_this._why_left = "";
_this._time_in_element = "";
return _this;
}
CMIPathsObject.prototype.reset = function () {
this._initialized = false;
this._location_id = "";
this._date = "";
this._time = "";
this._status = "";
this._why_left = "";
this._time_in_element = "";
};
Object.defineProperty(CMIPathsObject.prototype, "location_id", {
get: function () {
return this._location_id;
},
set: function (location_id) {
if (checkAICCValidFormat(location_id, regex.aicc_regex.CMIString256)) {
this._location_id = location_id;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIPathsObject.prototype, "date", {
get: function () {
return this._date;
},
set: function (date) {
if (checkAICCValidFormat(date, regex.aicc_regex.CMIString256)) {
this._date = date;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIPathsObject.prototype, "time", {
get: function () {
return this._time;
},
set: function (time) {
if (checkAICCValidFormat(time, regex.aicc_regex.CMITime)) {
this._time = time;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIPathsObject.prototype, "status", {
get: function () {
return this._status;
},
set: function (status) {
if (checkAICCValidFormat(status, regex.aicc_regex.CMIStatus2)) {
this._status = status;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIPathsObject.prototype, "why_left", {
get: function () {
return this._why_left;
},
set: function (why_left) {
if (checkAICCValidFormat(why_left, regex.aicc_regex.CMIString256)) {
this._why_left = why_left;
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(CMIPathsObject.prototype, "time_in_element", {
get: function () {
return this._time_in_element;
},
set: function (time_in_element) {
if (checkAICCValidFormat(time_in_element, regex.aicc_regex.CMITime)) {
this._time_in_element = time_in_element;
}
},
enumerable: false,
configurable: true
});
CMIPathsObject.prototype.toJSON = function () {
this.jsonString = true;
var result = {
location_id: this.location_id,
date: this.date,
time: this.time,
status: this.status,
why_left: this.why_left,
time_in_element: this.time_in_element,
};
delete this.jsonString;
return result;
};
return CMIPathsObject;
}(base_cmi.BaseCMI));
;// ./src/cmi/aicc/cmi.ts
var CMI = (function (_super) {
(0,tslib_es6.__extends)(CMI, _super);
function CMI(initialized) {
if (initialized === void 0) { initialized = false; }
var _this = _super.call(this, api_constants.aicc_constants.cmi_children) || this;
if (initialized)
_this.initialize();
_this.student_preference = new AICCStudentPreferences();
_this.student_data = new AICCCMIStudentData();
_this.student_demographics = new CMIStudentDemographics();
_this.evaluation = new CMIEvaluation();
_this.paths = new CMIPaths();
return _this;
}
CMI.prototype.initialize = function () {
var _a, _b, _c, _d, _e;
_super.prototype.initialize.call(this);
(_a = this.student_preference) === null || _a === void 0 ? void 0 : _a.initialize();
(_b = this.student_data) === null || _b === void 0 ? void 0 : _b.initialize();
(_c = this.student_demographics) === null || _c === void 0 ? void 0 : _c.initialize();
(_d = this.evaluation) === null || _d === void 0 ? void 0 : _d.initialize();
(_e = this.paths) === null || _e === void 0 ? void 0 : _e.initialize();
};
CMI.prototype.toJSON = function () {
this.jsonString = true;
var result = {
suspend_data: this.suspend_data,
launch_data: this.launch_data,
comments: this.comments,
comments_from_lms: this.comments_from_lms,
core: this.core,
objectives: this.objectives,
student_data: this.student_data,
student_preference: this.student_preference,
student_demographics: this.student_demographics,
interactions: this.interactions,
evaluation: this.evaluation,
paths: this.paths,
};
delete this.jsonString;
return result;
};
return CMI;
}(cmi.CMI));
// EXTERNAL MODULE: ./src/cmi/scorm12/nav.ts
var nav = __webpack_require__(331);
// EXTERNAL MODULE: ./src/utilities.ts
var utilities = __webpack_require__(864);
;// ./src/AICC.ts
var AICCImpl = (function (_super) {
(0,tslib_es6.__extends)(AICCImpl, _super);
function AICCImpl(settings) {
var _this = _super.call(this, settings) || this;
_this.cmi = new CMI();
_this.nav = new nav.NAV();
return _this;
}
AICCImpl.prototype.getChildElement = function (CMIElement, value, foundFirstIndex) {
var newChild = _super.prototype.getChildElement.call(this, CMIElement, value, foundFirstIndex);
if (!newChild) {
if ((0,utilities.stringMatches)(CMIElement, "cmi\\.evaluation\\.comments\\.\\d+")) {
newChild = new CMIEvaluationCommentsObject();
}
else if ((0,utilities.stringMatches)(CMIElement, "cmi\\.student_data\\.tries\\.\\d+")) {
newChild = new CMITriesObject();
}
else if ((0,utilities.stringMatches)(CMIElement, "cmi\\.student_data\\.attempt_records\\.\\d+")) {
newChild = new CMIAttemptRecordsObject();
}
else if ((0,utilities.stringMatches)(CMIElement, "cmi\\.paths\\.\\d+")) {
newChild = new CMIPathsObject();
}
}
return newChild;
};
AICCImpl.prototype.replaceWithAnotherScormAPI = function (newAPI) {
this.cmi = newAPI.cmi;
this.nav = newAPI.nav;
};
return AICCImpl;
}(Scorm12API.Scorm12API));
/***/ }),
/***/ 429:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
"default": function() { return /* binding */ src_BaseAPI; }
});
// EXTERNAL MODULE: ./node_modules/tslib/tslib.es6.mjs
var tslib_es6 = __webpack_require__(635);
// EXTERNAL MODULE: ./src/cmi/common/array.ts
var array = __webpack_require__(589);
// EXTERNAL MODULE: ./src/exceptions.ts
var exceptions = __webpack_require__(784);
// EXTERNAL MODULE: ./src/constants/api_constants.ts
var api_constants = __webpack_require__(340);
// EXTERNAL MODULE: ./src/utilities.ts
var utilities = __webpack_require__(864);
// EXTERNAL MODULE: ./src/constants/enums.ts
var enums = __webpack_require__(56);
;// ./src/constants/default_settings.ts
var DefaultSettings = {
autocommit: false,
autocommitSeconds: 10,
asyncCommit: false,
sendFullCommit: true,
lmsCommitUrl: false,
dataCommitFormat: "json",
commitRequestDataType: "application/json;charset=UTF-8",
autoProgress: false,
logLevel: enums.LogLevelEnum.ERROR,
selfReportSessionTime: false,
alwaysSendTotalTime: false,
renderCommonCommitFields: false,
strict_errors: true,
xhrHeaders: {},
xhrWithCredentials: false,
fetchMode: "cors",
responseHandler: function (response) {
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
var responseText, httpResult;
return (0,tslib_es6.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
if (!(typeof response !== "undefined")) return [3, 2];
return [4, response.text()];
case 1:
responseText = _a.sent();
httpResult = null;
if (responseText) {
httpResult = JSON.parse(responseText);
}
if (httpResult === null ||
!{}.hasOwnProperty.call(httpResult, "result")) {
if (response.status === 200) {
return [2, {
result: api_constants.global_constants.SCORM_TRUE,
errorCode: 0
}];
}
else {
return [2, {
result: api_constants.global_constants.SCORM_FALSE,
errorCode: 101
}];
}
}
else {
return [2, {
result: httpResult.result,
errorCode: httpResult.errorCode
? httpResult.errorCode
: httpResult.result === api_constants.global_constants.SCORM_TRUE
? 0
: 101
}];
}
_a.label = 2;
case 2: return [2, {
result: api_constants.global_constants.SCORM_FALSE,
errorCode: 101
}];
}
});
});
},
requestHandler: function (commitObject) {
return commitObject;
},
onLogMessage: function (messageLevel, logMessage) {
switch (messageLevel) {
case "4":
case 4:
case "ERROR":
case enums.LogLevelEnum.ERROR:
console.error(logMessage);
break;
case "3":
case 3:
case "WARN":
case enums.LogLevelEnum.WARN:
console.warn(logMessage);
break;
case "2":
case 2:
case "INFO":
case enums.LogLevelEnum.INFO:
console.info(logMessage);
break;
case "1":
case 1:
case "DEBUG":
case enums.LogLevelEnum.DEBUG:
if (console.debug) {
console.debug(logMessage);
}
else {
console.log(logMessage);
}
break;
}
},
scoItemIds: [],
scoItemIdValidator: false,
globalObjectiveIds: []
};
;// ./src/helpers/scheduled_commit.ts
var ScheduledCommit = (function () {
function ScheduledCommit(API, when, callback) {
this._cancelled = false;
this._API = API;
this._timeout = setTimeout(this.wrapper.bind(this), when);
this._callback = callback;
}
ScheduledCommit.prototype.cancel = function () {
this._cancelled = true;
if (this._timeout) {
clearTimeout(this._timeout);
}
};
ScheduledCommit.prototype.wrapper = function () {
var _this = this;
if (!this._cancelled) {
(function () { return (0,tslib_es6.__awaiter)(_this, void 0, void 0, function () { return (0,tslib_es6.__generator)(this, function (_a) {
switch (_a.label) {
case 0: return [4, this._API.commit(this._callback)];
case 1: return [2, _a.sent()];
}
}); }); })();
}
};
return ScheduledCommit;
}());
;// ./src/BaseAPI.ts
var BaseAPI = (function () {
function BaseAPI(error_codes, settings) {
var _newTarget = this.constructor;
var _a, _c;
this._settings = DefaultSettings;
if (_newTarget === BaseAPI) {
throw new TypeError("Cannot construct BaseAPI instances directly");
}
this.currentState = api_constants.global_constants.STATE_NOT_INITIALIZED;
this.lastErrorCode = "0";
this.listenerArray = [];
this._error_codes = error_codes;
if (settings) {
this.settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, DefaultSettings), settings);
}
this.apiLogLevel = (_a = this.settings.logLevel) !== null && _a !== void 0 ? _a : enums.LogLevelEnum.ERROR;
this.selfReportSessionTime = (_c = this.settings.selfReportSessionTime) !== null && _c !== void 0 ? _c : false;
}
BaseAPI.prototype.commonReset = function (settings) {
this.apiLog("reset", "Called", enums.LogLevelEnum.INFO);
this.settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this.settings), settings);
this.clearScheduledCommit();
this.currentState = api_constants.global_constants.STATE_NOT_INITIALIZED;
this.lastErrorCode = "0";
this.listenerArray = [];
this.startingData = {};
};
BaseAPI.prototype.initialize = function (callbackName, initializeMessage, terminationMessage) {
var returnValue = api_constants.global_constants.SCORM_FALSE;
if (this.isInitialized()) {
this.throwSCORMError(this._error_codes.INITIALIZED, initializeMessage);
}
else if (this.isTerminated()) {
this.throwSCORMError(this._error_codes.TERMINATED, terminationMessage);
}
else {
if (this.selfReportSessionTime) {
this.cmi.setStartTime();
}
this.currentState = api_constants.global_constants.STATE_INITIALIZED;
this.lastErrorCode = "0";
returnValue = api_constants.global_constants.SCORM_TRUE;
this.processListeners(callbackName);
}
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
this.clearSCORMError(returnValue);
return returnValue;
};
BaseAPI.prototype.apiLog = function (functionName, logMessage, messageLevel, CMIElement) {
logMessage = (0,utilities.formatMessage)(functionName, logMessage, CMIElement);
if (messageLevel >= this.apiLogLevel) {
this.settings.onLogMessage(messageLevel, logMessage);
}
};
Object.defineProperty(BaseAPI.prototype, "error_codes", {
get: function () {
return this._error_codes;
},
enumerable: false,
configurable: true
});
Object.defineProperty(BaseAPI.prototype, "settings", {
get: function () {
return this._settings;
},
set: function (settings) {
this._settings = (0,tslib_es6.__assign)((0,tslib_es6.__assign)({}, this._settings), settings);
},
enumerable: false,
configurable: true
});
BaseAPI.prototype.terminate = function (callbackName, checkTerminated) {
return (0,tslib_es6.__awaiter)(this, void 0, void 0, function () {
var returnValue, result;
return (0,tslib_es6.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
returnValue = api_constants.global_constants.SCORM_FALSE;
if (!this.checkState(checkTerminated, this._error_codes.TERMINATION_BEFORE_INIT, this._error_codes.MULTIPLE_TERMINATION)) return [3, 2];
this.currentState = api_constants.global_constants.STATE_TERMINATED;
return [4, this.storeData(true)];
case 1:
result = _a.sent();
if (typeof result.errorCode !== "undefined" && result.errorCode > 0) {
this.throwSCORMError(result.errorCode);
}
returnValue =
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
? api_constants.global_constants.SCORM_TRUE
: api_constants.global_constants.SCORM_FALSE;
if (checkTerminated)
this.lastErrorCode = "0";
returnValue = api_constants.global_constants.SCORM_TRUE;
this.processListeners(callbackName);
_a.label = 2;
case 2:
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
this.clearSCORMError(returnValue);
return [2, returnValue];
}
});
});
};
BaseAPI.prototype.getValue = function (callbackName, checkTerminated, CMIElement) {
var returnValue = "";
if (this.checkState(checkTerminated, this._error_codes.RETRIEVE_BEFORE_INIT, this._error_codes.RETRIEVE_AFTER_TERM)) {
if (checkTerminated)
this.lastErrorCode = "0";
try {
returnValue = this.getCMIValue(CMIElement);
}
catch (e) {
returnValue = this.handleValueAccessException(e, returnValue);
}
this.processListeners(callbackName, CMIElement);
}
this.apiLog(callbackName, ": returned: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
if (returnValue === undefined) {
return "";
}
this.clearSCORMError(returnValue);
return returnValue;
};
BaseAPI.prototype.setValue = function (callbackName, commitCallback, checkTerminated, CMIElement, value) {
if (value !== undefined) {
value = String(value);
}
var returnValue = api_constants.global_constants.SCORM_FALSE;
if (this.checkState(checkTerminated, this._error_codes.STORE_BEFORE_INIT, this._error_codes.STORE_AFTER_TERM)) {
if (checkTerminated)
this.lastErrorCode = "0";
try {
returnValue = this.setCMIValue(CMIElement, value);
}
catch (e) {
this.handleValueAccessException(e, returnValue);
}
this.processListeners(callbackName, CMIElement, value);
}
if (returnValue === undefined) {
returnValue = api_constants.global_constants.SCORM_FALSE;
}
if (String(this.lastErrorCode) === "0") {
if (this.settings.autocommit) {
this.scheduleCommit(this.settings.autocommitSeconds * 1000, commitCallback);
}
}
this.apiLog(callbackName, ": " + value + ": result: " + returnValue, enums.LogLevelEnum.INFO, CMIElement);
this.clearSCORMError(returnValue);
return returnValue;
};
BaseAPI.prototype.commit = function (callbackName_1) {
return (0,tslib_es6.__awaiter)(this, arguments, void 0, function (callbackName, checkTerminated) {
var returnValue, result;
if (checkTerminated === void 0) { checkTerminated = false; }
return (0,tslib_es6.__generator)(this, function (_a) {
switch (_a.label) {
case 0:
this.clearScheduledCommit();
returnValue = api_constants.global_constants.SCORM_FALSE;
if (!this.checkState(checkTerminated, this._error_codes.COMMIT_BEFORE_INIT, this._error_codes.COMMIT_AFTER_TERM)) return [3, 2];
return [4, this.storeData(false)];
case 1:
result = _a.sent();
if (result.errorCode && result.errorCode > 0) {
this.throwSCORMError(result.errorCode);
}
returnValue =
typeof result !== "undefined" && (result.result === true || result.result === api_constants.global_constants.SCORM_TRUE)
? api_constants.global_constants.SCORM_TRUE
: api_constants.global_constants.SCORM_FALSE;
this.apiLog(callbackName, " Result: " + returnValue, enums.LogLevelEnum.DEBUG, "HttpRequest");
if (checkTerminated)
this.lastErrorCode = "0";
this.processListeners(callbackName);
_a.label = 2;
case 2:
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
this.clearSCORMError(returnValue);
return [2, returnValue];
}
});
});
};
BaseAPI.prototype.getLastError = function (callbackName) {
var returnValue = String(this.lastErrorCode);
this.processListeners(callbackName);
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
return returnValue;
};
BaseAPI.prototype.getErrorString = function (callbackName, CMIErrorCode) {
var returnValue = "";
if (CMIErrorCode !== null && CMIErrorCode !== "") {
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode);
this.processListeners(callbackName);
}
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
return returnValue;
};
BaseAPI.prototype.getDiagnostic = function (callbackName, CMIErrorCode) {
var returnValue = "";
if (CMIErrorCode !== null && CMIErrorCode !== "") {
returnValue = this.getLmsErrorMessageDetails(CMIErrorCode, true);
this.processListeners(callbackName);
}
this.apiLog(callbackName, "returned: " + returnValue, enums.LogLevelEnum.INFO);
return returnValue;
};
BaseAPI.prototype.checkState = function (checkTerminated, beforeInitError, afterTermError) {
if (this.isNotInitialized()) {
this.throwSCORMError(beforeInitError);
return false;
}
else if (checkTerminated && this.isTerminated()) {
this.throwSCORMError(afterTermError);
return false;
}
return true;
};
BaseAPI.prototype.getLmsErrorMessageDetails = function (_errorNumber, _detail) {
if (_detail === void 0) { _detail = false; }
throw new Error("The getLmsErrorMessageDetails method has not been implemented");
};
BaseAPI.prototype.getCMIValue = function (_CMIElement) {
throw new Error("The getCMIValue method has not been implemented");
};
BaseAPI.prototype.setCMIValue = function (_CMIElement, _value) {
throw new Error("The setCMIValue method has not been implemented");
};
BaseAPI.prototype._commonSetCMIValue = function (methodName, scorm2004, CMIElement, value) {
if (!CMIElement || CMIElement === "") {
return api_constants.global_constants.SCORM_FALSE;
}
var structure = CMIElement.split(".");
var refObject = this;
var returnValue = api_constants.global_constants.SCORM_FALSE;
var foundFirstIndex = false;
var invalidErrorMessage = "The data model element passed to ".concat(methodName, " (").concat(CMIElement, ") is not a valid SCORM data model element.");
var invalidErrorCode = scorm2004
? this._error_codes.UNDEFINED_DATA_MODEL
: this._error_codes.GENERAL;
for (var idx = 0; idx < structure.length; idx++) {
var attribute = structure[idx];
if (!attribute) {
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
return api_constants.global_constants.SCORM_FALSE;
}
if (idx === structure.length - 1) {