fcad-core-dragon 2.0.0-beta.1 → 2.0.0-beta.3

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 (118) hide show
  1. package/.editorconfig +33 -33
  2. package/.eslintignore +29 -29
  3. package/{.eslintrc.js → .eslintrc.cjs} +81 -86
  4. package/CHANGELOG +364 -364
  5. package/README.md +71 -71
  6. package/bk.scss +117 -0
  7. package/package.json +61 -63
  8. package/src/$locales/en.json +143 -179
  9. package/src/$locales/fr.json +105 -181
  10. package/src/assets/data/onboardingMessages.json +47 -47
  11. package/src/components/AppBase.vue +1054 -614
  12. package/src/components/AppBaseButton.vue +87 -63
  13. package/src/components/AppBaseErrorDisplay.vue +438 -420
  14. package/src/components/AppBaseFlipCard.vue +84 -83
  15. package/src/components/AppBaseModule.vue +1673 -1842
  16. package/src/components/AppBasePage.vue +779 -312
  17. package/src/components/AppBasePopover.vue +41 -0
  18. package/src/components/AppCompAudio.vue +234 -0
  19. package/src/components/AppCompBranchButtons.vue +552 -582
  20. package/src/components/AppCompButtonProgress.vue +126 -147
  21. package/src/components/AppCompCarousel.vue +298 -192
  22. package/src/components/AppCompInputCheckBoxNext.vue +195 -0
  23. package/src/components/AppCompInputDropdownNext.vue +159 -0
  24. package/src/components/AppCompInputRadioNext.vue +152 -0
  25. package/src/components/{AppCompInputTextBox.vue → AppCompInputTextNext.vue} +106 -91
  26. package/src/components/AppCompInputTextTableNext.vue +141 -0
  27. package/src/components/AppCompInputTextToFillDropdownNext.vue +230 -0
  28. package/src/components/{AppCompInputTextToFillText.vue → AppCompInputTextToFillNext.vue} +171 -164
  29. package/src/components/AppCompJauge.vue +74 -55
  30. package/src/components/AppCompMenu.vue +413 -209
  31. package/src/components/AppCompMenuItem.vue +228 -174
  32. package/src/components/AppCompNavigation.vue +960 -949
  33. package/src/components/AppCompNoteCall.vue +133 -126
  34. package/src/components/AppCompNoteCredit.vue +292 -164
  35. package/src/components/AppCompPlayBar.vue +1218 -1319
  36. package/src/components/AppCompPlayBarNext.vue +2052 -0
  37. package/src/components/AppCompPlayBarProgress.vue +82 -0
  38. package/src/components/AppCompPopUpNext.vue +503 -0
  39. package/src/components/{AppCompQuiz.vue → AppCompQuizNext.vue} +2904 -2989
  40. package/src/components/AppCompQuizRecall.vue +276 -250
  41. package/src/components/AppCompSVGNext.vue +347 -0
  42. package/src/components/AppCompSettingsMenu.vue +172 -171
  43. package/src/components/AppCompTableOfContent.vue +387 -264
  44. package/src/components/AppCompTranscript.vue +24 -19
  45. package/src/components/AppCompVideoPlayer.vue +368 -336
  46. package/src/components/AppCompViewDisplay.vue +6 -6
  47. package/src/components/BaseModule.vue +72 -67
  48. package/src/composables/useQuiz.js +206 -0
  49. package/src/externalComps/ModuleView.vue +22 -0
  50. package/src/externalComps/SummaryView.vue +91 -0
  51. package/src/main.js +272 -227
  52. package/src/mixins/$mediaMixins.js +819 -0
  53. package/src/mixins/timerMixin.js +155 -156
  54. package/src/module/stores/appStore.js +893 -0
  55. package/src/module/xapi/ADL.js +376 -339
  56. package/src/module/xapi/Crypto/Hasher.js +241 -241
  57. package/src/module/xapi/Crypto/WordArray.js +278 -278
  58. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
  59. package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -319
  60. package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
  61. package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
  62. package/src/module/xapi/Crypto/encoders/Base.js +105 -105
  63. package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
  64. package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
  65. package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
  66. package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
  67. package/src/module/xapi/Crypto/index.js +53 -53
  68. package/src/module/xapi/Statement/activity.js +47 -47
  69. package/src/module/xapi/Statement/agent.js +55 -55
  70. package/src/module/xapi/Statement/group.js +26 -26
  71. package/src/module/xapi/Statement/index.js +259 -259
  72. package/src/module/xapi/Statement/statement.js +253 -253
  73. package/src/module/xapi/Statement/statementRef.js +23 -23
  74. package/src/module/xapi/Statement/substatement.js +22 -22
  75. package/src/module/xapi/Statement/verb.js +36 -36
  76. package/src/module/xapi/activitytypes.js +17 -17
  77. package/src/module/xapi/launch.js +157 -157
  78. package/src/module/xapi/utils.js +167 -167
  79. package/src/module/xapi/verbs.js +294 -294
  80. package/src/module/xapi/wrapper.js +1963 -1890
  81. package/src/module/xapi/xapiStatement.js +444 -444
  82. package/src/plugins/bus.js +8 -3
  83. package/src/plugins/gsap.js +14 -17
  84. package/src/plugins/helper.js +308 -295
  85. package/src/plugins/i18n.js +44 -31
  86. package/src/plugins/idb.js +219 -212
  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 -21
  91. package/src/router/index.js +43 -41
  92. package/src/router/routes.js +312 -337
  93. package/src/shared/generalfuncs.js +210 -188
  94. package/src/shared/validators.js +1069 -249
  95. package/vite.config.js +27 -0
  96. package/.prettierrc.js +0 -5
  97. package/babel.config.js +0 -3
  98. package/src/components/AppBaseDragChoice.vue +0 -91
  99. package/src/components/AppBaseDropZone.vue +0 -112
  100. package/src/components/AppCompBif.vue +0 -120
  101. package/src/components/AppCompDragAndDrop.vue +0 -339
  102. package/src/components/AppCompInputAssociation.vue +0 -332
  103. package/src/components/AppCompInputCheckBox.vue +0 -227
  104. package/src/components/AppCompInputDropdown.vue +0 -184
  105. package/src/components/AppCompInputRadio.vue +0 -169
  106. package/src/components/AppCompInputTextTable.vue +0 -155
  107. package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
  108. package/src/components/AppCompMediaPlayer.vue +0 -397
  109. package/src/components/AppCompPopUp.vue +0 -522
  110. package/src/components/AppCompPopover.vue +0 -27
  111. package/src/components/AppCompSVG.vue +0 -309
  112. package/src/mixins/$pageMixins.js +0 -459
  113. package/src/mixins/$quizMixins.js +0 -456
  114. package/src/module/store.js +0 -895
  115. package/src/plugins/timeManager.js +0 -77
  116. package/src/routes_bckp.js +0 -313
  117. package/src/routes_static.js +0 -344
  118. package/vue.config.js +0 -83
