fcad-core-dragon 2.0.0-beta.4 → 2.0.0-beta.6

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.
Files changed (96) hide show
  1. package/.editorconfig +33 -33
  2. package/.eslintignore +29 -29
  3. package/.eslintrc.cjs +81 -81
  4. package/CHANGELOG +19 -0
  5. package/README.md +71 -71
  6. package/bk.scss +117 -117
  7. package/package.json +8 -8
  8. package/src/$locales/en.json +23 -23
  9. package/src/$locales/fr.json +22 -21
  10. package/src/assets/data/onboardingMessages.json +47 -47
  11. package/src/components/AppBase.vue +186 -116
  12. package/src/components/AppBaseButton.test.js +22 -0
  13. package/src/components/AppBaseButton.vue +13 -5
  14. package/src/components/AppBaseErrorDisplay.vue +438 -438
  15. package/src/components/AppBaseFlipCard.vue +84 -84
  16. package/src/components/AppBaseModule.vue +207 -128
  17. package/src/components/AppBasePage.vue +18 -45
  18. package/src/components/AppBasePopover.vue +41 -41
  19. package/src/components/AppCompAudio.vue +20 -17
  20. package/src/components/AppCompBranchButtons.vue +28 -70
  21. package/src/components/AppCompButtonProgress.vue +4 -9
  22. package/src/components/AppCompCarousel.vue +120 -90
  23. package/src/components/{AppCompTranscript.vue → AppCompContainer.vue} +8 -1
  24. package/src/components/AppCompInputCheckBoxNext.vue +5 -0
  25. package/src/components/AppCompInputDropdownNext.vue +50 -8
  26. package/src/components/AppCompInputRadioNext.vue +152 -152
  27. package/src/components/AppCompInputTextNext.vue +21 -2
  28. package/src/components/AppCompInputTextTableNext.vue +1 -0
  29. package/src/components/AppCompInputTextToFillDropdownNext.vue +8 -0
  30. package/src/components/AppCompInputTextToFillNext.vue +171 -171
  31. package/src/components/AppCompJauge.vue +74 -74
  32. package/src/components/AppCompMenu.vue +13 -7
  33. package/src/components/AppCompMenuItem.vue +228 -228
  34. package/src/components/AppCompNavigation.vue +43 -30
  35. package/src/components/AppCompNoteCall.vue +64 -38
  36. package/src/components/AppCompNoteCredit.vue +303 -105
  37. package/src/components/AppCompPlayBarNext.vue +25 -12
  38. package/src/components/AppCompPlayBarProgress.vue +82 -82
  39. package/src/components/AppCompPopUpNext.vue +1 -4
  40. package/src/components/AppCompQuizNext.vue +8 -4
  41. package/src/components/AppCompQuizRecall.vue +44 -22
  42. package/src/components/AppCompSVGNext.vue +2 -3
  43. package/src/components/AppCompSettingsMenu.vue +172 -172
  44. package/src/components/AppCompTableOfContent.vue +61 -62
  45. package/src/components/AppCompVideoPlayer.vue +17 -15
  46. package/src/components/AppCompViewDisplay.vue +6 -6
  47. package/src/components/BaseModule.vue +1 -18
  48. package/src/components/tests__/AppBaseButton.spec.js +53 -0
  49. package/src/composables/useQuiz.js +206 -206
  50. package/src/externalComps/ModuleView.vue +22 -22
  51. package/src/externalComps/SummaryView.vue +91 -91
  52. package/src/main.js +37 -32
  53. package/src/mixins/$mediaMixins.js +819 -819
  54. package/src/mixins/timerMixin.js +155 -155
  55. package/src/module/stores/appStore.js +59 -6
  56. package/src/module/xapi/ADL.js +144 -4
  57. package/src/module/xapi/Crypto/Hasher.js +241 -241
  58. package/src/module/xapi/Crypto/WordArray.js +278 -278
  59. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
  60. package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -315
  61. package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
  62. package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
  63. package/src/module/xapi/Crypto/encoders/Base.js +105 -105
  64. package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
  65. package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
  66. package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
  67. package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
  68. package/src/module/xapi/Crypto/index.js +53 -53
  69. package/src/module/xapi/Statement/activity.js +47 -47
  70. package/src/module/xapi/Statement/agent.js +55 -55
  71. package/src/module/xapi/Statement/group.js +26 -26
  72. package/src/module/xapi/Statement/index.js +259 -259
  73. package/src/module/xapi/Statement/statement.js +253 -253
  74. package/src/module/xapi/Statement/statementRef.js +23 -23
  75. package/src/module/xapi/Statement/substatement.js +22 -22
  76. package/src/module/xapi/Statement/verb.js +36 -36
  77. package/src/module/xapi/activitytypes.js +17 -17
  78. package/src/module/xapi/utils.js +167 -167
  79. package/src/module/xapi/verbs.js +294 -294
  80. package/src/module/xapi/wrapper copy.js +1963 -0
  81. package/src/module/xapi/wrapper.js +121 -188
  82. package/src/module/xapi/xapiStatement.js +444 -444
  83. package/src/plugins/bus.js +8 -8
  84. package/src/plugins/gsap.js +14 -14
  85. package/src/plugins/helper.js +52 -12
  86. package/src/plugins/i18n.js +44 -44
  87. package/src/plugins/save.js +37 -37
  88. package/src/plugins/scorm.js +287 -287
  89. package/src/plugins/xapi.js +11 -11
  90. package/src/public/index.html +33 -33
  91. package/src/router/index.js +8 -2
  92. package/src/router/routes.js +312 -312
  93. package/src/shared/generalfuncs.js +210 -210
  94. package/src/shared/validators.js +38 -179
  95. package/vitest.config.js +19 -0
  96. package/src/components/AppCompPlayBar.vue +0 -1218
