scorm-again 1.5.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +4 -9
- package/.run/Mocha Unit Tests.run.xml +14 -0
- package/.run/compile.run.xml +12 -0
- package/README.md +12 -3
- package/dist/aicc.js +7362 -0
- package/dist/aicc.js.map +1 -0
- package/dist/aicc.min.js +40 -0
- package/dist/scorm-again.js +1353 -1006
- package/dist/scorm-again.js.map +1 -1
- package/dist/scorm-again.min.js +52 -41
- package/dist/scorm12.js +5610 -0
- package/dist/scorm12.js.map +1 -0
- package/dist/scorm12.min.js +34 -0
- package/dist/scorm2004.js +7011 -0
- package/dist/scorm2004.js.map +1 -0
- package/dist/scorm2004.min.js +40 -0
- package/package.json +36 -28
- package/src/BaseAPI.js +71 -39
- package/src/Scorm12API.js +8 -15
- package/src/Scorm2004API.js +5 -8
- package/src/cmi/aicc_cmi.js +73 -35
- package/src/cmi/common.js +27 -21
- package/src/cmi/scorm12_cmi.js +24 -8
- package/src/cmi/scorm2004_cmi.js +67 -47
- package/src/constants/api_constants.js +8 -0
- package/src/constants/response_constants.js +2 -2
- package/src/exceptions.js +77 -6
- package/src/exports/aicc.js +3 -0
- package/src/exports/scorm-again.js +7 -0
- package/src/exports/scorm12.js +3 -0
- package/src/exports/scorm2004.js +3 -0
- package/test/Scorm2004API.spec.js +37 -7
- package/test/api_helpers.js +4 -4
- package/test/cmi_helpers.js +3 -3
- package/test/exceptions.spec.js +59 -4
- package/webpack.js +78 -0
- package/gruntfile.js +0 -87
- package/src/exports.js +0 -7
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
!function(){var r={"./node_modules/lodash.debounce/index.js":
|
|
2
|
+
/*!***********************************************!*\
|
|
3
|
+
!*** ./node_modules/lodash.debounce/index.js ***!
|
|
4
|
+
\***********************************************/function(e,s,t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function v(){return f.Date.now()}var n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt,t="object"==(void 0===t.g?"undefined":r(t.g))&&t.g&&t.g.Object===Object&&t.g,h="object"==("undefined"==typeof self?"undefined":r(self))&&self&&self.Object===Object&&self,f=t||h||Function("return this")(),d=Object.prototype.toString,b=Math.max,M=Math.min;function E(e){var t=r(e);return e&&("object"==t||"function"==t)}function m(e){return"symbol"==r(e)||!!(t=e)&&"object"==r(t)&&d.call(e)==i;var t}function _(e){if("number"==typeof e)return e;if(m(e))return n;if("string"!=typeof(e=E(e)?E(t="function"==typeof e.valueOf?e.valueOf():e)?t+"":t:e))return 0===e?e:+e;e=e.replace(o,"");var t=l.test(e);return t||c.test(e)?u(e.slice(2),t?2:8):a.test(e)?n:+e}e.exports=function(h,r,e){var n,i,o,a,s,l,c=0,f=!1,u=!1,t=!0;if("function"!=typeof h)throw new TypeError("Expected a function");function d(e){var t=n,r=i;return n=i=void 0,c=e,a=h.apply(r,t)}function m(e){var t=e-l;return void 0===l||r<=t||t<0||u&&o<=e-c}function p(){var e,t=v();if(m(t))return g(t);s=setTimeout(p,(e=r-((t=t)-l),u?M(e,o-(t-c)):e))}function g(e){return s=void 0,t&&n?d(e):(n=i=void 0,a)}function y(){var e=v(),t=m(e);if(n=arguments,i=this,l=e,t){if(void 0===s)return c=e=l,s=setTimeout(p,r),f?d(e):a;if(u)return s=setTimeout(p,r),d(l)}return void 0===s&&(s=setTimeout(p,r)),a}return r=_(r)||0,E(e)&&(f=!!e.leading,u="maxWait"in e,o=u?b(_(e.maxWait)||0,r):o,t="trailing"in e?!!e.trailing:t),y.cancel=function(){void 0!==s&&clearTimeout(s),n=l=i=s=void(c=0)},y.flush=function(){return void 0===s?a:g(v())},y}},"./src/BaseAPI.js":
|
|
5
|
+
/*!************************!*\
|
|
6
|
+
!*** ./src/BaseAPI.js ***!
|
|
7
|
+
\************************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return T}});var p=t(/*! ./cmi/common */"./src/cmi/common.js"),l=t(/*! ./exceptions */"./src/exceptions.js"),e=t(/*! ./constants/error_codes */"./src/constants/error_codes.js"),c=t(/*! ./constants/api_constants */"./src/constants/api_constants.js"),u=t(/*! ./utilities */"./src/utilities.js"),h=t(/*! lodash.debounce */"./node_modules/lodash.debounce/index.js"),g=t.n(h);function y(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return v(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function E(e){return(E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function b(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?_(Object(r),!0).forEach(function(e){I(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function M(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function S(e,t,r){return t&&w(e.prototype,t),r&&w(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function I(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function i(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function f(e,t){t=O(e,t,"get");return t.get?t.get.call(e):t.value}function o(e,t,r){var t=O(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function O(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var d=c.default.global,C=e.default.scorm12,a=new WeakMap,m=new WeakMap,n=new WeakMap,T=function(){function r(e,t){if(M(this,r),i(this,a,{writable:!0,value:void 0}),i(this,m,{writable:!0,value:void 0}),i(this,n,{writable:!0,value:{autocommit:!1,autocommitSeconds:10,asyncCommit:!1,sendBeaconCommit:!1,lmsCommitUrl:!1,dataCommitFormat:"json",commitRequestDataType:"application/json;charset=UTF-8",autoProgress:!1,logLevel:d.LOG_LEVEL_ERROR,selfReportSessionTime:!1,alwaysSendTotalTime:!1,strict_errors:!0,xhrHeaders:{},xhrWithCredentials:!1,responseHandler:function(e){var t;return void 0!==e&&(null!==(t=JSON.parse(e.responseText))&&{}.hasOwnProperty.call(t,"result")||(t={},200===e.status?(t.result=d.SCORM_TRUE,t.errorCode=0):(t.result=d.SCORM_FALSE,t.errorCode=101))),t},requestHandler:function(e){return e},onLogMessage:function(e,t){switch(e){case d.LOG_LEVEL_ERROR:console.error(t);break;case d.LOG_LEVEL_WARNING:console.warn(t);break;case d.LOG_LEVEL_INFO:console.info(t);break;case d.LOG_LEVEL_DEBUG:console.debug?console.debug(t):console.log(t)}}}}),I(this,"cmi",void 0),I(this,"startingData",void 0),(this instanceof r?this.constructor:void 0)===r)throw new TypeError("Cannot construct BaseAPI instances directly");this.currentState=d.STATE_NOT_INITIALIZED,this.lastErrorCode=0,this.listenerArray=[],o(this,a,null),o(this,m,e),this.settings=t,this.apiLogLevel=this.settings.logLevel,this.selfReportSessionTime=this.settings.selfReportSessionTime}return S(r,[{key:"initialize",value:function(e,t,r){var n=d.SCORM_FALSE;return this.isInitialized()?this.throwSCORMError(f(this,m).INITIALIZED,t):this.isTerminated()?this.throwSCORMError(f(this,m).TERMINATED,r):(this.selfReportSessionTime&&this.cmi.setStartTime(),this.currentState=d.STATE_INITIALIZED,this.lastErrorCode=0,n=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"error_codes",get:function(){return f(this,m)}},{key:"settings",get:function(){return f(this,n)},set:function(e){o(this,n,b(b({},f(this,n)),e))}},{key:"terminate",value:function(e,t){var r,n=d.SCORM_FALSE;return this.checkState(t,f(this,m).TERMINATION_BEFORE_INIT,f(this,m).MULTIPLE_TERMINATION)&&(this.currentState=d.STATE_TERMINATED,r=this.storeData(!0),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&void 0!==r.errorCode&&0<r.errorCode&&this.throwSCORMError(r.errorCode),n=void 0!==r&&r.result?r.result:d.SCORM_FALSE,t&&(this.lastErrorCode=0),n=d.SCORM_TRUE,this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"getValue",value:function(e,t,r){var n;if(this.checkState(t,f(this,m).RETRIEVE_BEFORE_INIT,f(this,m).RETRIEVE_AFTER_TERM)){t&&(this.lastErrorCode=0);try{n=this.getCMIValue(r)}catch(e){e instanceof l.ValidationError?(this.lastErrorCode=e.errorCode,n=d.SCORM_FALSE):(e.message?console.error(e.message):console.error(e),this.throwSCORMError(f(this,m).GENERAL))}this.processListeners(e,r)}return this.apiLog(e,r,": returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"setValue",value:function(e,t,r,n,i){void 0!==i&&(i=String(i));var o=d.SCORM_FALSE;if(this.checkState(r,f(this,m).STORE_BEFORE_INIT,f(this,m).STORE_AFTER_TERM)){r&&(this.lastErrorCode=0);try{o=this.setCMIValue(n,i)}catch(e){e instanceof l.ValidationError?(this.lastErrorCode=e.errorCode,o=d.SCORM_FALSE):(e.message?console.error(e.message):console.error(e),this.throwSCORMError(f(this,m).GENERAL))}this.processListeners(e,n,i)}return void 0===o&&(o=d.SCORM_FALSE),"0"===String(this.lastErrorCode)&&this.settings.autocommit&&!f(this,a)&&this.scheduleCommit(1e3*this.settings.autocommitSeconds,t),this.apiLog(e,n,": "+i+": result: "+o,d.LOG_LEVEL_INFO),this.clearSCORMError(o),o}},{key:"commit",value:function(e,t){this.clearScheduledCommit();var r,n=d.SCORM_FALSE;return this.checkState(t,f(this,m).COMMIT_BEFORE_INIT,f(this,m).COMMIT_AFTER_TERM)&&(r=this.storeData(!1),!this.settings.sendBeaconCommit&&!this.settings.asyncCommit&&r.errorCode&&0<r.errorCode&&this.throwSCORMError(r.errorCode),n=void 0!==r&&r.result?r.result:d.SCORM_FALSE,this.apiLog(e,"HttpRequest"," Result: "+n,d.LOG_LEVEL_DEBUG),t&&(this.lastErrorCode=0),this.processListeners(e)),this.apiLog(e,null,"returned: "+n,d.LOG_LEVEL_INFO),this.clearSCORMError(n),n}},{key:"getLastError",value:function(e){var t=String(this.lastErrorCode);return this.processListeners(e),this.apiLog(e,null,"returned: "+t,d.LOG_LEVEL_INFO),t}},{key:"getErrorString",value:function(e,t){var r="";return null!==t&&""!==t&&(r=this.getLmsErrorMessageDetails(t),this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),r}},{key:"getDiagnostic",value:function(e,t){var r="";return null!==t&&""!==t&&(r=this.getLmsErrorMessageDetails(t,!0),this.processListeners(e)),this.apiLog(e,null,"returned: "+r,d.LOG_LEVEL_INFO),r}},{key:"checkState",value:function(e,t,r){return this.isNotInitialized()?(this.throwSCORMError(t),!1):!e||!this.isTerminated()||(this.throwSCORMError(r),!1)}},{key:"apiLog",value:function(e,t,r,n){r=this.formatMessage(e,t,r),n>=this.apiLogLevel&&this.settings.onLogMessage(n,r)}},{key:"formatMessage",value:function(e,t,r){for(var n="",i=20-(n+=e).length,o=0;o<i;o++)n+=" ";if(n+=": ",t)for(var i=70-(n+=t).length,a=0;a<i;a++)n+=" ";return r&&(n+=r),n}},{key:"stringMatches",value:function(e,t){return e&&t&&e.match(t)}},{key:"_checkObjectHasProperty",value:function(e,t){return Object.hasOwnProperty.call(e,t)||Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),t)||t in e}},{key:"getLmsErrorMessageDetails",value:function(e,t){throw new Error("The getLmsErrorMessageDetails method has not been implemented")}},{key:"getCMIValue",value:function(e){throw new Error("The getCMIValue method has not been implemented")}},{key:"setCMIValue",value:function(e,t){throw new Error("The setCMIValue method has not been implemented")}},{key:"_commonSetCMIValue",value:function(u,e,t,r){if(!t||""===t)return d.SCORM_FALSE;for(var n=t.split("."),i=this,o=d.SCORM_FALSE,a=!1,s="The data model element passed to ".concat(u," (").concat(t,") is not a valid SCORM data model element."),h=e?f(this,m).UNDEFINED_DATA_MODEL:f(this,m).GENERAL,l=0;l<n.length;l++){var c=n[l];if(l===n.length-1)e&&"{target="===c.substr(0,8)&&"function"==typeof i._isTargetValid?this.throwSCORMError(f(this,m).READ_ONLY_ELEMENT):this._checkObjectHasProperty(i,c)?(this.isInitialized()&&this.stringMatches(t,"\\.correct_responses\\.\\d+")&&this.validateCorrectResponse(t,r),e&&0!==this.lastErrorCode||(i[c]=r,o=d.SCORM_TRUE)):this.throwSCORMError(h,s);else{if(!(i=i[c])){this.throwSCORMError(h,s);break}i instanceof p.CMIArray&&(c=parseInt(n[l+1],10),isNaN(c)||((c=i.childArray[c])?(i=c,a=!0):(c=this.getChildElement(t,r,a),a=!0,c?(i.initialized&&c.initialize(),i.childArray.push(c),i=c):this.throwSCORMError(h,s)),l++))}}return o===d.SCORM_FALSE&&this.apiLog(u,null,"There was an error setting the value for: ".concat(t,", value of: ").concat(r),d.LOG_LEVEL_WARNING),o}},{key:"validateCorrectResponse",value:function(e,t){}},{key:"getChildElement",value:function(e,t,r){throw new Error("The getChildElement method has not been implemented")}},{key:"_commonGetCMIValue",value:function(e,t,r){if(!r||""===r)return"";for(var n=r.split("."),i=this,o=null,u="The data model element passed to ".concat(e," (").concat(r,") has not been initialized."),a="The data model element passed to ".concat(e," (").concat(r,") is not a valid SCORM data model element."),s=t?f(this,m).UNDEFINED_DATA_MODEL:f(this,m).GENERAL,l=0;l<n.length;l++){if(o=n[l],t){if("{target="===String(o).substr(0,8)&&"function"==typeof i._isTargetValid)return c=String(o).substr(8,String(o).length-9),i._isTargetValid(c);if(!this._checkObjectHasProperty(i,o))return void this.throwSCORMError(s,a)}else if(l===n.length-1&&!this._checkObjectHasProperty(i,o))return void this.throwSCORMError(s,a);if(void 0===(i=i[o])){this.throwSCORMError(s,a);break}if(i instanceof p.CMIArray){var c=parseInt(n[l+1],10);if(!isNaN(c)){var h=i.childArray[c];if(!h){this.throwSCORMError(f(this,m).VALUE_NOT_INITIALIZED,u);break}i=h,l++}}}if(null!=i)return i;t||("_children"===o?this.throwSCORMError(C.CHILDREN_ERROR):"_count"===o&&this.throwSCORMError(C.COUNT_ERROR))}},{key:"isInitialized",value:function(){return this.currentState===d.STATE_INITIALIZED}},{key:"isNotInitialized",value:function(){return this.currentState===d.STATE_NOT_INITIALIZED}},{key:"isTerminated",value:function(){return this.currentState===d.STATE_TERMINATED}},{key:"on",value:function(e,t){if(t)for(var r=e.split(" "),n=0;n<r.length;n++){var i=r[n].split(".");if(0===i.length)return;var o=i[0],a=null;1<i.length&&(a=e.replace(o+".","")),this.listenerArray.push({functionName:o,CMIElement:a,callback:t}),this.apiLog("on",o,"Added event listener: ".concat(this.listenerArray.length),d.LOG_LEVEL_INFO)}}},{key:"off",value:function(n,i){var o=this;if(i)for(var a=n.split(" "),e=0;e<a.length;e++){var t=function(e){e=a[e].split(".");if(0===e.length)return{v:void 0};var t=e[0],r=null,e=(1<e.length&&(r=n.replace(t+".","")),o.listenerArray.findIndex(function(e){return e.functionName===t&&e.CMIElement===r&&e.callback===i}));-1!==e&&(o.listenerArray.splice(e,1),o.apiLog("off",t,"Removed event listener: ".concat(o.listenerArray.length),d.LOG_LEVEL_INFO))}(e);if("object"===E(t))return t.v}}},{key:"clear",value:function(n){for(var i=this,o=n.split(" "),e=0;e<o.length;e++){var t=function(e){e=o[e].split(".");if(0===e.length)return{v:void 0};var t=e[0],r=null;1<e.length&&(r=n.replace(t+".","")),i.listenerArray=i.listenerArray.filter(function(e){return e.functionName!==t&&e.CMIElement!==r})}(e);if("object"===E(t))return t.v}}},{key:"processListeners",value:function(e,t,r){this.apiLog(e,t,r);for(var n=0;n<this.listenerArray.length;n++){var i=this.listenerArray[n],o=i.functionName===e,a=!!i.CMIElement,s=!1,s=t&&i.CMIElement&&"*"===i.CMIElement.substring(i.CMIElement.length-1)?0===t.indexOf(i.CMIElement.substring(0,i.CMIElement.length-1)):i.CMIElement===t;!o||a&&!s||i.callback(t,r)}}},{key:"throwSCORMError",value:function(e,t){t=t||this.getLmsErrorMessageDetails(e),this.apiLog("throwSCORMError",null,e+": "+t,d.LOG_LEVEL_ERROR),this.lastErrorCode=String(e)}},{key:"clearSCORMError",value:function(e){void 0!==e&&e!==d.SCORM_FALSE&&(this.lastErrorCode=0)}},{key:"storeData",value:function(e){throw new Error("The storeData method has not been implemented")}},{key:"loadFromFlattenedJSON",value:function(t,r){var n,i,e,o,a=this;function s(e,t,r){var n,e=e.match(r);return null!==e&&null!==(n=t.match(r))?(t=Number(e[2]))===(r=Number(n[2]))?"id"!==e[3]&&("type"!==e[3]||"id"===n[3])?1:-1:t-r:null}this.isNotInitialized()?(n=/^(cmi\.interactions\.)(\d+)\.(.*)$/,i=/^(cmi\.objectives\.)(\d+)\.(.*)$/,(e=Object.keys(t).map(function(e){return[String(e),t[e]]})).sort(function(e,t){var e=y(e,2),r=e[0],e=(e[1],y(t,2)),t=e[0];e[1];return null!==(e=s(r,t,n))||null!==(e=s(r,t,i))?e:r<t?-1:t<r?1:0}),e.forEach(function(e){(o={})[e[0]]=e[1],a.loadFromJSON((0,u.unflatten)(o),r)})):console.error("loadFromFlattenedJSON can only be called before the call to lmsInitialize.")}},{key:"loadFromJSON",value:function(e,t){if(this.isNotInitialized()){for(var r in t=void 0!==t?t:"cmi",this.startingData=e)if({}.hasOwnProperty.call(e,r)&&e[r]){var n=(t?t+".":"")+r,i=e[r];if(i.childArray)for(var o=0;o<i.childArray.length;o++)this.loadFromJSON(i.childArray[o],n+"."+o);else i.constructor===Object?this.loadFromJSON(i,n):this.setCMIValue(n,i)}}else console.error("loadFromJSON can only be called before the call to lmsInitialize.")}},{key:"renderCMIToJSONString",value:function(){var e=this.cmi;return JSON.stringify({cmi:e})}},{key:"renderCMIToJSONObject",value:function(){return JSON.parse(this.renderCMIToJSONString())}},{key:"renderCommitCMI",value:function(e){throw new Error("The storeData method has not been implemented")}},{key:"processHttpRequest",value:function(e,t){function r(e,t,r,n){if(n={result:d.SCORM_FALSE,errorCode:n.GENERAL},r.sendBeaconCommit)try{var i={type:r.commitRequestDataType},o=t instanceof Array?new Blob([t.join("&")],i):new Blob([JSON.stringify(t)],i),a={};navigator.sendBeacon(e,o)?(a.result=d.SCORM_TRUE,a.errorCode=0):(a.result=d.SCORM_FALSE,a.errorCode=101)}catch(e){return console.error(e),l.processListeners("CommitError"),n}else{var s=new XMLHttpRequest;s.open("POST",e,r.asyncCommit),Object.keys(r.xhrHeaders).length&&Object.keys(r.xhrHeaders).forEach(function(e){s.setRequestHeader(e,r.xhrHeaders[e])}),s.withCredentials=r.xhrWithCredentials,r.asyncCommit&&(s.onload=function(e){a="function"==typeof r.responseHandler?r.responseHandler(s):JSON.parse(s.responseText)});try{if((t=r.requestHandler(t))instanceof Array?(s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(t.join("&"))):(s.setRequestHeader("Content-Type",r.commitRequestDataType),s.send(JSON.stringify(t))),r.asyncCommit)return(a={}).result=d.SCORM_TRUE,a.errorCode=0,l.processListeners("CommitSuccess"),a;a="function"==typeof r.responseHandler?r.responseHandler(s):JSON.parse(s.responseText)}catch(e){return console.error(e),l.processListeners("CommitError"),n}}return void 0===a?(l.processListeners("CommitError"),n):(!0===a.result||a.result===d.SCORM_TRUE?l.processListeners("CommitSuccess"):l.processListeners("CommitError"),a)}var n,i=2<arguments.length&&void 0!==arguments[2]&&arguments[2],l=this;return void 0!==g()?((n=g()(r,500))(e,t,this.settings,this.error_codes),i&&n.flush(),{result:d.SCORM_TRUE,errorCode:0}):r(e,t,this.settings,this.error_codes)}},{key:"scheduleCommit",value:function(e,t){o(this,a,new j(this,e,t)),this.apiLog("scheduleCommit","","scheduled",d.LOG_LEVEL_DEBUG)}},{key:"clearScheduledCommit",value:function(){f(this,a)&&(f(this,a).cancel(),o(this,a,null),this.apiLog("clearScheduledCommit","","cleared",d.LOG_LEVEL_DEBUG))}}]),r}(),k=new WeakMap,R=new WeakMap,s=new WeakMap,L=new WeakMap,j=function(){function n(e,t,r){M(this,n),i(this,k,{writable:!0,value:void 0}),i(this,R,{writable:!0,value:!1}),i(this,s,{writable:!0,value:void 0}),i(this,L,{writable:!0,value:void 0}),o(this,k,e),o(this,s,setTimeout(this.wrapper.bind(this),t)),o(this,L,r)}return S(n,[{key:"cancel",value:function(){o(this,R,!0),f(this,s)&&clearTimeout(f(this,s))}},{key:"wrapper",value:function(){f(this,R)||f(this,k).commit(f(this,L))}}]),n}()},"./src/Scorm2004API.js":
|
|
8
|
+
/*!*****************************!*\
|
|
9
|
+
!*** ./src/Scorm2004API.js ***!
|
|
10
|
+
\*****************************/function(r,e,t){"use strict";t.r(e),t.d(e,{default:function(){return O}});var e=t(/*! ./BaseAPI */"./src/BaseAPI.js"),a=t(/*! ./cmi/scorm2004_cmi */"./src/cmi/scorm2004_cmi.js"),o=t(/*! ./utilities */"./src/utilities.js"),n=t(/*! ./constants/api_constants */"./src/constants/api_constants.js"),f=t(/*! ./constants/error_codes */"./src/constants/error_codes.js"),d=t(/*! ./constants/response_constants */"./src/constants/response_constants.js"),m=t(/*! ./constants/language_constants */"./src/constants/language_constants.js"),t=t(/*! ./constants/regex */"./src/constants/regex.js");function p(e){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function g(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function y(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?g(Object(r),!0).forEach(function(e){b(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function v(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function E(e,t){return(E=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function _(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=i(r),t=(e=n?(e=i(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===p(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function M(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function w(e,t){t=function(e,t,r){if(t.has(e))return t.get(e);throw new TypeError("attempted to "+r+" private field on non-instance")}(e,t,"get");return t.get?t.get.call(e):t.value}var l=n.default.scorm2004,c=n.default.global,u=f.default.scorm2004,h=d.default.correct,S=t.default.scorm2004,I=new WeakMap,O=function(e){var t=i;if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&E(t,e);var r,n=_(i);function i(e){if(!(this instanceof i))throw new TypeError("Cannot call a class as a function");var e=y(y({},{mastery_override:!1}),e);return M(s(e=n.call(this,u,e)),I,{writable:!0,value:void 0}),b(s(e),"checkDuplicatedPattern",function(e,t,r){for(var n=!1,i=e._count,o=0;o<i&&!n;o++)o!==t&&e.childArray[o]===r&&(n=!0);return n}),e.cmi=new a.CMI,e.adl=new a.ADL,e.Initialize=e.lmsInitialize,e.Terminate=e.lmsTerminate,e.GetValue=e.lmsGetValue,e.SetValue=e.lmsSetValue,e.Commit=e.lmsCommit,e.GetLastError=e.lmsGetLastError,e.GetErrorString=e.lmsGetErrorString,e.GetDiagnostic=e.lmsGetDiagnostic,e}return t=i,(e=[{key:"version",get:function(){return w(this,I)}},{key:"lmsInitialize",value:function(){return this.cmi.initialize(),this.initialize("Initialize")}},{key:"lmsTerminate",value:function(){var e=this.terminate("Terminate",!0);if(e===c.SCORM_TRUE)if("_none_"!==this.adl.nav.request)switch(this.adl.nav.request){case"continue":this.processListeners("SequenceNext");break;case"previous":this.processListeners("SequencePrevious");break;case"choice":this.processListeners("SequenceChoice");break;case"exit":this.processListeners("SequenceExit");break;case"exitAll":this.processListeners("SequenceExitAll");break;case"abandon":this.processListeners("SequenceAbandon");break;case"abandonAll":this.processListeners("SequenceAbandonAll")}else this.settings.autoProgress&&this.processListeners("SequenceNext");return e}},{key:"lmsGetValue",value:function(e){return this.getValue("GetValue",!0,e)}},{key:"lmsSetValue",value:function(e,t){return this.setValue("SetValue","Commit",!0,e,t)}},{key:"lmsCommit",value:function(){return this.commit("Commit")}},{key:"lmsGetLastError",value:function(){return this.getLastError("GetLastError")}},{key:"lmsGetErrorString",value:function(e){return this.getErrorString("GetErrorString",e)}},{key:"lmsGetDiagnostic",value:function(e){return this.getDiagnostic("GetDiagnostic",e)}},{key:"setCMIValue",value:function(e,t){return this._commonSetCMIValue("SetValue",!0,e,t)}},{key:"getChildElement",value:function(e,t,r){var n,i,o;return this.stringMatches(e,"cmi\\.objectives\\.\\d+")?n=new a.CMIObjectivesObject:r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.correct_responses\\.\\d+")?(i=e.split("."),i=Number(i[2]),i=this.cmi.interactions.childArray[i],this.isInitialized()&&(i.type?(this.checkDuplicateChoiceResponse(i,t),(o=h[i.type])?this.checkValidResponseType(o,t,i.type):this.throwSCORMError(u.GENERAL_SET_FAILURE,"Incorrect Response Type: "+i.type)):this.throwSCORMError(u.DEPENDENCY_NOT_ESTABLISHED)),0===this.lastErrorCode&&(n=new a.CMIInteractionsCorrectResponsesObject)):r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+\\.objectives\\.\\d+")?n=new a.CMIInteractionsObjectivesObject:!r&&this.stringMatches(e,"cmi\\.interactions\\.\\d+")?n=new a.CMIInteractionsObject:this.stringMatches(e,"cmi\\.comments_from_learner\\.\\d+")?n=new a.CMICommentsObject:this.stringMatches(e,"cmi\\.comments_from_lms\\.\\d+")&&(n=new a.CMICommentsObject(!0)),n}},{key:"checkValidResponseType",value:function(e,t,r){var n=[];null!=e&&e.delimiter?n=String(t).split(e.delimiter):n[0]=t,0<n.length&&n.length<=e.max?this.checkCorrectResponseValue(r,n,t):n.length>e.max&&this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Pattern Too Long")}},{key:"checkDuplicateChoiceResponse",value:function(e,t){var r=e.correct_responses._count;if("choice"===e.type)for(var n=0;n<r&&0===this.lastErrorCode;n++)e.correct_responses.childArray[n].pattern===t&&this.throwSCORMError(u.GENERAL_SET_FAILURE)}},{key:"validateCorrectResponse",value:function(e,t){var e=e.split("."),r=Number(e[2]),e=Number(e[4]),r=this.cmi.interactions.childArray[r],n=r.correct_responses._count,i=(this.checkDuplicateChoiceResponse(r,t),h[r.type]);void 0===i.limit||n<=i.limit?(this.checkValidResponseType(i,t,r.type),0===this.lastErrorCode&&(!i.duplicate||!this.checkDuplicatedPattern(r.correct_responses,e,t))||0===this.lastErrorCode&&""===t||0===this.lastErrorCode&&this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Pattern Already Exists")):this.throwSCORMError(u.GENERAL_SET_FAILURE,"Data Model Element Collection Limit Reached")}},{key:"getCMIValue",value:function(e){return this._commonGetCMIValue("GetValue",!0,e)}},{key:"getLmsErrorMessageDetails",value:function(e,t){var r="",n="";return e=String(e),l.error_descriptions[e]&&(r=l.error_descriptions[e].basicMessage,n=l.error_descriptions[e].detailMessage),t?n:r}},{key:"checkCorrectResponseValue",value:function(e,t,r){for(var n=h[e],i=new RegExp(n.format),o=0;o<t.length&&0===this.lastErrorCode;o++)if(e.match("^(fill-in|long-fill-in|matching|performance|sequencing)$")&&(t[o]=this.removeCorrectResponsePrefixes(t[o])),null!=n&&n.delimiter2){var a=t[o].split(n.delimiter2);2===a.length&&a[0].match(i)&&a[1].match(new RegExp(n.format2))||this.throwSCORMError(u.TYPE_MISMATCH)}else{a=t[o].match(i);if(!a&&""!==r||!a&&"true-false"===e)this.throwSCORMError(u.TYPE_MISMATCH);else if("numeric"===e&&1<t.length)Number(t[0])>Number(t[1])&&this.throwSCORMError(u.TYPE_MISMATCH);else if(""!==t[o]&&n.unique)for(var s=0;s<o&&0===this.lastErrorCode;s++)t[o]===t[s]&&this.throwSCORMError(u.TYPE_MISMATCH)}}},{key:"removeCorrectResponsePrefixes",value:function(e){for(var t,r=!1,n=!1,i=!1,o=new RegExp("^({(lang|case_matters|order_matters)=([^}]+)})"),a=e.match(o);a;){switch(a[2]){case"lang":!(t=e.match(S.CMILangcr))||void 0!==(t=t[3])&&0<t.length&&void 0===m.default[t.toLowerCase()]&&this.throwSCORMError(u.TYPE_MISMATCH),i=!0;break;case"case_matters":i||r||n||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),n=!0;break;case"order_matters":n||i||r||"true"!==a[3]&&"false"!==a[3]&&this.throwSCORMError(u.TYPE_MISMATCH),r=!0}a=(e=e.substr(a[1].length)).match(o)}return e}},{key:"replaceWithAnotherScormAPI",value:function(e){this.cmi=e.cmi,this.adl=e.adl}},{key:"renderCommitCMI",value:function(e){var t=this.renderCMIToJSONObject(),r=(e&&(t.cmi.total_time=this.cmi.getCurrentTotalTime()),[]),n=o.flatten(t);switch(this.settings.dataCommitFormat){case"flattened":return o.flatten(t);case"params":for(var i in n)!{}.hasOwnProperty.call(n,i)||r.push("".concat(i,"=").concat(n[i]));return r;default:return t}}},{key:"storeData",value:function(e){e&&"normal"===this.cmi.mode&&"credit"===this.cmi.credit&&(this.cmi.completion_threshold&&this.cmi.progress_measure&&(this.cmi.progress_measure>=this.cmi.completion_threshold?(console.debug("Setting Completion Status: Completed"),this.cmi.completion_status="completed"):(console.debug("Setting Completion Status: Incomplete"),this.cmi.completion_status="incomplete")),this.cmi.scaled_passing_score&&this.cmi.score.scaled&&(this.cmi.score.scaled>=this.cmi.scaled_passing_score?(console.debug("Setting Success Status: Passed"),this.cmi.success_status="passed"):(console.debug("Setting Success Status: Failed"),this.cmi.success_status="failed")));var t,r,n=!1,i=(this.adl.nav.request!==(null===(i=this.startingData)||void 0===i||null===(r=i.adl)||void 0===r||null===(t=r.nav)||void 0===t?void 0:t.request)&&"_none_"!==this.adl.nav.request&&(this.adl.nav.request=encodeURIComponent(this.adl.nav.request),n=!0),this.renderCommitCMI(e||this.settings.alwaysSendTotalTime));return this.apiLogLevel===c.LOG_LEVEL_DEBUG&&(console.debug("Commit (terminated: "+(e?"yes":"no")+"): "),console.debug(i)),this.settings.lmsCommitUrl?(r=this.processHttpRequest(this.settings.lmsCommitUrl,i,e),n&&void 0!==r.navRequest&&""!==r.navRequest&&Function('"use strict";(() => { '.concat(r.navRequest," })()"))(),r):c.SCORM_TRUE}}])&&v(t.prototype,e),r&&v(t,r),Object.defineProperty(t,"prototype",{writable:!1}),i}(e.default)},"./src/cmi/common.js":
|
|
11
|
+
/*!***************************!*\
|
|
12
|
+
!*** ./src/cmi/common.js ***!
|
|
13
|
+
\***************************/function(r,n,e){"use strict";e.r(n),e.d(n,{checkValidFormat:function(){return I},checkValidRange:function(){return O},BaseCMI:function(){return k},CMIScore:function(){return D},CMIArray:function(){return z}});var n=e(/*! ../constants/api_constants */"./src/constants/api_constants.js"),i=e(/*! ../constants/error_codes */"./src/constants/error_codes.js"),e=e(/*! ../constants/regex */"./src/constants/regex.js");function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=c(r),t=(e=n?(e=c(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===o(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return h(t)}}function h(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(e){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function _(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function f(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function d(e,t,r){var t=b(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function t(e,t){t=b(e,t,"get");return t.get?t.get.call(e):t.value}function b(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var M=n.default.scorm12,w=e.default.scorm12,S=i.default.scorm12;function I(e,t,r,n,i){t=new RegExp(t),t=e.match(t);if(i&&""===e)return!0;if(void 0===e||!t||""===t[0])throw new n.prototype.constructor(r);return!0}function O(e,t,r,n){t=t.split("#");if((e=+e)>=t[0]){if("*"===t[1]||e<=t[1])return!0;throw new n.prototype.constructor(r)}throw new n.prototype.constructor(r)}var C=new WeakMap,T=new WeakMap,k=function(){function n(){var e,t,r;if(E(this,n),r=!(t="jsonString"),t in(e=this)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,f(this,C,{writable:!0,value:!1}),f(this,T,{writable:!0,value:void 0}),(this instanceof n?this.constructor:void 0)===n)throw new TypeError("Cannot construct BaseCMI instances directly")}return _(n,[{key:"initialized",get:function(){return t(this,C)}},{key:"start_time",get:function(){return t(this,T)}},{key:"initialize",value:function(){d(this,C,!0)}},{key:"setStartTime",value:function(){d(this,T,(new Date).getTime())}}]),n}(),R=new WeakMap,m=new WeakMap,L=new WeakMap,p=new WeakMap,g=new WeakMap,y=new WeakMap,v=new WeakMap,j=new WeakMap,A=new WeakMap,N=new WeakMap,D=function(){a(u,k);var c=l(u);function u(e){var t,r=e.score_children,n=e.score_range,i=e.max,o=e.invalidErrorCode,a=e.invalidTypeCode,s=e.invalidRangeCode,l=e.decimalRegex,e=e.errorClass;return E(this,u),f(h(t=c.call(this)),R,{writable:!0,value:void 0}),f(h(t),m,{writable:!0,value:void 0}),f(h(t),L,{writable:!0,value:void 0}),f(h(t),p,{writable:!0,value:void 0}),f(h(t),g,{writable:!0,value:void 0}),f(h(t),y,{writable:!0,value:void 0}),f(h(t),v,{writable:!0,value:void 0}),f(h(t),j,{writable:!0,value:""}),f(h(t),A,{writable:!0,value:""}),f(h(t),N,{writable:!0,value:void 0}),d(h(t),R,r||M.score_children),d(h(t),m,!!n&&w.score_range),d(h(t),N,i||""===i?i:"100"),d(h(t),L,o||S.INVALID_SET_VALUE),d(h(t),p,a||S.TYPE_MISMATCH),d(h(t),g,s||S.VALUE_OUT_OF_RANGE),d(h(t),y,l||w.CMIDecimal),d(h(t),v,e),t}return _(u,[{key:"_children",get:function(){return t(this,R)},set:function(e){throw new(t(this,v).prototype.constructor)(t(this,L))}},{key:"raw",get:function(){return t(this,j)},set:function(e){!I(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!O(e,t(this,m),t(this,g),t(this,v))||d(this,j,e)}},{key:"min",get:function(){return t(this,A)},set:function(e){!I(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!O(e,t(this,m),t(this,g),t(this,v))||d(this,A,e)}},{key:"max",get:function(){return t(this,N)},set:function(e){!I(e,t(this,y),t(this,p),t(this,v))||t(this,m)&&!O(e,t(this,m),t(this,g),t(this,v))||d(this,N,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={raw:this.raw,min:this.min,max:this.max};return delete this.jsonString,e}}]),u}(),P=new WeakMap,x=new WeakMap,V=new WeakMap,z=function(){a(o,k);var i=l(o);function o(e){var t,r=e.children,n=e.errorCode,e=e.errorClass;return E(this,o),f(h(t=i.call(this)),P,{writable:!0,value:void 0}),f(h(t),x,{writable:!0,value:void 0}),f(h(t),V,{writable:!0,value:void 0}),d(h(t),V,r),d(h(t),P,n),d(h(t),x,e),t.childArray=[],t}return _(o,[{key:"_children",get:function(){return t(this,V)},set:function(e){throw new(t(this,x).prototype.constructor)(t(this,P))}},{key:"_count",get:function(){return this.childArray.length},set:function(e){throw new(t(this,x).prototype.constructor)(t(this,P))}},{key:"toJSON",value:function(){this.jsonString=!0;for(var e={},t=0;t<this.childArray.length;t++)e[t+""]=this.childArray[t];return delete this.jsonString,e}}]),o}()},"./src/cmi/scorm2004_cmi.js":
|
|
14
|
+
/*!**********************************!*\
|
|
15
|
+
!*** ./src/cmi/scorm2004_cmi.js ***!
|
|
16
|
+
\**********************************/function(e,t,r){"use strict";r.r(t),r.d(t,{CMI:function(){return ee},CMIInteractionsObject:function(){return Ee},CMIObjectivesObject:function(){return Ie},CMICommentsObject:function(){return je},CMIInteractionsObjectivesObject:function(){return Ne},CMIInteractionsCorrectResponsesObject:function(){return Pe},ADL:function(){return xe}});var i=r(/*! ./common */"./src/cmi/common.js"),t=r(/*! ../constants/api_constants */"./src/constants/api_constants.js"),n=r(/*! ../constants/regex */"./src/constants/regex.js"),m=r(/*! ../constants/error_codes */"./src/constants/error_codes.js"),p=r(/*! ../constants/response_constants */"./src/constants/response_constants.js"),g=r(/*! ../exceptions */"./src/exceptions.js"),y=r(/*! ../utilities */"./src/utilities.js");function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function E(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t&&_(e.prototype,t),r&&_(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(){return(b="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=I(e)););return e}(e,t);if(n)return n=Object.getOwnPropertyDescriptor(n,t),n.get?n.get.call(arguments.length<3?e:r):n.value}).apply(this,arguments)}function M(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&w(e,t)}function w(e,t){return(w=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function S(r){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}();return function(){var e,t=I(r),t=(e=n?(e=I(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments),this);if(e&&("object"===v(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return s(t)}}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function I(e){return(I=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function c(e,t,r){var t=O(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function u(e,t){t=O(e,t,"get");return t.get?t.get.call(e):t.value}function O(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var C=t.default.scorm2004,T=m.default.scorm2004,k=p.default.learner,h=n.default.scorm2004;function f(){throw new g.Scorm2004ValidationError(T.READ_ONLY_ELEMENT)}function R(){throw new g.Scorm2004ValidationError(T.WRITE_ONLY_ELEMENT)}function L(){throw new g.Scorm2004ValidationError(T.TYPE_MISMATCH)}function j(){throw new g.Scorm2004ValidationError(T.DEPENDENCY_NOT_ESTABLISHED)}function d(e,t,r){return(0,i.checkValidFormat)(e,t,T.TYPE_MISMATCH,g.Scorm2004ValidationError,r)}function A(e,t){return(0,i.checkValidRange)(e,t,T.VALUE_OUT_OF_RANGE,g.Scorm2004ValidationError)}var N=new WeakMap,D=new WeakMap,P=new WeakMap,x=new WeakMap,V=new WeakMap,z=new WeakMap,F=new WeakMap,G=new WeakMap,W=new WeakMap,U=new WeakMap,q=new WeakMap,$=new WeakMap,B=new WeakMap,H=new WeakMap,Y=new WeakMap,J=new WeakMap,Z=new WeakMap,X=new WeakMap,K=new WeakMap,Q=new WeakMap,ee=function(){M(n,i.BaseCMI);var r=S(n);function n(e){var t;return o(this,n),l(s(t=r.call(this)),N,{writable:!0,value:"1.0"}),l(s(t),D,{writable:!0,value:C.cmi_children}),l(s(t),P,{writable:!0,value:"unknown"}),l(s(t),x,{writable:!0,value:""}),l(s(t),V,{writable:!0,value:"credit"}),l(s(t),z,{writable:!0,value:""}),l(s(t),F,{writable:!0,value:""}),l(s(t),G,{writable:!0,value:""}),l(s(t),W,{writable:!0,value:""}),l(s(t),U,{writable:!0,value:""}),l(s(t),q,{writable:!0,value:""}),l(s(t),$,{writable:!0,value:""}),l(s(t),B,{writable:!0,value:"normal"}),l(s(t),H,{writable:!0,value:""}),l(s(t),Y,{writable:!0,value:""}),l(s(t),J,{writable:!0,value:"PT0H0M0S"}),l(s(t),Z,{writable:!0,value:"unknown"}),l(s(t),X,{writable:!0,value:""}),l(s(t),K,{writable:!0,value:"continue,no message"}),l(s(t),Q,{writable:!0,value:""}),t.learner_preference=new ae,t.score=new Ce,t.comments_from_learner=new ue,t.comments_from_lms=new ce,t.interactions=new se,t.objectives=new le,e&&t.initialize(),t}return a(n,[{key:"initialize",value:function(){var e;b(I(n.prototype),"initialize",this).call(this),null!==(e=this.learner_preference)&&void 0!==e&&e.initialize(),null!==(e=this.score)&&void 0!==e&&e.initialize(),null!==(e=this.comments_from_learner)&&void 0!==e&&e.initialize(),null!==(e=this.comments_from_lms)&&void 0!==e&&e.initialize(),null!==(e=this.interactions)&&void 0!==e&&e.initialize(),null!==(e=this.objectives)&&void 0!==e&&e.initialize()}},{key:"_version",get:function(){return u(this,N)},set:function(e){f()}},{key:"_children",get:function(){return u(this,D)},set:function(e){f()}},{key:"completion_status",get:function(){return u(this,P)},set:function(e){d(e,h.CMICStatus)&&c(this,P,e)}},{key:"completion_threshold",get:function(){return u(this,x)},set:function(e){this.initialized?f():c(this,x,e)}},{key:"credit",get:function(){return u(this,V)},set:function(e){this.initialized?f():c(this,V,e)}},{key:"entry",get:function(){return u(this,z)},set:function(e){this.initialized?f():c(this,z,e)}},{key:"exit",get:function(){return this.jsonString?u(this,F):R()},set:function(e){d(e,h.CMIExit,!0)&&c(this,F,e)}},{key:"launch_data",get:function(){return u(this,G)},set:function(e){this.initialized?f():c(this,G,e)}},{key:"learner_id",get:function(){return u(this,W)},set:function(e){this.initialized?f():c(this,W,e)}},{key:"learner_name",get:function(){return u(this,U)},set:function(e){this.initialized?f():c(this,U,e)}},{key:"location",get:function(){return u(this,q)},set:function(e){d(e,h.CMIString1000)&&c(this,q,e)}},{key:"max_time_allowed",get:function(){return u(this,$)},set:function(e){this.initialized?f():c(this,$,e)}},{key:"mode",get:function(){return u(this,B)},set:function(e){this.initialized?f():c(this,B,e)}},{key:"progress_measure",get:function(){return u(this,H)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.progress_range)&&c(this,H,e)}},{key:"scaled_passing_score",get:function(){return u(this,Y)},set:function(e){this.initialized?f():c(this,Y,e)}},{key:"session_time",get:function(){return this.jsonString?u(this,J):R()},set:function(e){d(e,h.CMITimespan)&&c(this,J,e)}},{key:"success_status",get:function(){return u(this,Z)},set:function(e){d(e,h.CMISStatus)&&c(this,Z,e)}},{key:"suspend_data",get:function(){return u(this,X)},set:function(e){d(e,h.CMIString64000,!0)&&c(this,X,e)}},{key:"time_limit_action",get:function(){return u(this,K)},set:function(e){this.initialized?f():c(this,K,e)}},{key:"total_time",get:function(){return u(this,Q)},set:function(e){this.initialized?f():c(this,Q,e)}},{key:"getCurrentTotalTime",value:function(){var e=u(this,J),t=this.start_time;return null!=t&&(t=(new Date).getTime()-t,e=y.getSecondsAsISODuration(t/1e3)),y.addTwoDurations(u(this,Q),e,h.CMITimespan)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={comments_from_learner:this.comments_from_learner,comments_from_lms:this.comments_from_lms,completion_status:this.completion_status,completion_threshold:this.completion_threshold,credit:this.credit,entry:this.entry,exit:this.exit,interactions:this.interactions,launch_data:this.launch_data,learner_id:this.learner_id,learner_name:this.learner_name,learner_preference:this.learner_preference,location:this.location,max_time_allowed:this.max_time_allowed,mode:this.mode,objectives:this.objectives,progress_measure:this.progress_measure,scaled_passing_score:this.scaled_passing_score,score:this.score,session_time:this.session_time,success_status:this.success_status,suspend_data:this.suspend_data,time_limit_action:this.time_limit_action};return delete this.jsonString,e}}]),n}(),te=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,oe=new WeakMap,ae=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),te,{writable:!0,value:C.student_preference_children}),l(s(e),re,{writable:!0,value:"1"}),l(s(e),ne,{writable:!0,value:""}),l(s(e),ie,{writable:!0,value:"1"}),l(s(e),oe,{writable:!0,value:"0"}),e}return a(r,[{key:"_children",get:function(){return u(this,te)},set:function(e){f()}},{key:"audio_level",get:function(){return u(this,re)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.audio_range)&&c(this,re,e)}},{key:"language",get:function(){return u(this,ne)},set:function(e){d(e,h.CMILang)&&c(this,ne,e)}},{key:"delivery_speed",get:function(){return u(this,ie)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.speed_range)&&c(this,ie,e)}},{key:"audio_captioning",get:function(){return u(this,oe)},set:function(e){d(e,h.CMISInteger)&&A(e,h.text_range)&&c(this,oe,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={audio_level:this.audio_level,language:this.language,delivery_speed:this.delivery_speed,audio_captioning:this.audio_captioning};return delete this.jsonString,e}}]),r}(),se=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.interactions_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),le=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.objectives_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),ce=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.comments_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),ue=function(){M(t,i.CMIArray);var e=S(t);function t(){return o(this,t),e.call(this,{children:C.comments_children,errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError})}return a(t)}(),he=new WeakMap,fe=new WeakMap,de=new WeakMap,me=new WeakMap,pe=new WeakMap,ge=new WeakMap,ye=new WeakMap,ve=new WeakMap,Ee=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),he,{writable:!0,value:""}),l(s(e),fe,{writable:!0,value:""}),l(s(e),de,{writable:!0,value:""}),l(s(e),me,{writable:!0,value:""}),l(s(e),pe,{writable:!0,value:""}),l(s(e),ge,{writable:!0,value:""}),l(s(e),ye,{writable:!0,value:""}),l(s(e),ve,{writable:!0,value:""}),e.objectives=new i.CMIArray({errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError,children:C.objectives_children}),e.correct_responses=new i.CMIArray({errorCode:T.READ_ONLY_ELEMENT,errorClass:g.Scorm2004ValidationError,children:C.correct_responses_children}),e}return a(r,[{key:"initialize",value:function(){var e;b(I(r.prototype),"initialize",this).call(this),null!==(e=this.objectives)&&void 0!==e&&e.initialize(),null!==(e=this.correct_responses)&&void 0!==e&&e.initialize()}},{key:"id",get:function(){return u(this,he)},set:function(e){d(e,h.CMILongIdentifier)&&c(this,he,e)}},{key:"type",get:function(){return u(this,fe)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMIType)&&c(this,fe,e)}},{key:"timestamp",get:function(){return u(this,de)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMITime)&&c(this,de,e)}},{key:"weighting",get:function(){return u(this,me)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMIDecimal)&&c(this,me,e)}},{key:"learner_response",get:function(){return u(this,pe)},set:function(e){if(!this.initialized||""!==u(this,fe)&&""!==u(this,he)){var t=[],r=k[this.type];if(r){if(null!=r&&r.delimiter?t=e.split(r.delimiter):t[0]=e,!(0<t.length&&t.length<=r.max))throw new g.Scorm2004ValidationError(T.GENERAL_SET_FAILURE);for(var n=new RegExp(r.format),i=0;i<t.length;i++)if(null!=r&&r.delimiter2){var o=t[i].split(r.delimiter2);2===o.length&&o[0].match(n)&&o[1].match(new RegExp(r.format2))||L()}else if(t[i].match(n)){if(""!==t[i]&&r.unique)for(var a=0;a<i;a++)t[i]===t[a]&&L()}else L();c(this,pe,e)}else L()}else j()}},{key:"result",get:function(){return u(this,ge)},set:function(e){d(e,h.CMIResult)&&c(this,ge,e)}},{key:"latency",get:function(){return u(this,ye)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMITimespan)&&c(this,ye,e)}},{key:"description",get:function(){return u(this,ve)},set:function(e){this.initialized&&""===u(this,he)?j():d(e,h.CMILangString250,!0)&&c(this,ve,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={id:this.id,type:this.type,objectives:this.objectives,timestamp:this.timestamp,weighting:this.weighting,learner_response:this.learner_response,result:this.result,latency:this.latency,description:this.description,correct_responses:this.correct_responses};return delete this.jsonString,e}}]),r}(),_e=new WeakMap,be=new WeakMap,Me=new WeakMap,we=new WeakMap,Se=new WeakMap,Ie=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),_e,{writable:!0,value:""}),l(s(e),be,{writable:!0,value:"unknown"}),l(s(e),Me,{writable:!0,value:"unknown"}),l(s(e),we,{writable:!0,value:""}),l(s(e),Se,{writable:!0,value:""}),e.score=new Ce,e}return a(r,[{key:"initialize",value:function(){var e;b(I(r.prototype),"initialize",this).call(this),null!==(e=this.score)&&void 0!==e&&e.initialize()}},{key:"id",get:function(){return u(this,_e)},set:function(e){d(e,h.CMILongIdentifier)&&c(this,_e,e)}},{key:"success_status",get:function(){return u(this,be)},set:function(e){this.initialized&&""===u(this,_e)?j():d(e,h.CMISStatus)&&c(this,be,e)}},{key:"completion_status",get:function(){return u(this,Me)},set:function(e){this.initialized&&""===u(this,_e)?j():d(e,h.CMICStatus)&&c(this,Me,e)}},{key:"progress_measure",get:function(){return u(this,we)},set:function(e){this.initialized&&""===u(this,_e)?j():d(e,h.CMIDecimal)&&A(e,h.progress_range)&&c(this,we,e)}},{key:"description",get:function(){return u(this,Se)},set:function(e){this.initialized&&""===u(this,_e)?j():d(e,h.CMILangString250,!0)&&c(this,Se,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={id:this.id,success_status:this.success_status,completion_status:this.completion_status,progress_measure:this.progress_measure,description:this.description,score:this.score};return delete this.jsonString,e}}]),r}(),Oe=new WeakMap,Ce=function(){M(r,i.CMIScore);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this,{score_children:C.score_children,max:"",invalidErrorCode:T.READ_ONLY_ELEMENT,invalidTypeCode:T.TYPE_MISMATCH,invalidRangeCode:T.VALUE_OUT_OF_RANGE,decimalRegex:h.CMIDecimal,errorClass:g.Scorm2004ValidationError})),Oe,{writable:!0,value:""}),e}return a(r,[{key:"scaled",get:function(){return u(this,Oe)},set:function(e){d(e,h.CMIDecimal)&&A(e,h.scaled_range)&&c(this,Oe,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={scaled:this.scaled,raw:b(I(r.prototype),"raw",this),min:b(I(r.prototype),"min",this),max:b(I(r.prototype),"max",this)};return delete this.jsonString,e}}]),r}(),Te=new WeakMap,ke=new WeakMap,Re=new WeakMap,Le=new WeakMap,je=function(){M(n,i.BaseCMI);var r=S(n);function n(){var e,t=0<arguments.length&&void 0!==arguments[0]&&arguments[0];return o(this,n),l(s(e=r.call(this)),Te,{writable:!0,value:""}),l(s(e),ke,{writable:!0,value:""}),l(s(e),Re,{writable:!0,value:""}),l(s(e),Le,{writable:!0,value:void 0}),c(s(e),Te,""),c(s(e),ke,""),c(s(e),Re,""),c(s(e),Le,t),e}return a(n,[{key:"comment",get:function(){return u(this,Te)},set:function(e){this.initialized&&u(this,Le)?f():d(e,h.CMILangString4000,!0)&&c(this,Te,e)}},{key:"location",get:function(){return u(this,ke)},set:function(e){this.initialized&&u(this,Le)?f():d(e,h.CMIString250)&&c(this,ke,e)}},{key:"timestamp",get:function(){return u(this,Re)},set:function(e){this.initialized&&u(this,Le)?f():d(e,h.CMITime)&&c(this,Re,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={comment:this.comment,location:this.location,timestamp:this.timestamp};return delete this.jsonString,e}}]),n}(),Ae=new WeakMap,Ne=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),Ae,{writable:!0,value:""}),e}return a(r,[{key:"id",get:function(){return u(this,Ae)},set:function(e){d(e,h.CMILongIdentifier)&&c(this,Ae,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={id:this.id};return delete this.jsonString,e}}]),r}(),De=new WeakMap,Pe=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),De,{writable:!0,value:""}),e}return a(r,[{key:"pattern",get:function(){return u(this,De)},set:function(e){d(e,h.CMIFeedback)&&c(this,De,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={pattern:this.pattern};return delete this.jsonString,e}}]),r}(),xe=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),(e=t.call(this)).nav=new ze,e}return a(r,[{key:"initialize",value:function(){var e;b(I(r.prototype),"initialize",this).call(this),null!==(e=this.nav)&&void 0!==e&&e.initialize()}},{key:"toJSON",value:function(){this.jsonString=!0;var e={nav:this.nav};return delete this.jsonString,e}}]),r}(),Ve=new WeakMap,ze=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),Ve,{writable:!0,value:"_none_"}),e.request_valid=new We,e}return a(r,[{key:"initialize",value:function(){var e;b(I(r.prototype),"initialize",this).call(this),null!==(e=this.request_valid)&&void 0!==e&&e.initialize()}},{key:"request",get:function(){return u(this,Ve)},set:function(e){d(e,h.NAVEvent)&&c(this,Ve,e)}},{key:"toJSON",value:function(){this.jsonString=!0;var e={request:this.request};return delete this.jsonString,e}}]),r}(),Fe=new WeakMap,Ge=new WeakMap,We=function(){M(r,i.BaseCMI);var t=S(r);function r(){var e;return o(this,r),l(s(e=t.call(this)),Fe,{writable:!0,value:"unknown"}),l(s(e),Ge,{writable:!0,value:"unknown"}),E(s(e),"choice",function(){return a(function e(){o(this,e),E(this,"_isTargetValid",function(e){return"unknown"})})}()),E(s(e),"jump",function(){return a(function e(){o(this,e),E(this,"_isTargetValid",function(e){return"unknown"})})}()),e}return a(r,[{key:"continue",get:function(){return u(this,Fe)},set:function(e){f()}},{key:"previous",get:function(){return u(this,Ge)},set:function(e){f()}},{key:"toJSON",value:function(){this.jsonString=!0;var e={previous:this.previous,continue:this.continue};return delete this.jsonString,e}}]),r}()},"./src/constants/api_constants.js":
|
|
17
|
+
/*!****************************************!*\
|
|
18
|
+
!*** ./src/constants/api_constants.js ***!
|
|
19
|
+
\****************************************/function(e,t,r){"use strict";function o(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function n(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?o(Object(i),!0).forEach(function(e){var t,r;t=n,r=i[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}r.r(t);var r={cmi_children:"core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions",core_children:"student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time",score_children:"raw,min,max",comments_children:"content,location,time",objectives_children:"id,score,status",correct_responses_children:"pattern",student_data_children:"mastery_score,max_time_allowed,time_limit_action",student_preference_children:"audio,language,speed,text",interactions_children:"id,objectives,time,type,correct_responses,weighting,student_response,result,latency",error_descriptions:{101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error. Use LMSGetDiagnostic for more information"},201:{basicMessage:"Invalid argument error",detailMessage:"Indicates that an argument represents an invalid data model element or is otherwise incorrect."},202:{basicMessage:"Element cannot have children",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_children" for a data model element that does not support the "_children" suffix.'},203:{basicMessage:"Element not an array - cannot have count",detailMessage:'Indicates that LMSGetValue was called with a data model element name that ends in "_count" for a data model element that does not support the "_count" suffix.'},301:{basicMessage:"Not initialized",detailMessage:"Indicates that an API call was made before the call to lmsInitialize."},401:{basicMessage:"Not implemented error",detailMessage:"The data model element indicated in a call to LMSGetValue or LMSSetValue is valid, but was not implemented by this LMS. SCORM 1.2 defines a set of data model elements as being optional for an LMS to implement."},402:{basicMessage:"Invalid set value, element is a keyword",detailMessage:'Indicates that LMSSetValue was called on a data model element that represents a keyword (elements that end in "_children" and "_count").'},403:{basicMessage:"Element is read only",detailMessage:"LMSSetValue was called with a data model element that can only be read."},404:{basicMessage:"Element is write only",detailMessage:"LMSGetValue was called on a data model element that can only be written to."},405:{basicMessage:"Incorrect Data Type",detailMessage:"LMSSetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Element Value Out Of Range",detailMessage:"The numeric value supplied to a LMSSetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}},i=n(n({},r),{cmi_children:"core,suspend_data,launch_data,comments,objectives,student_data,student_preference,interactions,evaluation",student_preference_children:"audio,language,lesson_type,speed,text,text_color,text_location,text_size,video,windows",student_data_children:"attempt_number,tries,mastery_score,max_time_allowed,time_limit_action",student_demographics_children:"city,class,company,country,experience,familiar_name,instructor_name,title,native_language,state,street_address,telephone,years_experience",tries_children:"time,status,score",attempt_records_children:"score,lesson_status",paths_children:"location_id,date,time,status,why_left,time_in_element"});t.default={global:{SCORM_TRUE:"true",SCORM_FALSE:"false",STATE_NOT_INITIALIZED:0,STATE_INITIALIZED:1,STATE_TERMINATED:2,LOG_LEVEL_DEBUG:1,LOG_LEVEL_INFO:2,LOG_LEVEL_WARNING:3,LOG_LEVEL_ERROR:4,LOG_LEVEL_NONE:5},scorm12:r,aicc:i,scorm2004:{cmi_children:"_version,comments_from_learner,comments_from_lms,completion_status,credit,entry,exit,interactions,launch_data,learner_id,learner_name,learner_preference,location,max_time_allowed,mode,objectives,progress_measure,scaled_passing_score,score,session_time,success_status,suspend_data,time_limit_action,total_time",comments_children:"comment,timestamp,location",score_children:"max,raw,scaled,min",objectives_children:"progress_measure,completion_status,success_status,description,score,id",correct_responses_children:"pattern",student_data_children:"mastery_score,max_time_allowed,time_limit_action",student_preference_children:"audio_level,audio_captioning,delivery_speed,language",interactions_children:"id,type,objectives,timestamp,correct_responses,weighting,learner_response,result,latency,description",error_descriptions:{0:{basicMessage:"No Error",detailMessage:"No error occurred, the previous API call was successful."},101:{basicMessage:"General Exception",detailMessage:"No specific error code exists to describe the error. Use GetDiagnostic for more information."},102:{basicMessage:"General Initialization Failure",detailMessage:"Call to Initialize failed for an unknown reason."},103:{basicMessage:"Already Initialized",detailMessage:"Call to Initialize failed because Initialize was already called."},104:{basicMessage:"Content Instance Terminated",detailMessage:"Call to Initialize failed because Terminate was already called."},111:{basicMessage:"General Termination Failure",detailMessage:"Call to Terminate failed for an unknown reason."},112:{basicMessage:"Termination Before Initialization",detailMessage:"Call to Terminate failed because it was made before the call to Initialize."},113:{basicMessage:"Termination After Termination",detailMessage:"Call to Terminate failed because Terminate was already called."},122:{basicMessage:"Retrieve Data Before Initialization",detailMessage:"Call to GetValue failed because it was made before the call to Initialize."},123:{basicMessage:"Retrieve Data After Termination",detailMessage:"Call to GetValue failed because it was made after the call to Terminate."},132:{basicMessage:"Store Data Before Initialization",detailMessage:"Call to SetValue failed because it was made before the call to Initialize."},133:{basicMessage:"Store Data After Termination",detailMessage:"Call to SetValue failed because it was made after the call to Terminate."},142:{basicMessage:"Commit Before Initialization",detailMessage:"Call to Commit failed because it was made before the call to Initialize."},143:{basicMessage:"Commit After Termination",detailMessage:"Call to Commit failed because it was made after the call to Terminate."},201:{basicMessage:"General Argument Error",detailMessage:"An invalid argument was passed to an API method (usually indicates that Initialize, Commit or Terminate did not receive the expected empty string argument."},301:{basicMessage:"General Get Failure",detailMessage:"Indicates a failed GetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},351:{basicMessage:"General Set Failure",detailMessage:"Indicates a failed SetValue call where no other specific error code is applicable. Use GetDiagnostic for more information."},391:{basicMessage:"General Commit Failure",detailMessage:"Indicates a failed Commit call where no other specific error code is applicable. Use GetDiagnostic for more information."},401:{basicMessage:"Undefined Data Model Element",detailMessage:"The data model element name passed to GetValue or SetValue is not a valid SCORM data model element."},402:{basicMessage:"Unimplemented Data Model Element",detailMessage:"The data model element indicated in a call to GetValue or SetValue is valid, but was not implemented by this LMS. In SCORM 2004, this error would indicate an LMS that is not fully SCORM conformant."},403:{basicMessage:"Data Model Element Value Not Initialized",detailMessage:"Attempt to read a data model element that has not been initialized by the LMS or through a SetValue call. This error condition is often reached during normal execution of a SCO."},404:{basicMessage:"Data Model Element Is Read Only",detailMessage:"SetValue was called with a data model element that can only be read."},405:{basicMessage:"Data Model Element Is Write Only",detailMessage:"GetValue was called on a data model element that can only be written to."},406:{basicMessage:"Data Model Element Type Mismatch",detailMessage:"SetValue was called with a value that is not consistent with the data format of the supplied data model element."},407:{basicMessage:"Data Model Element Value Out Of Range",detailMessage:"The numeric value supplied to a SetValue call is outside of the numeric range allowed for the supplied data model element."},408:{basicMessage:"Data Model Dependency Not Established",detailMessage:"Some data model elements cannot be set until another data model element was set. This error condition indicates that the prerequisite element was not set before the dependent element."}}}}},"./src/constants/error_codes.js":
|
|
20
|
+
/*!**************************************!*\
|
|
21
|
+
!*** ./src/constants/error_codes.js ***!
|
|
22
|
+
\**************************************/function(e,t,r){"use strict";function o(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function n(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?o(Object(i),!0).forEach(function(e){var t,r;t=n,r=i[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}r.r(t);var r={GENERAL:101,INITIALIZATION_FAILED:101,INITIALIZED:101,TERMINATED:101,TERMINATION_FAILURE:101,TERMINATION_BEFORE_INIT:101,MULTIPLE_TERMINATION:101,RETRIEVE_BEFORE_INIT:101,RETRIEVE_AFTER_TERM:101,STORE_BEFORE_INIT:101,STORE_AFTER_TERM:101,COMMIT_BEFORE_INIT:101,COMMIT_AFTER_TERM:101,ARGUMENT_ERROR:101,CHILDREN_ERROR:101,COUNT_ERROR:101,GENERAL_GET_FAILURE:101,GENERAL_SET_FAILURE:101,GENERAL_COMMIT_FAILURE:101,UNDEFINED_DATA_MODEL:101,UNIMPLEMENTED_ELEMENT:101,VALUE_NOT_INITIALIZED:101,INVALID_SET_VALUE:101,READ_ONLY_ELEMENT:101,WRITE_ONLY_ELEMENT:101,TYPE_MISMATCH:101,VALUE_OUT_OF_RANGE:101,DEPENDENCY_NOT_ESTABLISHED:101},i=n(n({},r),{RETRIEVE_BEFORE_INIT:301,STORE_BEFORE_INIT:301,COMMIT_BEFORE_INIT:301,ARGUMENT_ERROR:201,CHILDREN_ERROR:202,COUNT_ERROR:203,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:401,VALUE_NOT_INITIALIZED:301,INVALID_SET_VALUE:402,READ_ONLY_ELEMENT:403,WRITE_ONLY_ELEMENT:404,TYPE_MISMATCH:405,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408}),r=n(n({},r),{INITIALIZATION_FAILED:102,INITIALIZED:103,TERMINATED:104,TERMINATION_FAILURE:111,TERMINATION_BEFORE_INIT:112,MULTIPLE_TERMINATIONS:113,RETRIEVE_BEFORE_INIT:122,RETRIEVE_AFTER_TERM:123,STORE_BEFORE_INIT:132,STORE_AFTER_TERM:133,COMMIT_BEFORE_INIT:142,COMMIT_AFTER_TERM:143,ARGUMENT_ERROR:201,GENERAL_GET_FAILURE:301,GENERAL_SET_FAILURE:351,GENERAL_COMMIT_FAILURE:391,UNDEFINED_DATA_MODEL:401,UNIMPLEMENTED_ELEMENT:402,VALUE_NOT_INITIALIZED:403,READ_ONLY_ELEMENT:404,WRITE_ONLY_ELEMENT:405,TYPE_MISMATCH:406,VALUE_OUT_OF_RANGE:407,DEPENDENCY_NOT_ESTABLISHED:408});t.default={scorm12:i,scorm2004:r}},"./src/constants/language_constants.js":
|
|
23
|
+
/*!*********************************************!*\
|
|
24
|
+
!*** ./src/constants/language_constants.js ***!
|
|
25
|
+
\*********************************************/function(e,t,r){"use strict";r.r(t);t.default={aa:"aa",ab:"ab",ae:"ae",af:"af",ak:"ak",am:"am",an:"an",ar:"ar",as:"as",av:"av",ay:"ay",az:"az",ba:"ba",be:"be",bg:"bg",bh:"bh",bi:"bi",bm:"bm",bn:"bn",bo:"bo",br:"br",bs:"bs",ca:"ca",ce:"ce",ch:"ch",co:"co",cr:"cr",cs:"cs",cu:"cu",cv:"cv",cy:"cy",da:"da",de:"de",dv:"dv",dz:"dz",ee:"ee",el:"el",en:"en",eo:"eo",es:"es",et:"et",eu:"eu",fa:"fa",ff:"ff",fi:"fi",fj:"fj",fo:"fo",fr:"fr",fy:"fy",ga:"ga",gd:"gd",gl:"gl",gn:"gn",gu:"gu",gv:"gv",ha:"ha",he:"he",hi:"hi",ho:"ho",hr:"hr",ht:"ht",hu:"hu",hy:"hy",hz:"hz",ia:"ia",id:"id",ie:"ie",ig:"ig",ii:"ii",ik:"ik",io:"io",is:"is",it:"it",iu:"iu",ja:"ja",jv:"jv",ka:"ka",kg:"kg",ki:"ki",kj:"kj",kk:"kk",kl:"kl",km:"km",kn:"kn",ko:"ko",kr:"kr",ks:"ks",ku:"ku",kv:"kv",kw:"kw",ky:"ky",la:"la",lb:"lb",lg:"lg",li:"li",ln:"ln",lo:"lo",lt:"lt",lu:"lu",lv:"lv",mg:"mg",mh:"mh",mi:"mi",mk:"mk",ml:"ml",mn:"mn",mo:"mo",mr:"mr",ms:"ms",mt:"mt",my:"my",na:"na",nb:"nb",nd:"nd",ne:"ne",ng:"ng",nl:"nl",nn:"nn",no:"no",nr:"nr",nv:"nv",ny:"ny",oc:"oc",oj:"oj",om:"om",or:"or",os:"os",pa:"pa",pi:"pi",pl:"pl",ps:"ps",pt:"pt",qu:"qu",rm:"rm",rn:"rn",ro:"ro",ru:"ru",rw:"rw",sa:"sa",sc:"sc",sd:"sd",se:"se",sg:"sg",sh:"sh",si:"si",sk:"sk",sl:"sl",sm:"sm",sn:"sn",so:"so",sq:"sq",sr:"sr",ss:"ss",st:"st",su:"su",sv:"sv",sw:"sw",ta:"ta",te:"te",tg:"tg",th:"th",ti:"ti",tk:"tk",tl:"tl",tn:"tn",to:"to",tr:"tr",ts:"ts",tt:"tt",tw:"tw",ty:"ty",ug:"ug",uk:"uk",ur:"ur",uz:"uz",ve:"ve",vi:"vi",vo:"vo",wa:"wa",wo:"wo",xh:"xh",yi:"yi",yo:"yo",za:"za",zh:"zh",zu:"zu",aar:"aar",abk:"abk",ave:"ave",afr:"afr",aka:"aka",amh:"amh",arg:"arg",ara:"ara",asm:"asm",ava:"ava",aym:"aym",aze:"aze",bak:"bak",bel:"bel",bul:"bul",bih:"bih",bis:"bis",bam:"bam",ben:"ben",tib:"tib",bod:"bod",bre:"bre",bos:"bos",cat:"cat",che:"che",cha:"cha",cos:"cos",cre:"cre",cze:"cze",ces:"ces",chu:"chu",chv:"chv",wel:"wel",cym:"cym",dan:"dan",ger:"ger",deu:"deu",div:"div",dzo:"dzo",ewe:"ewe",gre:"gre",ell:"ell",eng:"eng",epo:"epo",spa:"spa",est:"est",baq:"baq",eus:"eus",per:"per",fas:"fas",ful:"ful",fin:"fin",fij:"fij",fao:"fao",fre:"fre",fra:"fra",fry:"fry",gle:"gle",gla:"gla",glg:"glg",grn:"grn",guj:"guj",glv:"glv",hau:"hau",heb:"heb",hin:"hin",hmo:"hmo",hrv:"hrv",hat:"hat",hun:"hun",arm:"arm",hye:"hye",her:"her",ina:"ina",ind:"ind",ile:"ile",ibo:"ibo",iii:"iii",ipk:"ipk",ido:"ido",ice:"ice",isl:"isl",ita:"ita",iku:"iku",jpn:"jpn",jav:"jav",geo:"geo",kat:"kat",kon:"kon",kik:"kik",kua:"kua",kaz:"kaz",kal:"kal",khm:"khm",kan:"kan",kor:"kor",kau:"kau",kas:"kas",kur:"kur",kom:"kom",cor:"cor",kir:"kir",lat:"lat",ltz:"ltz",lug:"lug",lim:"lim",lin:"lin",lao:"lao",lit:"lit",lub:"lub",lav:"lav",mlg:"mlg",mah:"mah",mao:"mao",mri:"mri",mac:"mac",mkd:"mkd",mal:"mal",mon:"mon",mol:"mol",mar:"mar",may:"may",msa:"msa",mlt:"mlt",bur:"bur",mya:"mya",nau:"nau",nob:"nob",nde:"nde",nep:"nep",ndo:"ndo",dut:"dut",nld:"nld",nno:"nno",nor:"nor",nbl:"nbl",nav:"nav",nya:"nya",oci:"oci",oji:"oji",orm:"orm",ori:"ori",oss:"oss",pan:"pan",pli:"pli",pol:"pol",pus:"pus",por:"por",que:"que",roh:"roh",run:"run",rum:"rum",ron:"ron",rus:"rus",kin:"kin",san:"san",srd:"srd",snd:"snd",sme:"sme",sag:"sag",slo:"slo",sin:"sin",slk:"slk",slv:"slv",smo:"smo",sna:"sna",som:"som",alb:"alb",sqi:"sqi",srp:"srp",ssw:"ssw",sot:"sot",sun:"sun",swe:"swe",swa:"swa",tam:"tam",tel:"tel",tgk:"tgk",tha:"tha",tir:"tir",tuk:"tuk",tgl:"tgl",tsn:"tsn",ton:"ton",tur:"tur",tso:"tso",tat:"tat",twi:"twi",tah:"tah",uig:"uig",ukr:"ukr",urd:"urd",uzb:"uzb",ven:"ven",vie:"vie",vol:"vol",wln:"wln",wol:"wol",xho:"xho",yid:"yid",yor:"yor",zha:"zha",chi:"chi",zho:"zho",zul:"zul"}},"./src/constants/regex.js":
|
|
26
|
+
/*!********************************!*\
|
|
27
|
+
!*** ./src/constants/regex.js ***!
|
|
28
|
+
\********************************/function(e,t,r){"use strict";function o(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function n(n){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?o(Object(i),!0).forEach(function(e){var t,r;t=n,r=i[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(i)):o(Object(i)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(i,e))})}return n}r.r(t);var r={CMIString256:"^.{0,255}$",CMIString4096:"^.{0,4096}$",CMITime:"^(?:[01]\\d|2[0123]):(?:[012345]\\d):(?:[012345]\\d)$",CMITimespan:"^([0-9]{2,}):([0-9]{2}):([0-9]{2})(.[0-9]{1,2})?$",CMIInteger:"^\\d+$",CMISInteger:"^-?([0-9]+)$",CMIDecimal:"^-?([0-9]{0,3})(.[0-9]*)?$",CMIIdentifier:"^[\\u0021-\\u007E\\s]{0,255}$",CMIFeedback:"^.{0,255}$",CMIIndex:"[._](\\d+).",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]*)?)$",NAVEvent:"^(previous|continue)$",score_range:"0#100",audio_range:"-1#100",speed_range:"-100#100",weighting_range:"-100#100",text_range:"-1#1"},i=n(n({},r),{CMIIdentifier:"^\\w{1,255}$"});t.default={aicc:i,scorm12:r,scorm2004:{CMIString200:"^[\\u0000-\\uFFFF]{0,200}$",CMIString250:"^[\\u0000-\\uFFFF]{0,250}$",CMIString1000:"^[\\u0000-\\uFFFF]{0,1000}$",CMIString4000:"^[\\u0000-\\uFFFF]{0,4000}$",CMIString64000:"^[\\u0000-\\uFFFF]{0,64000}$",CMILang:"^([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?$|^$",CMILangString250:"^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,250}$)?$",CMILangcr:"^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?}))(.*?)$",CMILangString250cr:"^(({lang=([a-zA-Z]{2,3}|i|x)?(-[a-zA-Z0-9-]{2,8})?})?(.{0,250})?)?$",CMILangString4000:"^({lang=([a-zA-Z]{2,3}|i|x)(-[a-zA-Z0-9-]{2,8})?})?((?!{.*$).{0,4000}$)?$",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)?)?$",CMIInteger:"^\\d+$",CMISInteger:"^-?([0-9]+)$",CMIDecimal:"^-?([0-9]{1,5})(\\.[0-9]{1,18})?$",CMIIdentifier:"^\\S{1,250}[a-zA-Z0-9]$",CMIShortIdentifier:"^[\\w\\.\\-\\_]{1,250}$",CMILongIdentifier:"^(?:(?!urn:)\\S{1,4000}|urn:[A-Za-z0-9-]{1,31}:\\S{1,4000}|.{1,4000})$",CMIFeedback:"^.*$",CMIIndex:"[._](\\d+).",CMIIndexStore:".N(\\d+).",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|incorrect|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)$",NAVBoolean:"^(unknown|true|false$)",NAVTarget:"^(previous|continue|choice.{target=\\S{0,200}[a-zA-Z0-9]})$",scaled_range:"-1#1",audio_range:"0#*",speed_range:"0#*",text_range:"-1#1",progress_range:"0#1"}}},"./src/constants/response_constants.js":
|
|
29
|
+
/*!*********************************************!*\
|
|
30
|
+
!*** ./src/constants/response_constants.js ***!
|
|
31
|
+
\*********************************************/function(e,t,r){"use strict";r.r(t);var r=r(/*! ./regex */"./src/constants/regex.js").default.scorm2004,n={"true-false":{format:"^true$|^false$",max:1,delimiter:"",unique:!1},choice:{format:r.CMILongIdentifier,max:36,delimiter:"[,]",unique:!0},"fill-in":{format:r.CMILangString250,max:10,delimiter:"[,]",unique:!1},"long-fill-in":{format:r.CMILangString4000,max:1,delimiter:"",unique:!1},matching:{format:r.CMIShortIdentifier,format2:r.CMIShortIdentifier,max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1},performance:{format:"^$|"+r.CMIShortIdentifier,format2:r.CMIDecimal+"|^$|"+r.CMIShortIdentifier,max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1},sequencing:{format:r.CMIShortIdentifier,max:36,delimiter:"[,]",unique:!1},likert:{format:r.CMIShortIdentifier,max:1,delimiter:"",unique:!1},numeric:{format:r.CMIDecimal,max:1,delimiter:"",unique:!1},other:{format:r.CMIString4000,max:1,delimiter:"",unique:!1}},r={"true-false":{max:1,delimiter:"",unique:!1,duplicate:!1,format:"^true$|^false$",limit:1},choice:{max:36,delimiter:"[,]",unique:!0,duplicate:!1,format:r.CMILongIdentifier},"fill-in":{max:10,delimiter:"[,]",unique:!1,duplicate:!1,format:r.CMILangString250cr},"long-fill-in":{max:1,delimiter:"",unique:!1,duplicate:!0,format:r.CMILangString4000},matching:{max:36,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:r.CMIShortIdentifier,format2:r.CMIShortIdentifier},performance:{max:250,delimiter:"[,]",delimiter2:"[.]",unique:!1,duplicate:!1,format:"^$|"+r.CMIShortIdentifier,format2:r.CMIDecimal+"|^$|"+r.CMIShortIdentifier},sequencing:{max:36,delimiter:"[,]",unique:!1,duplicate:!1,format:r.CMIShortIdentifier},likert:{max:1,delimiter:"",unique:!1,duplicate:!1,format:r.CMIShortIdentifier,limit:1},numeric:{max:2,delimiter:"[:]",unique:!1,duplicate:!1,format:r.CMIDecimal,limit:1},other:{max:1,delimiter:"",unique:!1,duplicate:!1,format:r.CMIString4000,limit:1}};t.default={learner:n,correct:r}},"./src/exceptions.js":
|
|
32
|
+
/*!***************************!*\
|
|
33
|
+
!*** ./src/exceptions.js ***!
|
|
34
|
+
\***************************/function(t,e,r){"use strict";r.r(e),r.d(e,{ValidationError:function(){return O},Scorm12ValidationError:function(){return C},AICCValidationError:function(){return T},Scorm2004ValidationError:function(){return k}});e=r(/*! ./constants/api_constants */"./src/constants/api_constants.js");function f(e){return(f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function n(e,t,r){return t&&d(e.prototype,t),r&&d(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function l(r){var n=g();return function(){var e,t=v(r);return i(this,n?(e=v(this).constructor,Reflect.construct(t,arguments,e)):t.apply(this,arguments))}}function i(e,t){if(t&&("object"===f(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e){var r="function"==typeof Map?new Map:void 0;return function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return p(e,arguments,v(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),y(t,e)}(e)}function p(e,t,r){return(p=g()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);t=new(Function.bind.apply(e,n));return r&&y(t,r.prototype),t}).apply(null,arguments)}function g(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function E(e,t,r){var n=e;if(t.has(n))throw new TypeError("Cannot initialize the same private elements twice on an object");t.set(e,r)}function _(e,t){t=M(e,t,"get");return t.get?t.get.call(e):t.value}function b(e,t,r){var t=M(e,t,"set"),n=r;if(t.set)t.set.call(e,n);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=n}return r}function M(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}var o=e.default.scorm12.error_descriptions,u=e.default.aicc.error_descriptions,h=e.default.scorm2004.error_descriptions,w=new WeakMap,S=new WeakMap,I=new WeakMap,O=function(){s(o,m(Error));var i=l(o);function o(e,t,r){var n;return a(this,o),E(c(n=i.call(this,t)),w,{writable:!0,value:void 0}),E(c(n),S,{writable:!0,value:void 0}),E(c(n),I,{writable:!0,value:void 0}),b(c(n),w,e),b(c(n),S,t),b(c(n),I,r),n}return n(o,[{key:"errorCode",get:function(){return _(this,w)}},{key:"errorMessage",get:function(){return _(this,S)}},{key:"detailedMessage",get:function(){return _(this,I)}}]),o}(),C=function(){s(r,O);var t=l(r);function r(e){return a(this,r),i({}.hasOwnProperty.call(o,String(e))?t.call(this,e,o[String(e)].basicMessage,o[String(e)].detailMessage):t.call(this,101,o[101].basicMessage,o[101].detailMessage))}return n(r)}(),T=function(){s(r,O);var t=l(r);function r(e){return a(this,r),i({}.hasOwnProperty.call(u,String(e))?t.call(this,e,u[String(e)].basicMessage,u[String(e)].detailMessage):t.call(this,101,u[101].basicMessage,u[101].detailMessage))}return n(r)}(),k=function(){s(r,O);var t=l(r);function r(e){return a(this,r),i({}.hasOwnProperty.call(h,String(e))?t.call(this,e,h[String(e)].basicMessage,h[String(e)].detailMessage):t.call(this,101,h[101].basicMessage,h[101].detailMessage))}return n(r)}()},"./src/utilities.js":
|
|
35
|
+
/*!**************************!*\
|
|
36
|
+
!*** ./src/utilities.js ***!
|
|
37
|
+
\**************************/function(u,e,t){"use strict";function a(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Map"===(r="Object"===r&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}t.r(e),t.d(e,{SECONDS_PER_SECOND:function(){return r},SECONDS_PER_MINUTE:function(){return i},SECONDS_PER_HOUR:function(){return o},SECONDS_PER_DAY:function(){return h},getSecondsAsHHMMSS:function(){return d},getSecondsAsISODuration:function(){return m},getTimeAsSeconds:function(){return s},getDurationAsSeconds:function(){return l},addTwoDurations:function(){return p},addHHMMSSTimeStrings:function(){return g},flatten:function(){return y},unflatten:function(){return v},countDecimals:function(){return c}});var r=1,i=60,o=60*i,h=24*o,f=[["D",h],["H",o],["M",i],["S",r]];function d(e){if(!e||e<=0)return"00:00:00";var t=Math.floor(e/o),r=new Date(1e3*e),n=r.getUTCMinutes(),r=r.getSeconds(),e=e%1,i="";return 0<c(e)&&(i="."+(i=2<c(e)?e.toFixed(2):String(e)).split(".")[1]),(t+":"+n+":"+r).replace(/\b\d\b/g,"0$&")+i}function m(e){if(!e||e<=0)return"PT0S";var n="P",i=e;return f.forEach(function(e){var e=a(e,2),t=e[0],e=e[1],r=Math.floor(i/e);2<c(i%=e)&&(i=Number(Number(i).toFixed(2))),"S"===t&&0<i&&(r+=i),r&&((0<n.indexOf("D")||"H"===t||"M"===t||"S"===t)&&-1===n.indexOf("T")&&(n+="T"),n+="".concat(r).concat(t))}),n}function s(e,t){if(!e||"string"!=typeof e||!e.match(t))return 0;t=e.split(":");return 3600*Number(t[0])+60*Number(t[1])+Number(t[2])}function l(e,t){if(!e||!e.match(t))return 0;var t=a(new RegExp(t).exec(e)||[],8),e=t[1],r=(t[2],t[4]),n=t[5],i=t[6],t=t[7],o=0;return(o+=+Number(t)||0)+(60*Number(i)||0)+(3600*Number(n)||0)+(86400*Number(r)||0)+(31536e3*Number(e)||0)}function p(e,t,r){return m(l(e,r)+l(t,r))}function g(e,t,r){return d(s(e,r)+s(t,r))}function y(e){var s={};return function e(t,r){if(Object(t)!==t)s[r]=t;else if(Array.isArray(t))for(var n=0,i=t.length;n<i;n++)e(t[n],r+"["+n+"]"),0===i&&(s[r]=[]);else{var o,a=!0;for(o in t)!{}.hasOwnProperty.call(t,o)||(a=!1,e(t[o],r?r+"."+o:o));a&&r&&(s[r]={})}}(e,""),s}function v(e){if(Object(e)!==e||Array.isArray(e))return e;var t,r=/\.?([^.[\]]+)|\[(\d+)]/g,n={};for(t in e)if({}.hasOwnProperty.call(e,t)){for(var i=n,o="",a=r.exec(t);a;)i=i[o]||(i[o]=a[2]?[]:{}),o=a[2]||a[1],a=r.exec(t);i[o]=e[t]}return n[""]||n}function c(e){return!(Math.floor(e)===e||String(e).indexOf(".")<0)&&e.toString().split(".")[1].length||0}}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;t=n[e]={exports:{}};return r[e](t,t.exports,i),t.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};!function(){"use strict";
|
|
38
|
+
/*!**********************************!*\
|
|
39
|
+
!*** ./src/exports/scorm2004.js ***!
|
|
40
|
+
\**********************************/i.r(t);var e=i(/*! ../Scorm2004API */"./src/Scorm2004API.js");window.Scorm2004API=e.default}()}();
|
package/package.json
CHANGED
|
@@ -1,50 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scorm-again",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "A modern SCORM JavaScript run-time library for AICC, SCORM 1.2, and SCORM 2004",
|
|
5
5
|
"main": "dist/scorm-again.min.js",
|
|
6
|
+
"browserslist": [
|
|
7
|
+
"> 1%",
|
|
8
|
+
"edge >= 16",
|
|
9
|
+
"safari >= 9",
|
|
10
|
+
"firefox >= 57",
|
|
11
|
+
"ie >= 11",
|
|
12
|
+
"ios >= 9",
|
|
13
|
+
"chrome >= 49"
|
|
14
|
+
],
|
|
6
15
|
"directories": {
|
|
7
16
|
"test": "test"
|
|
8
17
|
},
|
|
9
18
|
"devDependencies": {
|
|
10
|
-
"@babel/cli": "^7.
|
|
11
|
-
"@babel/core": "^7.
|
|
12
|
-
"@babel/node": "^7.
|
|
13
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
14
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
15
|
-
"@babel/plugin-proposal-private-methods": "^7.
|
|
16
|
-
"@babel/preset-env": "^7.
|
|
17
|
-
"@babel/preset-flow": "^7.
|
|
18
|
-
"@babel/register": "^7.
|
|
19
|
-
"@types/chai": "^4.
|
|
20
|
-
"@types/mocha": "^
|
|
19
|
+
"@babel/cli": "^7.17.0",
|
|
20
|
+
"@babel/core": "^7.17.2",
|
|
21
|
+
"@babel/node": "^7.16.8",
|
|
22
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
23
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
24
|
+
"@babel/plugin-proposal-private-methods": "^7.16.11",
|
|
25
|
+
"@babel/preset-env": "^7.16.11",
|
|
26
|
+
"@babel/preset-flow": "^7.16.7",
|
|
27
|
+
"@babel/register": "^7.17.0",
|
|
28
|
+
"@types/chai": "^4.3.0",
|
|
29
|
+
"@types/mocha": "^9.1.0",
|
|
21
30
|
"babel-eslint": "^11.0.0-beta.2",
|
|
31
|
+
"babel-loader": "^8.2.3",
|
|
22
32
|
"babelify": "^10.0.0",
|
|
23
33
|
"browserify": "^17.0.0",
|
|
24
|
-
"chai": "^4.3.
|
|
25
|
-
"eslint": "^
|
|
34
|
+
"chai": "^4.3.6",
|
|
35
|
+
"eslint": "^8.8.0",
|
|
26
36
|
"eslint-config-google": "^0.14.0",
|
|
27
|
-
"eslint-plugin-import": "^2.
|
|
37
|
+
"eslint-plugin-import": "^2.25.4",
|
|
38
|
+
"eslint-webpack-plugin": "^3.1.1",
|
|
28
39
|
"fetch-pretender": "^1.5.0",
|
|
29
|
-
"
|
|
30
|
-
"grunt-browserify": "^6.0.0",
|
|
31
|
-
"grunt-cli": "^1.4.2",
|
|
32
|
-
"grunt-contrib-watch": "^1.1.0",
|
|
33
|
-
"grunt-mocha-test": "^0.13.3",
|
|
34
|
-
"jsdoc": "^3.6.6",
|
|
40
|
+
"jsdoc": "^3.6.10",
|
|
35
41
|
"jsdoc-babel": "^0.5.0",
|
|
36
42
|
"lodash.debounce": "^4.0.8",
|
|
37
|
-
"minifyify": "^7.3.5",
|
|
38
43
|
"minimist": "^1.2.5",
|
|
39
|
-
"mocha": "^
|
|
40
|
-
"mocha-junit-reporter": "^2.0.
|
|
41
|
-
"mochawesome": "^
|
|
44
|
+
"mocha": "^9.2.0",
|
|
45
|
+
"mocha-junit-reporter": "^2.0.2",
|
|
46
|
+
"mochawesome": "^7.0.1",
|
|
42
47
|
"nyc": "^15.1.0",
|
|
43
|
-
"sinon": "^
|
|
48
|
+
"sinon": "^13.0.1",
|
|
49
|
+
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
50
|
+
"webpack": "^5.68.0",
|
|
51
|
+
"webpack-cli": "^4.9.2"
|
|
44
52
|
},
|
|
45
53
|
"scripts": {
|
|
46
54
|
"test": "./node_modules/.bin/mocha --require @babel/register --bdd --recursive --reporter list",
|
|
47
|
-
"compile": "./node_modules/.bin/
|
|
55
|
+
"compile": "./node_modules/.bin/webpack --bail --config webpack.js",
|
|
48
56
|
"fix": "./node_modules/.bin/eslint ./src --fix"
|
|
49
57
|
},
|
|
50
58
|
"repository": {
|
|
@@ -57,7 +65,7 @@
|
|
|
57
65
|
"cmi"
|
|
58
66
|
],
|
|
59
67
|
"author": "Jonathan Putney <jonathan@putney.io>",
|
|
60
|
-
"license": "
|
|
68
|
+
"license": "MIT",
|
|
61
69
|
"bugs": {
|
|
62
70
|
"url": "https://github.com/jcputney/scorm-again/issues"
|
|
63
71
|
},
|
package/src/BaseAPI.js
CHANGED
|
@@ -28,6 +28,9 @@ export default class BaseAPI {
|
|
|
28
28
|
logLevel: global_constants.LOG_LEVEL_ERROR,
|
|
29
29
|
selfReportSessionTime: false,
|
|
30
30
|
alwaysSendTotalTime: false,
|
|
31
|
+
strict_errors: true,
|
|
32
|
+
xhrHeaders: {},
|
|
33
|
+
xhrWithCredentials: false,
|
|
31
34
|
responseHandler: function(xhr) {
|
|
32
35
|
let result;
|
|
33
36
|
if (typeof xhr !== 'undefined') {
|
|
@@ -45,6 +48,29 @@ export default class BaseAPI {
|
|
|
45
48
|
}
|
|
46
49
|
return result;
|
|
47
50
|
},
|
|
51
|
+
requestHandler: function(commitObject) {
|
|
52
|
+
return commitObject;
|
|
53
|
+
},
|
|
54
|
+
onLogMessage: function(messageLevel, logMessage) {
|
|
55
|
+
switch (messageLevel) {
|
|
56
|
+
case global_constants.LOG_LEVEL_ERROR:
|
|
57
|
+
console.error(logMessage);
|
|
58
|
+
break;
|
|
59
|
+
case global_constants.LOG_LEVEL_WARNING:
|
|
60
|
+
console.warn(logMessage);
|
|
61
|
+
break;
|
|
62
|
+
case global_constants.LOG_LEVEL_INFO:
|
|
63
|
+
console.info(logMessage);
|
|
64
|
+
break;
|
|
65
|
+
case global_constants.LOG_LEVEL_DEBUG:
|
|
66
|
+
if (console.debug) {
|
|
67
|
+
console.debug(logMessage);
|
|
68
|
+
} else {
|
|
69
|
+
console.log(logMessage);
|
|
70
|
+
}
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
},
|
|
48
74
|
};
|
|
49
75
|
cmi;
|
|
50
76
|
startingData: {};
|
|
@@ -148,11 +174,11 @@ export default class BaseAPI {
|
|
|
148
174
|
|
|
149
175
|
const result = this.storeData(true);
|
|
150
176
|
if (!this.settings.sendBeaconCommit && !this.settings.asyncCommit &&
|
|
151
|
-
|
|
177
|
+
typeof result.errorCode !== 'undefined' && result.errorCode > 0) {
|
|
152
178
|
this.throwSCORMError(result.errorCode);
|
|
153
179
|
}
|
|
154
180
|
returnValue = (typeof result !== 'undefined' && result.result) ?
|
|
155
|
-
|
|
181
|
+
result.result : global_constants.SCORM_FALSE;
|
|
156
182
|
|
|
157
183
|
if (checkTerminated) this.lastErrorCode = 0;
|
|
158
184
|
|
|
@@ -185,7 +211,21 @@ export default class BaseAPI {
|
|
|
185
211
|
this.#error_codes.RETRIEVE_BEFORE_INIT,
|
|
186
212
|
this.#error_codes.RETRIEVE_AFTER_TERM)) {
|
|
187
213
|
if (checkTerminated) this.lastErrorCode = 0;
|
|
188
|
-
|
|
214
|
+
try {
|
|
215
|
+
returnValue = this.getCMIValue(CMIElement);
|
|
216
|
+
} catch (e) {
|
|
217
|
+
if (e instanceof ValidationError) {
|
|
218
|
+
this.lastErrorCode = e.errorCode;
|
|
219
|
+
returnValue = global_constants.SCORM_FALSE;
|
|
220
|
+
} else {
|
|
221
|
+
if (e.message) {
|
|
222
|
+
console.error(e.message);
|
|
223
|
+
} else {
|
|
224
|
+
console.error(e);
|
|
225
|
+
}
|
|
226
|
+
this.throwSCORMError(this.#error_codes.GENERAL);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
189
229
|
this.processListeners(callbackName, CMIElement);
|
|
190
230
|
}
|
|
191
231
|
|
|
@@ -275,11 +315,11 @@ export default class BaseAPI {
|
|
|
275
315
|
this.#error_codes.COMMIT_AFTER_TERM)) {
|
|
276
316
|
const result = this.storeData(false);
|
|
277
317
|
if (!this.settings.sendBeaconCommit && !this.settings.asyncCommit &&
|
|
278
|
-
|
|
318
|
+
result.errorCode && result.errorCode > 0) {
|
|
279
319
|
this.throwSCORMError(result.errorCode);
|
|
280
320
|
}
|
|
281
321
|
returnValue = (typeof result !== 'undefined' && result.result) ?
|
|
282
|
-
|
|
322
|
+
result.result : global_constants.SCORM_FALSE;
|
|
283
323
|
|
|
284
324
|
this.apiLog(callbackName, 'HttpRequest', ' Result: ' + returnValue,
|
|
285
325
|
global_constants.LOG_LEVEL_DEBUG);
|
|
@@ -393,24 +433,7 @@ export default class BaseAPI {
|
|
|
393
433
|
logMessage = this.formatMessage(functionName, CMIElement, logMessage);
|
|
394
434
|
|
|
395
435
|
if (messageLevel >= this.apiLogLevel) {
|
|
396
|
-
|
|
397
|
-
case global_constants.LOG_LEVEL_ERROR:
|
|
398
|
-
console.error(logMessage);
|
|
399
|
-
break;
|
|
400
|
-
case global_constants.LOG_LEVEL_WARNING:
|
|
401
|
-
console.warn(logMessage);
|
|
402
|
-
break;
|
|
403
|
-
case global_constants.LOG_LEVEL_INFO:
|
|
404
|
-
console.info(logMessage);
|
|
405
|
-
break;
|
|
406
|
-
case global_constants.LOG_LEVEL_DEBUG:
|
|
407
|
-
if (console.debug) {
|
|
408
|
-
console.debug(logMessage);
|
|
409
|
-
} else {
|
|
410
|
-
console.log(logMessage);
|
|
411
|
-
}
|
|
412
|
-
break;
|
|
413
|
-
}
|
|
436
|
+
this.settings.onLogMessage(messageLevel, logMessage);
|
|
414
437
|
}
|
|
415
438
|
}
|
|
416
439
|
|
|
@@ -475,9 +498,9 @@ export default class BaseAPI {
|
|
|
475
498
|
*/
|
|
476
499
|
_checkObjectHasProperty(refObject, attribute: String) {
|
|
477
500
|
return Object.hasOwnProperty.call(refObject, attribute) ||
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
501
|
+
Object.getOwnPropertyDescriptor(
|
|
502
|
+
Object.getPrototypeOf(refObject), attribute) ||
|
|
503
|
+
(attribute in refObject);
|
|
481
504
|
}
|
|
482
505
|
|
|
483
506
|
/**
|
|
@@ -541,21 +564,21 @@ export default class BaseAPI {
|
|
|
541
564
|
|
|
542
565
|
const invalidErrorMessage = `The data model element passed to ${methodName} (${CMIElement}) is not a valid SCORM data model element.`;
|
|
543
566
|
const invalidErrorCode = scorm2004 ?
|
|
544
|
-
|
|
545
|
-
|
|
567
|
+
this.#error_codes.UNDEFINED_DATA_MODEL :
|
|
568
|
+
this.#error_codes.GENERAL;
|
|
546
569
|
|
|
547
570
|
for (let i = 0; i < structure.length; i++) {
|
|
548
571
|
const attribute = structure[i];
|
|
549
572
|
|
|
550
573
|
if (i === structure.length - 1) {
|
|
551
574
|
if (scorm2004 && (attribute.substr(0, 8) === '{target=') &&
|
|
552
|
-
|
|
575
|
+
(typeof refObject._isTargetValid == 'function')) {
|
|
553
576
|
this.throwSCORMError(this.#error_codes.READ_ONLY_ELEMENT);
|
|
554
577
|
} else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
555
578
|
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
556
579
|
} else {
|
|
557
580
|
if (this.isInitialized() &&
|
|
558
|
-
|
|
581
|
+
this.stringMatches(CMIElement, '\\.correct_responses\\.\\d+')) {
|
|
559
582
|
this.validateCorrectResponse(CMIElement, value);
|
|
560
583
|
}
|
|
561
584
|
|
|
@@ -656,8 +679,8 @@ export default class BaseAPI {
|
|
|
656
679
|
const uninitializedErrorMessage = `The data model element passed to ${methodName} (${CMIElement}) has not been initialized.`;
|
|
657
680
|
const invalidErrorMessage = `The data model element passed to ${methodName} (${CMIElement}) is not a valid SCORM data model element.`;
|
|
658
681
|
const invalidErrorCode = scorm2004 ?
|
|
659
|
-
|
|
660
|
-
|
|
682
|
+
this.#error_codes.UNDEFINED_DATA_MODEL :
|
|
683
|
+
this.#error_codes.GENERAL;
|
|
661
684
|
|
|
662
685
|
for (let i = 0; i < structure.length; i++) {
|
|
663
686
|
attribute = structure[i];
|
|
@@ -671,9 +694,8 @@ export default class BaseAPI {
|
|
|
671
694
|
}
|
|
672
695
|
} else {
|
|
673
696
|
if ((String(attribute).substr(0, 8) === '{target=') &&
|
|
674
|
-
|
|
675
|
-
const target = String(attribute).
|
|
676
|
-
substr(8, String(attribute).length - 9);
|
|
697
|
+
(typeof refObject._isTargetValid == 'function')) {
|
|
698
|
+
const target = String(attribute).substr(8, String(attribute).length - 9);
|
|
677
699
|
return refObject._isTargetValid(target);
|
|
678
700
|
} else if (!this._checkObjectHasProperty(refObject, attribute)) {
|
|
679
701
|
this.throwSCORMError(invalidErrorCode, invalidErrorMessage);
|
|
@@ -803,7 +825,7 @@ export default class BaseAPI {
|
|
|
803
825
|
const removeIndex = this.listenerArray.findIndex((obj) =>
|
|
804
826
|
obj.functionName === functionName &&
|
|
805
827
|
obj.CMIElement === CMIElement &&
|
|
806
|
-
obj.callback === callback
|
|
828
|
+
obj.callback === callback,
|
|
807
829
|
);
|
|
808
830
|
if (removeIndex !== -1) {
|
|
809
831
|
this.listenerArray.splice(removeIndex, 1);
|
|
@@ -852,8 +874,8 @@ export default class BaseAPI {
|
|
|
852
874
|
const listenerHasCMIElement = !!listener.CMIElement;
|
|
853
875
|
let CMIElementsMatch = false;
|
|
854
876
|
if (CMIElement && listener.CMIElement &&
|
|
855
|
-
|
|
856
|
-
|
|
877
|
+
listener.CMIElement.substring(listener.CMIElement.length - 1) ===
|
|
878
|
+
'*') {
|
|
857
879
|
CMIElementsMatch = CMIElement.indexOf(listener.CMIElement.substring(0,
|
|
858
880
|
listener.CMIElement.length - 1)) === 0;
|
|
859
881
|
} else {
|
|
@@ -1078,6 +1100,15 @@ export default class BaseAPI {
|
|
|
1078
1100
|
if (!settings.sendBeaconCommit) {
|
|
1079
1101
|
const httpReq = new XMLHttpRequest();
|
|
1080
1102
|
httpReq.open('POST', url, settings.asyncCommit);
|
|
1103
|
+
|
|
1104
|
+
if (Object.keys(settings.xhrHeaders).length) {
|
|
1105
|
+
Object.keys(settings.xhrHeaders).forEach((header) => {
|
|
1106
|
+
httpReq.setRequestHeader(header, settings.xhrHeaders[header]);
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
httpReq.withCredentials = settings.xhrWithCredentials;
|
|
1111
|
+
|
|
1081
1112
|
if (settings.asyncCommit) {
|
|
1082
1113
|
httpReq.onload = function(e) {
|
|
1083
1114
|
if (typeof settings.responseHandler === 'function') {
|
|
@@ -1088,6 +1119,7 @@ export default class BaseAPI {
|
|
|
1088
1119
|
};
|
|
1089
1120
|
}
|
|
1090
1121
|
try {
|
|
1122
|
+
params = settings.requestHandler(params);
|
|
1091
1123
|
if (params instanceof Array) {
|
|
1092
1124
|
httpReq.setRequestHeader('Content-Type',
|
|
1093
1125
|
'application/x-www-form-urlencoded');
|
|
@@ -1149,7 +1181,7 @@ export default class BaseAPI {
|
|
|
1149
1181
|
}
|
|
1150
1182
|
|
|
1151
1183
|
if (result.result === true ||
|
|
1152
|
-
|
|
1184
|
+
result.result === global_constants.SCORM_TRUE) {
|
|
1153
1185
|
api.processListeners('CommitSuccess');
|
|
1154
1186
|
} else {
|
|
1155
1187
|
api.processListeners('CommitError');
|