@@ -1,895 +0,0 @@
1
- import Vue from 'vue'
2
-
3
- const thisModule = {} /* */
4
- const state = {
5
- status: '',
6
- anchorStatus: null,
7
- thisModule,
8
- currentActivity: null,
9
- currentPage: null,
10
- currentBranchPage: null,
11
- currentBranching: null,
12
- currentSection: null,
13
- currentPageMediaElement: null,
14
- currentMediaDuration: null,
15
- currentPageTimeline: null,
16
- bookmark: null,
17
- currentBrowser: null,
18
- isMobile: null,
19
- deviceType: null,
20
- introAcitve: null,
21
- userMetaData: {},
22
- appConfigs: null,
23
- menuSetting: null,
24
- applicationSettings: {},
25
- routeHistory: null,
26
- mediaVolume: 1,
27
- mediaSubtitles: false,
28
- showPrimaryCtrl: true,
29
- showNavLeftCtrl: true,
30
- showNavRightCtrl: true,
31
- prevActivity: null,
32
- nextActivity: null,
33
- lrsConfig: null,
34
- compStatusTracker: []
35
- }
36
- const getters = {
37
- /**
38
- * @description: Check if subtitles are enabled or not
39
- */
40
- getMediaSubtitles(state) {
41
- return state.mediaSubtitles
42
- },
43
- /**
44
- * @description: get media volume for the playbar
45
- */
46
- getMediaVolume(state) {
47
- return state.mediaVolume
48
- },
49
-
50
- /**
51
- * @description: Check if automatic video playback is enabled in application settings
52
- */
53
-
54
- getAutoplayEnabled(state) {
55
- return state.applicationSettings.autoplay
56
- ? state.applicationSettings.autoplay
57
- : null
58
- },
59
-
60
- /**
61
- * @description: Check if onboarding is enabled in application settings
62
- */
63
- getOnboardingEnabled(state) {
64
- return state.applicationSettings.onboarding
65
- ? state.applicationSettings.onboarding
66
- : null
67
- },
68
-
69
- /**
70
- * @description: Check if auto-show subtitles is enabled in application settings
71
- */
72
- getShowSubtitles(state) {
73
- return state.applicationSettings.subtitles
74
- ? state.applicationSettings.subtitles
75
- : null
76
- },
77
-
78
- /**
79
- * @description: Getter to return the app status
80
- */
81
- getAppStatus(state) {
82
- // return state.status
83
- // if (state.compStatusTracker.length) return 'loading'
84
- // else return 'ready'
85
-
86
- return state.compStatusTracker.length ? 'loading' : 'ready'
87
- },
88
-
89
- /**
90
- * @description: Getter to return the a page and its data
91
- * @param {String} activity_Id: ID of the activity
92
- * @param {String} page_Id: ID of the page
93
- * @return {Object} : data of the search result
94
- */
95
- getPageData(state) {
96
- return (activity_Id, page_Id) => {
97
- //Must have activity_Id, page_Id params
98
- if (!activity_Id || !page_Id)
99
- throw new Error(
100
- ` ⚠️ Invalid call to getPageData \n 🚩 Missing required arguments`
101
- )
102
-
103
- if (state.thisModule.activities.get(activity_Id)) {
104
- let page
105
-
106
- //handle the case for branching and normal pages
107
- if (page_Id.length > 3) {
108
- const splitted = page_Id.split('_')
109
- page = state.thisModule.activities
110
- .get(activity_Id)
111
- .get(splitted[0])
112
- .get(splitted[1])
113
- .get(page_Id)
114
- } else {
115
- const p = state.thisModule.activities.get(activity_Id).get(page_Id)
116
- if (p)
117
- switch (p.constructor) {
118
- //Branching root page
119
- case Map:
120
- page = p.get(page_Id)
121
- break
122
- //Normal page
123
- default:
124
- page = state.thisModule.activities.get(activity_Id).get(page_Id)
125
- break
126
- }
127
- }
128
- if (page) return page
129
- }
130
-
131
- return false
132
- }
133
- },
134
- /**
135
- * @description: Getter to return all activities of the module
136
- */
137
- getAllActivities(state) {
138
- if (Object.keys(state.thisModule).length && state.thisModule.activities)
139
- return {
140
- list: state.thisModule.activities,
141
- pageSize: (() => {
142
- let size = 0
143
- state.thisModule.activities.forEach((value) => {
144
- size = size + value.size
145
- })
146
- return size
147
- })()
148
- }
149
- return {}
150
- },
151
- getAnchorStatus(state) {
152
- return state.anchorStatus
153
- },
154
- getIntroStatus(state, getters) {
155
- let activities = getters.getAllActivities.list
156
- return activities.get('A00') ? true : false
157
- },
158
- getConcluStatus(state, getters) {
159
- let activities = getters.getAllActivities.list
160
- return activities.get('A99') ? true : false
161
- },
162
- getModuleInfo(state) {
163
- if (state.thisModule.info) return state.thisModule.info
164
- else return state.thisModule
165
- },
166
- getAppConfigs(state) {
167
- if (state.appConfigs) return state.appConfigs
168
- else return false
169
- },
170
- getRouteHistory(state) {
171
- return state.routeHistory ? state.routeHistory : []
172
- },
173
- hasMediaElOrTimeline(state) {
174
- return state.currentPageMediaElement || state.currentPageTimeline
175
- },
176
- /**
177
- * @description: Getter to return the current page
178
- * @returns: page {Object}
179
- */
180
- getCurrentPage(state) {
181
- let page = null
182
- if (state.currentPage !== null) {
183
- page = {
184
- ...state.currentPage
185
- }
186
- page.mElement = state.currentPageMediaElement
187
- page.timeline = state.currentPageTimeline
188
- }
189
- return page
190
- },
191
- /**
192
- * @description: Getter to return the current branching page
193
- * @returns: page {Object}
194
- */
195
- getCurrentBranching(state) {
196
- return state.currentBranching
197
- },
198
- /**
199
- * @description: Getter to return the current branch page in a branching
200
- * @returns: page {Object}
201
- */
202
- getCurrentBranchPage(state) {
203
- return state.currentBranchPage
204
- },
205
- /**
206
- * @description: Getter to return the current Media Duration
207
- */
208
- getCurrentMediaDuration(state) {
209
- return state.currentMediaDuration
210
- },
211
- /**
212
- * @description: Getter to return the browser
213
- */
214
- getCurrentBrowser(state) {
215
- return state.currentBrowser
216
- },
217
-
218
- getIsMobile(state) {
219
- return state.isMobile
220
- },
221
- /**
222
- * @description: Getter to return the type of device on which app is running (iosDevice, Android device or Desktop)
223
- */
224
- getDeviceType(state) {
225
- return state.deviceType
226
- },
227
- /**
228
- * @description: Getter to return the current enabled user settings
229
- */
230
- getApplicationSettings(state) {
231
- return state.applicationSettings
232
- },
233
-
234
- /**
235
- * @description: Getter to return the userMetadata
236
- * * @returns: {Object}
237
- */
238
- getUserInteraction(state) {
239
- return state.userMetaData
240
- },
241
- /**
242
- * @description: Getter to return all states of the activities
243
- * @returns: progess {Object}
244
- */
245
- getAllActivitiesState(state, getters) {
246
- const activities = getters.getAllActivities.list
247
- let progress = {}
248
- // search this acvitity in the userInteraction
249
- activities.forEach((aValue, aKey) => {
250
- let allStates
251
- let temp = []
252
-
253
- if (state.userMetaData[aKey]) {
254
- const activity = Object.entries(state.userMetaData[aKey])
255
-
256
- // get all the completed acitivities
257
- allStates = activity.map((page) => {
258
- // return only all the pages which state are completed or started
259
- if (
260
- page[1].userInteraction.state === 'completed' ||
261
- page[1].userInteraction.state === 'started'
262
- ) {
263
- return {
264
- ...allStates,
265
- [page[0]]: page[1].userInteraction.state
266
- }
267
- }
268
- })
269
- }
270
- if (allStates && allStates.length) {
271
- temp = [...allStates]
272
- }
273
-
274
- // Getting the(Map type Object) length of the activities including the branching
275
- let z = [] //placeholder
276
- const getLength = (el) => {
277
- if (el.size && el.size > 0) {
278
- el.forEach((v) => {
279
- // v is a map get its length with a recursive call to its elements
280
- if (v && v.constructor === Map && v.size > 0) getLength(v)
281
- else z.push(v) // v is an object add it to z
282
- })
283
- }
284
- return z.length //return the length of the paceholder
285
- }
286
-
287
- // Update the progress with new values
288
- progress = {
289
- ...progress,
290
- [aKey]: {
291
- size: getLength(aValue),
292
- progressions: [...temp]
293
- }
294
- }
295
- })
296
- return progress
297
- },
298
-
299
- /**
300
- * @description: Getter to return only completed activities
301
- * @returns: record {Object}
302
- */
303
- getAllCompleted(state, getters) {
304
- const allActivities = getters.getAllActivitiesState
305
- let record = {}
306
-
307
- for (const key in allActivities) {
308
- // get only actities that are completed
309
- const completed = allActivities[key].progressions.filter((page) => {
310
- if (page) return Object.values(page)[0] === 'completed'
311
- })
312
- // add the activity and its completed pages
313
- if (completed.length)
314
- record = {
315
- ...record,
316
- [key]: [...completed]
317
- } // add the complete array to the record
318
- }
319
- return record
320
- },
321
-
322
- // for the quizzes
323
- getAllQuizAnswers(state) {
324
- return state.quizAnswers
325
- },
326
- getAllPollAnswers(state) {
327
- return state.pollAnswers
328
- },
329
- getQuizAnswers(state) {
330
- return (question_id) => {
331
- const indexQuestion = state.quizAnswers.findIndex(function(element) {
332
- return element.questionId == question_id
333
- })
334
- if (indexQuestion !== -1) {
335
- return state.quizAnswers[indexQuestion]
336
- }
337
- return false
338
- }
339
- },
340
- getPollAnswers(state) {
341
- return (question_id) => {
342
- const indexQuestion = state.pollAnswers.findIndex(function(element) {
343
- return element.questionId == question_id
344
- })
345
- if (indexQuestion !== -1) {
346
- return state.pollAnswers[indexQuestion]
347
- }
348
- return false
349
- }
350
- },
351
- getBifChoice(state, getters) {
352
- const activities = getters.getUserInteraction
353
- let data = {}
354
-
355
- let act = null
356
- let page = null
357
- for (const c in activities) {
358
- act = c
359
- const activity = state.userMetaData[c]
360
- for (const b in activity) {
361
- page = b
362
- if (
363
- activity[b] &&
364
- [b].userInteractionactivity &&
365
- [b].userInteraction.bifChoice
366
- ) {
367
- let choix = activity[b].userInteraction.bifChoice
368
- data = { ...data, act, page, choix }
369
- }
370
- }
371
- }
372
-
373
- return data
374
- },
375
- /**
376
- * @description: Getter to return the connection information of the app
377
- * @returns: record {Object}
378
- */
379
- getConnectionInfo(state, getters) {
380
- return getters.getLrsInfo
381
- },
382
-
383
- /**
384
- * @description: Getter to return the menu setting
385
- * @returns: record {Object}
386
- */
387
- getMenuSettings(state) {
388
- return state.menuSetting
389
- },
390
- getTask(state) {
391
- return (id) => {
392
- for (const column of state.board.columns) {
393
- for (const task of column.tasks) {
394
- if (task.id === id) return task
395
- }
396
- }
397
- }
398
- },
399
- /**
400
- * @description: Getter to return the menu setting
401
- * @returns: record {Array}: liste of all the anchors by activity
402
- */
403
- getMenuAnchors(state, getters) {
404
- const menu = getters.getMenuSettings
405
- let anchors = []
406
- for (const c in menu) {
407
- anchors = [...anchors, { [c]: menu[c].anchors }]
408
- }
409
- return anchors
410
- },
411
-
412
- /**
413
- * @description: Getter to return the menu setting
414
- * @params ID {String}: id of the Activity
415
- * @returns: record {ArrayOfObject}
416
- */
417
- getAnchorsForActivity(state, getters) {
418
- const allAnchors = getters.getMenuAnchors
419
- return (id) => {
420
- const result = allAnchors.find((a) => a[id]) // find the object which has id
421
-
422
- if (result) return result[id]
423
- else return []
424
- }
425
- },
426
-
427
- /**
428
- * @description: Getter to return the current Section
429
- * @returns: {Object}
430
- */
431
- getCurrentSection(state) {
432
- if (state.currentSection) return state.currentSection
433
- else return {}
434
- },
435
-
436
- getShowPrimaryCtrl(state) {
437
- return state.showPrimaryCtrl
438
- },
439
-
440
- getShowNavLeftCtrl(state) {
441
- return state.showNavLeftCtrl
442
- },
443
-
444
- getShowNavRightCtrl(state) {
445
- return state.showNavRightCtrl
446
- },
447
-
448
- getLrsInfo(state) {
449
- return state.lrsConfig
450
- },
451
-
452
- getNextActivity(state) {
453
- return state.nextActivity
454
- },
455
-
456
- getPreviousActivity(state) {
457
- return state.prevActivity
458
- }
459
- }
460
-
461
- /**
462
- * @description: Getter to return the Anchors of on Activity
463
- * @params ID {String}: id of the activity for the search
464
- * @returns: record {Array}: liste of the anchors
465
- */
466
-
467
- const mutations = {
468
- UPDATE_APP_STATUS(state, status) {
469
- state.status = status
470
- },
471
-
472
- UPDATE_ANCHOR_STATE(state, status) {
473
- state.anchorStatus = status
474
- },
475
-
476
- UPDATE_INTRO_STATE(state, status) {
477
- state.introAcitve = status
478
- },
479
-
480
- SET_MOBILE_STATE(state, status) {
481
- state.isMobile = status
482
- },
483
- SET_CURRENT_BROWSER(state, browser) {
484
- state.currentBrowser = browser
485
- },
486
- SET_DEVICE_TYPE(state, device) {
487
- state.deviceType = device
488
- },
489
- SET_APPLICATION_SETTINGS(state, settings) {
490
- state.applicationSettings = settings
491
- },
492
-
493
- SET_MEDIA_VOLUME(state, volume) {
494
- state.mediaVolume = volume
495
- },
496
- SET_MEDIA_SUBTITLES(state, subtitlesEnabled) {
497
- state.mediaSubtitles = subtitlesEnabled
498
- },
499
-
500
- /* set/update the Application configuration*/
501
- SET_APP_CONFIGS(state, data) {
502
- state.appConfigs = data
503
- },
504
-
505
- SET_ROUTE_HISTORY(state, data) {
506
- state.routeHistory = data
507
- },
508
- /* set/update the Menu configuration*/
509
- SET_MENU(state, data) {
510
- state.menuSetting = data
511
- },
512
-
513
- ADD_PAGES(state, pages) {
514
- // Add Pages to the module
515
- if (!state.thisModule.children) state.thisModule.activities = pages
516
- },
517
- /* set/update the Branching information*/
518
- UPDATE_CURRENT_BRANCHING(state, data) {
519
- state.currentBranching = data
520
- },
521
- /* set/update the branch page information*/
522
- UPDATE_CURRENT_BRANCH_PAGE(state, data) {
523
- state.currentBranchPage = data
524
- },
525
- /* set/update page information*/
526
- UPDATE_CURRENT_PAGE(state, { activity_Id, page_Id }) {
527
- if (activity_Id && page_Id) {
528
- let page
529
- //id type case PXX_EXX_PXX
530
- if (page_Id.length > 3) {
531
- const splitted = page_Id.split('_')
532
- page = state.thisModule.activities
533
- .get(activity_Id)
534
- .get(splitted[0])
535
- .get(page_Id).content
536
- } else {
537
- const p = state.thisModule.activities.get(activity_Id).get(page_Id)
538
-
539
- //this branching page if the constructor is a map
540
- if (p && p.constructor === Map) {
541
- page = state.thisModule.activities
542
- .get(activity_Id)
543
- .get(page_Id)
544
- .get(page_Id).content
545
- } else
546
- page = state.thisModule.activities.get(activity_Id).get(page_Id)
547
- .content
548
- }
549
- state.currentPage = page
550
- } else state.currentPage = {}
551
- },
552
- /**
553
- @description update the module data.
554
- If no key is passed update the entire module with new data. if key is passed add/update the key
555
- @param {String} key : a key to add/update in the module
556
- @param {String} key : a key to add/update in the module
557
-
558
- */
559
- UPDATE_MODULE(state, { key, data }) {
560
- if (key || state.thisModule[key]) state.thisModule[key] = data
561
- else state.thisModule = data
562
- },
563
-
564
- UPDATE_CURRENT_PAGE_TIMELINE(state, data) {
565
- state.currentPageTimeline = data
566
- },
567
-
568
- UPDATE_CURRENT_PAGE_MEDIA_ELEMENT(state, data) {
569
- state.currentPageMediaElement = data
570
- },
571
-
572
- UPDATE_CURRENT_MEDIA_DURATION(state, data) {
573
- state.currentMediaDuration = data
574
- },
575
-
576
- UPDATE_CURRENT_SECTION(state, data) {
577
- // update when new data
578
- if (
579
- !state.currentSection ||
580
- state.currentSection.anchorName !== data.anchorName
581
- )
582
- state.currentSection = data
583
- },
584
- /**
585
- * @description: Save user interaction on a page to store: DONE
586
- * USe to Update existing userMetadata
587
- */
588
- UPDATE_USER_METADATA(state, data) {
589
- const _keys = Object.keys(data) // get all keys in the passed data
590
- // ckeck if the Activity existe in the user data
591
- if (data.activityRef) {
592
- if (state.userMetaData[data.activityRef]) {
593
- const activity = state.userMetaData[data.activityRef] // get targeted activity in the user data
594
- const page = data.id // page id
595
-
596
- // check if the page exist in the the activity
597
- if (Object.keys(activity).includes(page)) {
598
- // add entry for new key in user data for the target page
599
- _keys.forEach((key) => {
600
- // add add value of new key in the record : discart key=ActivityRef and key ===
601
- if (key !== _keys[0] && key !== _keys[1]) {
602
- // store the current user interaction in a variable
603
- const oldValue = activity[page][key]
604
-
605
- // update the user data by copying the old value and add new data
606
- activity[page][key] = {
607
- ...oldValue,
608
- ...data[key]
609
- }
610
- }
611
- })
612
- } else {
613
- /**
614
- * add the page reference as an object to the user data
615
- * and create entry for user interaction
616
- * */
617
- _keys.forEach((key) => {
618
- if (key !== _keys[0] && key !== _keys[1]) {
619
- Vue.set(activity, [page], {
620
- [key]: data[key]
621
- })
622
- }
623
- })
624
- }
625
- } else {
626
- // create a new entry for the activity
627
- state.userMetaData = {
628
- ...state.userMetaData,
629
- [data.activityRef]: {
630
- [data.id]: {}
631
- }
632
- }
633
-
634
- // Add data for each new page
635
- _keys.forEach((key) => {
636
- if (key !== _keys[0] && key !== _keys[1]) {
637
- // add the page datas
638
- state.userMetaData[data.activityRef][data.id] = {
639
- [key]: data[key]
640
- }
641
- }
642
- })
643
- }
644
- }
645
- },
646
-
647
- /* set/update the user data with existing record */
648
- SET_USER_METADATA(state, data) {
649
- state.userMetaData = data
650
- },
651
-
652
- // to update the answers
653
- UPDATE_ANSWERS_QUIZ(state, answers) {
654
- const theAnswers = this.getters.getAllQuizAnswers.findIndex(function(
655
- element
656
- ) {
657
- return element.questionId == answers.questionId
658
- })
659
- if (theAnswers == -1) {
660
- // if the answer already existed
661
- state.quizAnswers.push(answers)
662
- } else {
663
- state.quizAnswers[theAnswers] = answers
664
- }
665
- },
666
-
667
- UPDATE_ANSWERS_POLL(state, answers) {
668
- const theAnswers = this.getters.getAllPollAnswers.findIndex(function(
669
- element
670
- ) {
671
- return element.questionId == answers.questionId
672
- })
673
- if (theAnswers == -1) {
674
- // if the answer already existed
675
- state.pollAnswers.push(answers)
676
- } else {
677
- state.pollAnswers[theAnswers] = answers
678
- }
679
- },
680
-
681
- SET_SHOW_PRIMARY_CONTROL(state, bool) {
682
- state.showPrimaryCtrl = bool
683
- },
684
-
685
- SET_SHOW_NAV_LEFT_CONTROL(state, bool) {
686
- state.showNavLeftCtrl = bool
687
- },
688
-
689
- SET_SHOW_NAV_RIGHT_CONTROL(state, bool) {
690
- state.showNavRightCtrl = bool
691
- },
692
-
693
- SET_LRS_CONFIG(state, data) {
694
- if (data) state.lrsConfig = data
695
- },
696
-
697
- UPDATE_PREVIOUS_ACTIVITY(state, data) {
698
- state.prevActivity = data
699
- },
700
-
701
- UPDATE_NEXT_ACTIVITY(state, data) {
702
- state.nextActivity = data
703
- },
704
-
705
- UPDATE_COMPONENTS_STATUS(state, data) {
706
- if (!data) return
707
-
708
- const { name, status } = data
709
-
710
- if (!name || !status) return
711
-
712
- let tracker = state.compStatusTracker
713
-
714
- //search for the component
715
- let target = tracker.find((e) => e == name)
716
-
717
- //add component to tracking cue
718
- if (!target && status == 'loading') tracker.push(name)
719
-
720
- if (!tracker.length) return
721
-
722
- //remove component to tracking cue
723
- if (status == 'ready') {
724
- const index = tracker.indexOf(target)
725
-
726
- if (index >= 0) tracker = tracker.splice(index, 1)
727
- }
728
- }
729
- }
730
-
731
- const actions = {
732
- updateAppStatus({ commit }, status) {
733
- commit('UPDATE_APP_STATUS', status)
734
- },
735
- updateAnchorStatus({ commit }, status) {
736
- commit('UPDATE_ANCHOR_STATE', status)
737
- },
738
- updateIntroStatus({ commit }, status) {
739
- commit('UPDATE_INTRO_STATE', status)
740
- },
741
- /**
742
- * @description: add a page in to the state collection
743
- */
744
- addPage({ commit }, page) {
745
- commit('ADD_PAGE', page)
746
- },
747
-
748
- setRouteHistory({ commit }, data) {
749
- commit('SET_ROUTE_HISTORY', data)
750
- },
751
-
752
- /**
753
- * @description: Update page in state collection
754
- */
755
- updatePage({ commit }, newData) {
756
- commit('UPDATE_PAGE', newData)
757
- },
758
- /**
759
- * @description: Update module
760
- */
761
- updateActivitiesState({ commit }, data) {
762
- commit('UPDATE_ACTIVITES_STATE', data)
763
- },
764
- /**
765
- * @description: Update module
766
- */
767
- updateModule({ commit }, data) {
768
- commit('UPDATE_MODULE', data)
769
- },
770
-
771
- /**
772
- * @description: Update current Timeline
773
- */
774
- updateCurrentTimeline({ commit }, data) {
775
- commit('UPDATE_CURRENT_PAGE_TIMELINE', data)
776
- },
777
-
778
- /**
779
- * @description: Update current page
780
- */
781
- updateCurrentPage({ commit }, data) {
782
- commit('UPDATE_CURRENT_PAGE', data)
783
- },
784
- /**
785
- * @description: Update current section name
786
- */
787
- updateCurrentSection({ commit }, data) {
788
- commit('UPDATE_CURRENT_SECTION', data)
789
- },
790
-
791
- // /**
792
- // * @description: Update current media element (video/ audio)
793
- // */
794
- // updateCurrentMediaElement({ commit }, data) {
795
- // commit('UPDATE_CURRENT_PAGE_MEDIA_ELEMENT', data)
796
- // },
797
-
798
- /**
799
- * @description: Update current media element (video/ audio)
800
- */
801
- async updateCurrentMediaElement({ commit }, data) {
802
- return new Promise((resolve) => {
803
- commit('UPDATE_CURRENT_PAGE_MEDIA_ELEMENT', data)
804
- resolve()
805
- })
806
- },
807
- /**
808
- * @description: Update duration of current media element (video/ audio)
809
- */
810
- updateCurrentMediaDuration({ commit }, duration) {
811
- commit('UPDATE_CURRENT_MEDIA_DURATION', duration)
812
- },
813
-
814
- /**
815
- * @description: Update user meta data (video/ audio)
816
- */
817
- updateUserMetaData({ commit }, data) {
818
- commit('UPDATE_USER_METADATA', data)
819
- },
820
- setUserMetaData({ commit }, data) {
821
- commit('SET_USER_METADATA', data)
822
- },
823
-
824
- // to save the answers
825
- saveAnswersQuiz({ commit }, data) {
826
- commit('UPDATE_ANSWERS_QUIZ', data)
827
- },
828
- saveAnswersPoll({ commit }, data) {
829
- commit('UPDATE_ANSWERS_POLL', data)
830
- },
831
- // to
832
-
833
- /**
834
- * @description: Set app settings
835
- */
836
- setAppConfigs({ commit }, data) {
837
- commit('SET_APP_CONFIGS', data)
838
- },
839
- setMobileState({ commit }, data) {
840
- commit('SET_MOBILE_STATE', data)
841
- },
842
- setCurrentBrowser({ commit }, data) {
843
- commit('SET_CURRENT_BROWSER', data)
844
- },
845
- setDeviceType({ commit }, data) {
846
- commit('SET_DEVICE_TYPE', data)
847
- },
848
- setApplicationSettings({ commit }, data) {
849
- commit('SET_APPLICATION_SETTINGS', data)
850
- },
851
-
852
- setMediaVolume({ commit }, data) {
853
- commit('SET_MEDIA_VOLUME', data)
854
- },
855
- setMediaSubtitles({ commit }, data) {
856
- commit('SET_MEDIA_SUBTITLES', data)
857
- },
858
-
859
- setShowPrimaryCtrl({ commit }, data) {
860
- commit('SET_SHOW_PRIMARY_CONTROL', data)
861
- },
862
-
863
- setShowNavLeftCtrl({ commit }, data) {
864
- commit('SET_SHOW_NAV_LEFT_CONTROL', data)
865
- },
866
-
867
- setShowNavRightCtrl({ commit }, data) {
868
- commit('SET_SHOW_NAV_RIGHT_CONTROL', data)
869
- },
870
-
871
- setLrsConfig({ commit }, data) {
872
- // commit('UPDATE_APP_STATUS', 'loading')
873
- commit('SET_LRS_CONFIG', data)
874
- // commit('UPDATE_APP_STATUS', 'ready')
875
- },
876
-
877
- updatePreviousActivity({ commit }, data) {
878
- commit('UPDATE_PREVIOUS_ACTIVITY', data)
879
- },
880
-
881
- updateNextActivity({ commit }, data) {
882
- commit('UPDATE_NEXT_ACTIVITY', data)
883
- },
884
-
885
- updateCompStatusTracker({ commit }, data) {
886
- commit('UPDATE_COMPONENTS_STATUS', data)
887
- }
888
- }
889
-
890
- export default {
891
- state,
892
- mutations,
893
- actions,
894
- getters
895
- }