@@ -201,7 +201,7 @@ export function xapiwrapper(ADL) {
201
201
  function (r) {
202
202
  if (r.status == 200) {
203
203
  try {
204
- let lrsabout = JSON.parse(r.response)
204
+ let lrsabout = r.json()
205
205
  let versionOK = false
206
206
  for (let idx in lrsabout.version) {
207
207
  if (lrsabout.version.hasOwnProperty(idx))
@@ -384,7 +384,7 @@ export function xapiwrapper(ADL) {
384
384
  this.withCredentials,
385
385
  this.strictCallbacks
386
386
  )
387
- if (!callback) return { xhr: resp, id: id }
387
+ if (!callback) return { xhr: resp[0], id: id }
388
388
  }
389
389
  }
390
390
 
@@ -632,26 +632,14 @@ export function xapiwrapper(ADL) {
632
632
  for (let i in stmtArray) {
633
633
  if (stmtArray.hasOwnProperty(i)) this.prepareStatement(stmtArray[i])
634
634
  }
635
- // let resp = ADL.XHR_request(
636
- // this.lrs,
637
- // this.lrs.endpoint + 'statements',
638
- // 'POST',
639
- // JSON.stringify(stmtArray),
640
- // this.lrs.auth,
641
- // callback,
642
- // null,
643
- // false,
644
- // null,
645
- // this.withCredentials,
646
- // this.strictCallbacks
647
- // )
648
- //=============================================
635
+
649
636
  let headers = {}
650
637
  headers['Content-type'] = 'application/json; charset=UTF-8'
651
638
  headers['Authorization'] = this.lrs.auth
652
639
  headers['X-Experience-API-Version'] = ADL.XAPIWrapper.xapiVersion
653
640
 
654
641
  let payload = JSON.stringify(stmtArray)
642
+
655
643
  // fecth API used to allow the delivery of the request after the browser is closed
656
644
  let resp = await fetch(this.lrs.endpoint + 'statements', {
657
645
  method: 'POST',
@@ -669,7 +657,7 @@ export function xapiwrapper(ADL) {
669
657
 
670
658
  /*
671
659
  * Get statement(s) based on the searchparams or more url.
672
- * @param {object} searchparams an ADL.XAPIWrapper.searchParams object of
660
+ * @param {object || array } searchparams an ADL.XAPIWrapper.searchParams object of
673
661
  * key(search parameter)-value(parameter value) pairs.
674
662
  * Example:
675
663
  * let myparams = ADL.XAPIWrapper.searchParams();
@@ -694,28 +682,41 @@ export function xapiwrapper(ADL) {
694
682
  more,
695
683
  callback
696
684
  ) {
685
+ const listSearchParams = []
686
+
687
+ searchparams.constructor == Array
688
+ ? listSearchParams.push(...searchparams)
689
+ : listSearchParams.push(searchparams)
690
+
697
691
  if (this.testConfig()) {
698
692
  let url = this.lrs.endpoint + 'statements'
693
+ const URLS = []
699
694
  if (more) {
700
695
  url = this.base + more
701
696
  } else {
702
- let urlparams = new Array()
703
-
704
- for (let s in searchparams) {
705
- if (searchparams.hasOwnProperty(s)) {
706
- if (s == 'until' || s == 'since') {
707
- let d = new Date(searchparams[s])
708
- urlparams.push(s + '=' + encodeURIComponent(d.toISOString()))
709
- } else {
710
- urlparams.push(s + '=' + encodeURIComponent(searchparams[s]))
697
+ for (let searchparams of listSearchParams) {
698
+ let urlparams = new Array()
699
+ let _urls = url
700
+ for (let s in searchparams) {
701
+ if (searchparams.hasOwnProperty(s)) {
702
+ if (s == 'until' || s == 'since') {
703
+ let d = new Date(searchparams[s])
704
+ urlparams.push(s + '=' + encodeURIComponent(d.toISOString()))
705
+ } else {
706
+ urlparams.push(s + '=' + encodeURIComponent(searchparams[s]))
707
+ }
711
708
  }
712
709
  }
710
+ if (urlparams.length > 0) {
711
+ _urls = _urls + '?' + urlparams.join('&')
712
+ }
713
+ URLS.push(_urls)
713
714
  }
714
- if (urlparams.length > 0) url = url + '?' + urlparams.join('&')
715
715
  }
716
+
716
717
  let res = await ADL.XHR_request(
717
718
  this.lrs,
718
- url,
719
+ URLS,
719
720
  'GET',
720
721
  null,
721
722
  this.lrs.auth,
@@ -732,9 +733,9 @@ export function xapiwrapper(ADL) {
732
733
  }
733
734
 
734
735
  try {
735
- return JSON.parse(res.response)
736
+ return await res
736
737
  } catch (e) {
737
- return res.response
738
+ return e
738
739
  }
739
740
  }
740
741
  }
@@ -751,7 +752,7 @@ export function xapiwrapper(ADL) {
751
752
  * ADL.XAPIWrapper.log(res);
752
753
  * >> <Activity object>
753
754
  */
754
- XAPIWrapper.prototype.getActivities = function (activityid, callback) {
755
+ XAPIWrapper.prototype.getActivities = async function (activityid, callback) {
755
756
  if (this.testConfig()) {
756
757
  let url = this.lrs.endpoint + 'activities?activityId=<activityid>'
757
758
  url = url.replace('<activityid>', encodeURIComponent(activityid))
@@ -775,9 +776,9 @@ export function xapiwrapper(ADL) {
775
776
  }
776
777
 
777
778
  try {
778
- return JSON.parse(result.response)
779
+ return await result[0].json()
779
780
  } catch (e) {
780
- return result.response
781
+ return result
781
782
  }
782
783
  }
783
784
  }
@@ -887,7 +888,7 @@ export function xapiwrapper(ADL) {
887
888
  * {"mbox":"mailto:tom@example.com"}, "questionstate");
888
889
  * >> {info: "the state info"}
889
890
  */
890
- XAPIWrapper.prototype.getState = function (
891
+ XAPIWrapper.prototype.getState = async function (
891
892
  activityid,
892
893
  agent,
893
894
  stateid,
@@ -937,9 +938,9 @@ export function xapiwrapper(ADL) {
937
938
  }
938
939
 
939
940
  try {
940
- return JSON.parse(result.response)
941
+ return await result[0].json()
941
942
  } catch (e) {
942
- return result.response
943
+ return e
943
944
  }
944
945
  }
945
946
  }
@@ -973,7 +974,7 @@ export function xapiwrapper(ADL) {
973
974
  * {"mbox":"mailto:tom@example.com"}, "questionstate");
974
975
  * >> 404
975
976
  */
976
- XAPIWrapper.prototype.deleteState = function (
977
+ XAPIWrapper.prototype.deleteState = async function (
977
978
  activityid,
978
979
  agent,
979
980
  stateid,
@@ -1023,7 +1024,7 @@ export function xapiwrapper(ADL) {
1023
1024
  }
1024
1025
 
1025
1026
  try {
1026
- return JSON.parse(result.response)
1027
+ return await result[0].json()
1027
1028
  } catch (e) {
1028
1029
  return result
1029
1030
  }
@@ -1123,7 +1124,7 @@ export function xapiwrapper(ADL) {
1123
1124
  * function(r){ADL.XAPIWrapper.log(JSON.parse(r.response));});
1124
1125
  * >> {info: "the profile"}
1125
1126
  */
1126
- XAPIWrapper.prototype.getActivityProfile = function (
1127
+ XAPIWrapper.prototype.getActivityProfile = async function (
1127
1128
  activityid,
1128
1129
  profileid,
1129
1130
  since,
@@ -1165,9 +1166,9 @@ export function xapiwrapper(ADL) {
1165
1166
  }
1166
1167
 
1167
1168
  try {
1168
- return JSON.parse(result.response)
1169
+ return result[0].json()
1169
1170
  } catch (e) {
1170
- return result.response
1171
+ return result
1171
1172
  }
1172
1173
  }
1173
1174
  }
@@ -1187,7 +1188,7 @@ export function xapiwrapper(ADL) {
1187
1188
  * "actprofile");
1188
1189
  * >> XMLHttpRequest {statusText: "NO CONTENT", status: 204, response: "", responseType: "", responseXML: null…}
1189
1190
  */
1190
- XAPIWrapper.prototype.deleteActivityProfile = function (
1191
+ XAPIWrapper.prototype.deleteActivityProfile = async function (
1191
1192
  activityid,
1192
1193
  profileid,
1193
1194
  matchHash,
@@ -1230,7 +1231,7 @@ export function xapiwrapper(ADL) {
1230
1231
  }
1231
1232
 
1232
1233
  try {
1233
- return JSON.parse(result.response)
1234
+ return result[0].json()
1234
1235
  } catch (e) {
1235
1236
  return result
1236
1237
  }
@@ -1251,7 +1252,7 @@ export function xapiwrapper(ADL) {
1251
1252
  * ADL.XAPIWrapper.log(res);
1252
1253
  * >> <Person object>
1253
1254
  */
1254
- XAPIWrapper.prototype.getAgents = function (agent, callback) {
1255
+ XAPIWrapper.prototype.getAgents = async function (agent, callback) {
1255
1256
  if (this.testConfig()) {
1256
1257
  let url = this.lrs.endpoint + 'agents?agent=<agent>'
1257
1258
  url = url.replace('<agent>', encodeURIComponent(JSON.stringify(agent)))
@@ -1275,9 +1276,9 @@ export function xapiwrapper(ADL) {
1275
1276
  }
1276
1277
 
1277
1278
  try {
1278
- return JSON.parse(result.response)
1279
+ return result[0].json()
1279
1280
  } catch (e) {
1280
- return result.response
1281
+ return result
1281
1282
  }
1282
1283
  }
1283
1284
  }
@@ -1374,7 +1375,7 @@ export function xapiwrapper(ADL) {
1374
1375
  * function(r){ADL.XAPIWrapper.log(JSON.parse(r.response));});
1375
1376
  * >> {info: "the agent profile"}
1376
1377
  */
1377
- XAPIWrapper.prototype.getAgentProfile = function (
1378
+ XAPIWrapper.prototype.getAgentProfile = async function (
1378
1379
  agent,
1379
1380
  profileid,
1380
1381
  since,
@@ -1416,7 +1417,7 @@ export function xapiwrapper(ADL) {
1416
1417
  }
1417
1418
 
1418
1419
  try {
1419
- return JSON.parse(result.response)
1420
+ return result[0].json()
1420
1421
  } catch (e) {
1421
1422
  return result.response
1422
1423
  }
@@ -1438,7 +1439,7 @@ export function xapiwrapper(ADL) {
1438
1439
  * "agentprofile");
1439
1440
  * >> XMLHttpRequest {statusText: "NO CONTENT", status: 204, response: "", responseType: "", responseXML: null…}
1440
1441
  */
1441
- XAPIWrapper.prototype.deleteAgentProfile = function (
1442
+ XAPIWrapper.prototype.deleteAgentProfile = async function (
1442
1443
  agent,
1443
1444
  profileid,
1444
1445
  matchHash,
@@ -1480,7 +1481,7 @@ export function xapiwrapper(ADL) {
1480
1481
  }
1481
1482
 
1482
1483
  try {
1483
- return JSON.parse(result.response)
1484
+ return result[0].json()
1484
1485
  } catch (e) {
1485
1486
  return result
1486
1487
  }
@@ -1712,7 +1713,7 @@ export function xapiwrapper(ADL) {
1712
1713
  /*
1713
1714
  * makes a request to a server (if possible, use functions provided in XAPIWrapper)
1714
1715
  * @param {string} lrs the lrs connection info, such as endpoint, auth, etc
1715
- * @param {string} url the url of this request
1716
+ * @param {string | Array } urls the url of this request
1716
1717
  * @param {string} method the http request method
1717
1718
  * @param {string} data the payload
1718
1719
  * @param {string} auth the value for the Authorization header
@@ -1723,11 +1724,12 @@ export function xapiwrapper(ADL) {
1723
1724
  * @param {object} extraHeaders other header key-values to be added to this request
1724
1725
  * @param {boolean} withCredentials
1725
1726
  * @param {boolean} strictCallbacks Callback must be executed and first param is error or null if no error
1726
- * @return {object} xhr response object
1727
+ * @return {Objec} containing the status of last promise request and Array of the responses;
1727
1728
  */
1729
+
1728
1730
  ADL.XHR_request = function (
1729
1731
  lrs,
1730
- url,
1732
+ urls,
1731
1733
  method,
1732
1734
  data,
1733
1735
  auth,
@@ -1739,170 +1741,101 @@ export function xapiwrapper(ADL) {
1739
1741
  strictCallbacks
1740
1742
  ) {
1741
1743
  'use strict'
1744
+ let URLList = urls.constructor == Array ? [...urls] : [urls]
1745
+ // Consolidate headers
1746
+ let headers = {
1747
+ 'Content-Type': 'application/json',
1748
+ Authorization: auth,
1749
+ 'X-Experience-API-Version': ADL.XAPIWrapper.xapiVersion
1750
+ }
1742
1751
 
1743
- let xhr,
1744
- finished = false,
1745
- xDomainRequest = false,
1746
- ieXDomain = false,
1747
- ieModeRequest,
1748
- urlparts = url.toLowerCase().match(/^(.+):\/\/([^:/]*):?(\d+)?(\/.*)?$/),
1749
- location = window.location,
1750
- urlPort,
1751
- result,
1752
- extended,
1753
- prop,
1754
- until
1755
-
1756
- //Consolidate headers
1757
- let headers = {}
1758
- headers['Content-Type'] = 'application/json'
1759
- headers['Authorization'] = auth
1760
- headers['X-Experience-API-Version'] = ADL.XAPIWrapper.xapiVersion
1761
1752
  if (extraHeaders !== null) {
1762
1753
  for (let headerName in extraHeaders) {
1763
- if (extraHeaders.hasOwnProperty(headerName))
1754
+ if (extraHeaders.hasOwnProperty(headerName)) {
1764
1755
  headers[headerName] = extraHeaders[headerName]
1756
+ }
1765
1757
  }
1766
1758
  }
1767
1759
 
1768
- //See if this really is a cross domain
1769
- xDomainRequest =
1770
- location.protocol.toLowerCase() !== urlparts[1] ||
1771
- location.hostname.toLowerCase() !== urlparts[2]
1772
- if (!xDomainRequest) {
1773
- urlPort =
1774
- urlparts[3] === null
1775
- ? urlparts[1] === 'http'
1776
- ? '80'
1777
- : '443'
1778
- : urlparts[3]
1779
- xDomainRequest = urlPort === location.port
1780
- }
1781
-
1782
- //Add extended LMS-specified values to the URL
1760
+ // Add extended LMS-specified values to the URL
1783
1761
  if (lrs !== null && lrs.extended !== undefined) {
1784
- extended = new Array()
1785
- for (prop in lrs.extended) {
1762
+ let extended = []
1763
+ for (let prop in lrs.extended) {
1786
1764
  extended.push(prop + '=' + encodeURIComponent(lrs.extended[prop]))
1787
1765
  }
1788
1766
  if (extended.length > 0) {
1789
- url += (url.indexOf('?') > -1 ? '&' : '?') + extended.join('&')
1767
+ URLList.map(
1768
+ (url) =>
1769
+ (url += (url.indexOf('?') > -1 ? '&' : '?') + extended.join('&'))
1770
+ )
1790
1771
  }
1791
1772
  }
1773
+ let requestArray = []
1792
1774
 
1793
- //If it's not cross domain or we're not using IE, use the usual XmlHttpRequest
1794
- let windowsVersionCheck =
1795
- window.XDomainRequest &&
1796
- window.XMLHttpRequest &&
1797
- new XMLHttpRequest().responseType === undefined
1798
- if (
1799
- !xDomainRequest ||
1800
- windowsVersionCheck === undefined ||
1801
- windowsVersionCheck === false
1802
- ) {
1803
- xhr = new XMLHttpRequest()
1804
- xhr.withCredentials = withCredentials //allow cross domain cookie based auth
1805
- xhr.open(method, url, callback != null)
1806
- for (let headerName in headers) {
1807
- xhr.setRequestHeader(headerName, headers[headerName])
1775
+ for (const url of URLList) {
1776
+ // Prepare request options for fetch
1777
+ const fetchOptions = {
1778
+ method: method,
1779
+ headers: headers,
1780
+ body: data ? JSON.stringify(data) : null,
1781
+ credentials: withCredentials ? 'include' : 'same-origin'
1808
1782
  }
1809
- }
1810
- //Otherwise, use IE's XDomainRequest object
1811
- else {
1812
- ieXDomain = true
1813
- // ieModeRequest = ie_request(method, url, headers, data)
1814
- // xhr = new XDomainRequest()
1815
- xhr.open(ieModeRequest.method, ieModeRequest.url)
1783
+ requestArray.push(fetch(url, fetchOptions))
1816
1784
  }
1817
1785
 
1818
- //Setup request callback
1819
- function requestComplete() {
1820
- if (!finished) {
1821
- // may be in sync or async mode, using XMLHttpRequest or IE XDomainRequest, onreadystatechange or
1822
- // onload or both might fire depending upon browser, just covering all bases with event hooks and
1823
- // using 'finished' flag to avoid triggering events multiple times
1824
- finished = true
1825
- let notFoundOk = ignore404 && xhr.status === 404
1826
- if (
1827
- xhr.status === undefined ||
1828
- (xhr.status >= 200 && xhr.status < 400) ||
1829
- notFoundOk
1830
- ) {
1831
- if (callback) {
1832
- if (callbackargs) {
1833
- strictCallbacks
1834
- ? callback(null, xhr, callbackargs)
1835
- : callback(xhr, callbackargs)
1836
- } else {
1837
- let body
1838
-
1839
- try {
1840
- body = JSON.parse(xhr.responseText)
1841
- } catch (e) {
1842
- body = xhr.responseText
1843
- }
1786
+ // If no callback, we assume synchronous mode (using Promise)
1787
+ const makeRequest = async (requests) => {
1788
+ try {
1789
+ const response = await Promise.all(requests)
1790
+ const status = response[response.length - 1].status
1791
+ let body
1844
1792
 
1845
- strictCallbacks ? callback(null, xhr, body) : callback(xhr, body)
1846
- }
1847
- } else {
1848
- result = xhr
1849
- return xhr
1850
- }
1793
+ if (status === 404 && ignore404) {
1794
+ // If we are ignoring 404s
1795
+ body = null
1796
+ } else if (status >= 200 && status < 400) {
1797
+ // Successful response
1798
+ body = await response
1851
1799
  } else {
1852
- let warning
1853
- try {
1854
- warning =
1855
- 'There was a problem communicating with the Learning Record Store. ( ' +
1856
- xhr.status +
1857
- ' | ' +
1858
- xhr.response +
1859
- ' )' +
1860
- url
1861
- } catch (ex) {
1862
- warning = ex.toString()
1863
- }
1864
- ADL.XAPIWrapper.log(warning)
1865
- ADL.xhrRequestOnError(
1866
- xhr,
1867
- method,
1868
- url,
1869
- callback,
1870
- callbackargs,
1871
- strictCallbacks
1800
+ throw new Error(
1801
+ `There was a problem communicating with the Learning Record Store. (${status} | ${response.statusText}) ${urls}`
1872
1802
  )
1873
- result = xhr
1874
- return xhr
1875
1803
  }
1876
- } else {
1877
- return result
1878
- }
1879
- }
1880
1804
 
1881
- xhr.onreadystatechange = function () {
1882
- if (xhr.readyState === 4) {
1883
- return requestComplete()
1805
+ // Callback handling
1806
+ if (callback) {
1807
+ if (strictCallbacks) {
1808
+ callback(null, response, body, status)
1809
+ } else {
1810
+ callback(response, body, status)
1811
+ }
1812
+ }
1813
+ return { response, status }
1814
+ } catch (error) {
1815
+ // Log error to the console or call error handler
1816
+ ADL.XAPIWrapper.log(error.toString())
1817
+ if (callback) {
1818
+ if (strictCallbacks) {
1819
+ callback(error, null, callbackargs)
1820
+ } else {
1821
+ callback(null, callbackargs)
1822
+ }
1823
+ }
1824
+ return null
1884
1825
  }
1885
1826
  }
1886
1827
 
1887
- xhr.onload = requestComplete
1888
- xhr.onerror = requestComplete
1889
- //xhr.onerror = ADL.xhrRequestOnError(xhr, method, url);
1890
-
1891
- xhr.send(ieXDomain ? ieModeRequest.data : data)
1892
-
1893
1828
  if (!callback) {
1894
- // synchronous
1895
- if (ieXDomain) {
1896
- // synchronous call in IE, with no asynchronous mode available.
1897
- until = 1000 + new Date()
1898
- while (new Date() < until && xhr.readyState !== 4 && !finished) {
1899
- delay()
1900
- }
1901
- }
1902
- return requestComplete()
1829
+ // If no callback, we return the Promise (synchronous behavior)
1830
+ return makeRequest(requestArray)
1903
1831
  }
1832
+
1833
+ // If there's a callback, proceed with asynchronous request
1834
+ makeRequest(requestArray)
1904
1835
  }
1905
1836
 
1837
+ //====================================================================
1838
+
1906
1839
  /*
1907
1840
  * Holder for custom global error callback
1908
1841
  * @param {object} xhr xhr object or null