fcad-core-dragon 2.0.0-beta.0 → 2.0.0-beta.10

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 (161) hide show
  1. package/.editorconfig +6 -31
  2. package/.prettierrc +11 -0
  3. package/.vscode/extensions.json +8 -0
  4. package/.vscode/settings.json +16 -0
  5. package/CHANGELOG +153 -0
  6. package/README.md +28 -43
  7. package/documentation/.vitepress/config.js +114 -0
  8. package/documentation/api-examples.md +49 -0
  9. package/documentation/composants/app-base-button.md +58 -0
  10. package/documentation/composants/app-base-error-display.md +59 -0
  11. package/documentation/composants/app-base-popover.md +68 -0
  12. package/documentation/composants/app-comp-audio.md +75 -0
  13. package/documentation/composants/app-comp-branch-buttons.md +111 -0
  14. package/documentation/composants/app-comp-button-progress.md +53 -0
  15. package/documentation/composants/app-comp-carousel.md +53 -0
  16. package/documentation/composants/app-comp-container.md +53 -0
  17. package/documentation/composants/app-comp-input-checkbox-next.md +42 -0
  18. package/documentation/composants/app-comp-input-dropdown-next.md +34 -0
  19. package/documentation/composants/app-comp-input-radio-next.md +39 -0
  20. package/documentation/composants/app-comp-input-text-next.md +35 -0
  21. package/documentation/composants/app-comp-input-text-table-next.md +34 -0
  22. package/documentation/composants/app-comp-input-text-to-fill-dropdown-next.md +53 -0
  23. package/documentation/composants/app-comp-input-text-to-fill-next.md +31 -0
  24. package/documentation/composants/app-comp-jauge.md +31 -0
  25. package/documentation/composants/app-comp-menu-item.md +55 -0
  26. package/documentation/composants/app-comp-menu.md +29 -0
  27. package/documentation/composants/app-comp-navigation.md +41 -0
  28. package/documentation/composants/app-comp-note-call.md +53 -0
  29. package/documentation/composants/app-comp-note-credit.md +53 -0
  30. package/documentation/composants/app-comp-play-bar-next.md +53 -0
  31. package/documentation/composants/app-comp-pop-up-next.md +93 -0
  32. package/documentation/composants/app-comp-quiz-next.md +235 -0
  33. package/documentation/composants/app-comp-quiz-recall.md +53 -0
  34. package/documentation/composants/app-comp-svg-next.md +53 -0
  35. package/documentation/composants/app-comp-table-of-content.md +50 -0
  36. package/documentation/composants/app-comp-video-player.md +82 -0
  37. package/documentation/composants.md +46 -0
  38. package/documentation/composants_critiques/ModelPageComposant.md +53 -0
  39. package/documentation/composants_critiques/app-base-module.md +43 -0
  40. package/documentation/composants_critiques/app-base-page.md +48 -0
  41. package/documentation/composants_critiques/app-base.md +311 -0
  42. package/documentation/composants_critiques/main.md +15 -0
  43. package/documentation/demarrage.md +50 -0
  44. package/documentation/deploiement.md +58 -0
  45. package/documentation/index.md +33 -0
  46. package/documentation/markdown-examples.md +85 -0
  47. package/documentation/public/npm_version.png +0 -0
  48. package/documentation/public/vite.svg +15 -0
  49. package/documentation/public/vuejs.svg +2 -0
  50. package/documentation/public/vuetify.svg +6 -0
  51. package/eslint.config.js +60 -0
  52. package/package.json +43 -49
  53. package/src/$locales/en.json +94 -92
  54. package/src/$locales/fr.json +77 -113
  55. package/src/assets/data/onboardingMessages.json +1 -1
  56. package/src/components/AppBase.vue +971 -437
  57. package/src/components/AppBaseButton.test.js +21 -0
  58. package/src/components/AppBaseButton.vue +42 -10
  59. package/src/components/AppBaseErrorDisplay.vue +209 -162
  60. package/src/components/AppBaseFlipCard.vue +1 -0
  61. package/src/components/AppBaseModule.vue +1021 -976
  62. package/src/components/AppBasePage.vue +656 -128
  63. package/src/components/AppBasePopover.vue +41 -0
  64. package/src/components/AppBaseSkeleton.vue +66 -0
  65. package/src/components/AppCompAudio.vue +256 -0
  66. package/src/components/AppCompBranchButtons.vue +108 -181
  67. package/src/components/AppCompButtonProgress.vue +44 -70
  68. package/src/components/AppCompCarousel.vue +284 -233
  69. package/src/components/AppCompContainer.vue +29 -0
  70. package/src/components/AppCompInputCheckBoxNx.vue +323 -0
  71. package/src/components/AppCompInputDropdownNx.vue +299 -0
  72. package/src/components/AppCompInputRadioNx.vue +284 -0
  73. package/src/components/AppCompInputTextNx.vue +153 -0
  74. package/src/components/AppCompInputTextTableNx.vue +202 -0
  75. package/src/components/AppCompInputTextToFillDropdownNx.vue +340 -0
  76. package/src/components/AppCompInputTextToFillNx.vue +313 -0
  77. package/src/components/AppCompJauge.vue +36 -11
  78. package/src/components/AppCompMenu.vue +312 -92
  79. package/src/components/AppCompMenuItem.vue +129 -105
  80. package/src/components/AppCompNavigation.vue +972 -0
  81. package/src/components/AppCompNoteCall.vue +161 -0
  82. package/src/components/AppCompNoteCredit.vue +491 -0
  83. package/src/components/AppCompPlayBarNext.vue +2288 -0
  84. package/src/components/AppCompPopUpNext.vue +504 -0
  85. package/src/components/AppCompQuizNext.vue +510 -0
  86. package/src/components/AppCompQuizRecall.vue +350 -0
  87. package/src/components/AppCompSVGNext.vue +346 -0
  88. package/src/components/AppCompSettingsMenu.vue +18 -16
  89. package/src/components/AppCompTableOfContent.vue +340 -122
  90. package/src/components/AppCompVideoPlayer.vue +377 -0
  91. package/src/components/BaseModule.vue +24 -117
  92. package/src/components/tests__/AppBaseButton.spec.js +53 -0
  93. package/src/components/tests__/useTimer.spec.js +91 -0
  94. package/src/composables/useIdleDetector.js +56 -0
  95. package/src/composables/useQuiz.js +89 -0
  96. package/src/composables/useTimer.js +172 -0
  97. package/src/directives/nvdaFix.js +53 -0
  98. package/src/externalComps/ModuleView.vue +22 -0
  99. package/src/externalComps/SummaryView.vue +91 -0
  100. package/src/main.js +400 -142
  101. package/src/module/stores/appStore.js +947 -0
  102. package/src/module/xapi/ADL.js +241 -60
  103. package/src/module/xapi/Crypto/Hasher.js +8 -8
  104. package/src/module/xapi/Crypto/WordArray.js +6 -6
  105. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +4 -4
  106. package/src/module/xapi/Crypto/algorithms/C_algo.js +14 -18
  107. package/src/module/xapi/Crypto/algorithms/HMAC.js +1 -1
  108. package/src/module/xapi/Crypto/algorithms/SHA1.js +1 -1
  109. package/src/module/xapi/Crypto/encoders/Base.js +7 -7
  110. package/src/module/xapi/Crypto/encoders/Base64.js +3 -3
  111. package/src/module/xapi/Crypto/encoders/Hex.js +4 -3
  112. package/src/module/xapi/Crypto/encoders/Latin1.js +3 -3
  113. package/src/module/xapi/Crypto/encoders/Utf8.js +3 -3
  114. package/src/module/xapi/Statement/index.js +3 -3
  115. package/src/module/xapi/launch.js +10 -10
  116. package/src/module/xapi/utils.js +17 -17
  117. package/src/module/xapi/wrapper.js +223 -218
  118. package/src/module/xapi/xapiStatement.js +29 -29
  119. package/src/plugins/analytics.js +34 -0
  120. package/src/plugins/bus.js +7 -2
  121. package/src/plugins/gsap.js +9 -8
  122. package/src/plugins/helper.js +141 -43
  123. package/src/plugins/i18n.js +13 -18
  124. package/src/plugins/idb.js +46 -30
  125. package/src/plugins/save.js +1 -1
  126. package/src/plugins/scorm.js +15 -15
  127. package/src/plugins/xapi.js +2 -2
  128. package/src/public/index.html +23 -11
  129. package/src/router/index.js +57 -0
  130. package/src/router/routes.js +312 -0
  131. package/src/shared/generalfuncs.js +241 -10
  132. package/src/shared/validators.js +1018 -0
  133. package/vitest.config.js +19 -0
  134. package/.eslintignore +0 -29
  135. package/.eslintrc.js +0 -86
  136. package/.prettierrc.js +0 -5
  137. package/babel.config.js +0 -3
  138. package/src/components/AppBaseDragChoice.vue +0 -91
  139. package/src/components/AppBaseDropZone.vue +0 -112
  140. package/src/components/AppCompDragAndDrop.vue +0 -339
  141. package/src/components/AppCompInputAssociation.vue +0 -332
  142. package/src/components/AppCompInputCheckBox.vue +0 -227
  143. package/src/components/AppCompInputDropdown.vue +0 -184
  144. package/src/components/AppCompInputRadio.vue +0 -169
  145. package/src/components/AppCompInputTextBox.vue +0 -91
  146. package/src/components/AppCompInputTextTable.vue +0 -155
  147. package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
  148. package/src/components/AppCompInputTextToFillText.vue +0 -164
  149. package/src/components/AppCompMediaPlayer.vue +0 -365
  150. package/src/components/AppCompNavigationFull.vue +0 -1791
  151. package/src/components/AppCompPlayBar.vue +0 -1540
  152. package/src/components/AppCompPopUp.vue +0 -523
  153. package/src/components/AppCompQuiz.vue +0 -2998
  154. package/src/components/AppCompToolTip.vue +0 -94
  155. package/src/mixins/$pageMixins.js +0 -381
  156. package/src/mixins/$quizMixins.js +0 -456
  157. package/src/mixins/timerMixin.js +0 -132
  158. package/src/module/store.js +0 -874
  159. package/src/plugins/timeManager.js +0 -77
  160. package/src/routes.js +0 -734
  161. package/vue.config.js +0 -83
@@ -1,456 +0,0 @@
1
- const $extendsQuiz = {
2
- watch: {
3
- /**
4
- * @description used to call a validation
5
- */
6
- quizSubmit(newValue) {
7
- if (newValue == true) {
8
- this.validateAnswers()
9
- }
10
- }
11
- },
12
-
13
- methods: {
14
- /**
15
- * @param {String} inputId
16
- * @returns {Array} the class
17
- */
18
- classInput(inputId) {
19
- let theClass = []
20
-
21
- switch (this.inputType) {
22
- case 'choix_unique':
23
- if (inputId == this.quizInputUnique) {
24
- theClass.push('reponseSelectionner')
25
- }
26
- break
27
-
28
- case 'choix_mult':
29
- if (this.containsValue(this.quizInputMultiple, inputId)) {
30
- theClass.push('reponseSelectionner')
31
- }
32
- }
33
-
34
- if (this.showSolution) {
35
- if (this.solution !== null) {
36
- switch (this.inputType) {
37
- case 'choix_unique':
38
- if (inputId == this.solution) {
39
- theClass.push('correct_answer')
40
- } else {
41
- theClass.push('wrong_answer')
42
- }
43
- break
44
-
45
- case 'choix_mult':
46
- if (this.containsValue(this.solution, inputId)) {
47
- theClass.push('correct_answer')
48
- } else {
49
- theClass.push('wrong_answer')
50
- }
51
- break
52
-
53
- case 'dropdown':
54
- if (this.solution[inputId] == this.quizSelectedValue[inputId]) {
55
- theClass.push('correct_answer')
56
- } else {
57
- theClass.push('wrong_answer')
58
- }
59
- break
60
-
61
- case 'texte_troue_select':
62
- if (typeof this.quizSelectedValue[inputId] !== 'undefined') {
63
- if (
64
- Object.values(this.solution[inputId])[0] ==
65
- this.quizSelectedValue[inputId]
66
- ) {
67
- theClass.push('correct_answer')
68
- } else {
69
- theClass.push('wrong_answer')
70
- }
71
- }
72
- break
73
-
74
- case 'reponse_ouverte':
75
- if (this.solution == this.quizTextArea) {
76
- theClass.push('correct_answer')
77
- } else {
78
- theClass.push('wrong_answer')
79
- }
80
- break
81
- case 'texte_tableau':
82
- if (
83
- this.containsValue(
84
- this.solution[inputId].reponse_value,
85
- this.quizTextTableValue[inputId]
86
- )
87
- ) {
88
- theClass.push('correct_answer')
89
- } else {
90
- theClass.push('wrong_answer')
91
- }
92
- break
93
- case 'texte_troue':
94
- if (typeof this.quizTextTableValue[inputId] !== 'undefined') {
95
- if (
96
- this.containsValue(
97
- Object.values(this.solution[inputId])[0],
98
- this.quizTextTableValue[inputId]
99
- )
100
- ) {
101
- theClass.push('correct_answer')
102
- } else {
103
- theClass.push('wrong_answer')
104
- }
105
- }
106
- break
107
- case 'association':
108
- if (
109
- this.solution[inputId] == this.quizAssociationValue[inputId]
110
- ) {
111
- theClass.push('correct_answer')
112
- } else {
113
- theClass.push('wrong_answer')
114
- }
115
- break
116
- case 'dragdrop':
117
- if (
118
- this.solution &&
119
- this.solution[inputId] &&
120
- this.quizDragDropValue &&
121
- this.quizDragDropValue[inputId]
122
- ) {
123
- //remove sort if order is important
124
- const solution = [...this.solution[inputId]].sort(function(
125
- a,
126
- b
127
- ) {
128
- return a - b
129
- })
130
- const values = [...this.quizDragDropValue[inputId]].sort(
131
- function(a, b) {
132
- return a - b
133
- }
134
- )
135
- if (this.isEqual(solution, values)) {
136
- theClass.push('correct_answer')
137
- } else {
138
- theClass.push('wrong_answer')
139
- }
140
- }
141
- }
142
- }
143
- }
144
- return theClass
145
- },
146
- messageAccessibility(inputId) {
147
- let mess = ''
148
- if (this.showSolution) {
149
- if (this.solution !== null) {
150
- switch (this.inputType) {
151
- case 'choix_unique':
152
- if (inputId == this.solution) {
153
- mess = `${this.$t('quizState.goodAnswer')}`
154
- } else {
155
- mess = `${this.$t('quizState.badAnswer')}`
156
- }
157
- break
158
-
159
- case 'choix_mult':
160
- if (this.containsValue(this.solution, inputId)) {
161
- mess = `${this.$t('quizState.goodAnswer')}`
162
- } else {
163
- mess = `${this.$t('quizState.badAnswer')}`
164
- }
165
- break
166
-
167
- case 'dropdown':
168
- if (this.solution[inputId] == this.quizSelectedValue[inputId]) {
169
- mess = `${this.$t('quizState.goodAnswer')}`
170
- } else {
171
- mess = `${this.$t('quizState.badAnswer')}`
172
- }
173
- break
174
-
175
- case 'texte_troue_select':
176
- if (typeof this.quizSelectedValue[inputId] !== 'undefined') {
177
- if (
178
- Object.values(this.solution[inputId])[0] ==
179
- this.quizSelectedValue[inputId]
180
- ) {
181
- mess = `${this.$t('quizState.goodAnswer')}`
182
- } else {
183
- mess = `${this.$t('quizState.badAnswer')}`
184
- }
185
- }
186
- break
187
-
188
- case 'reponse_ouverte':
189
- if (this.solution == this.quizTextArea) {
190
- mess = `${this.$t('quizState.goodAnswer')}`
191
- } else {
192
- mess = `${this.$t('quizState.badAnswer')}`
193
- }
194
- break
195
- case 'texte_tableau':
196
- if (
197
- this.containsValue(
198
- this.solution[inputId].reponse_value,
199
- this.quizTextTableValue[inputId]
200
- )
201
- ) {
202
- mess = `${this.$t('quizState.goodAnswer')}`
203
- } else {
204
- mess = `${this.$t('quizState.badAnswer')}`
205
- }
206
- break
207
- case 'texte_troue':
208
- if (typeof this.quizTextTableValue[inputId] !== 'undefined') {
209
- if (
210
- this.containsValue(
211
- Object.values(this.solution[inputId])[0],
212
- this.quizTextTableValue[inputId]
213
- )
214
- ) {
215
- mess = `${this.$t('quizState.goodAnswer')}`
216
- } else {
217
- mess = `${this.$t('quizState.badAnswer')}`
218
- }
219
- }
220
- break
221
- case 'association':
222
- if (
223
- this.solution[inputId] == this.quizAssociationValue[inputId]
224
- ) {
225
- mess = `${this.$t('quizState.goodAnswer')}`
226
- } else {
227
- mess = `${this.$t('quizState.badAnswer')}`
228
- }
229
- break
230
- case 'dragdrop':
231
- if (
232
- this.solution &&
233
- this.solution[inputId] &&
234
- this.quizDragDropValue &&
235
- this.quizDragDropValue[inputId]
236
- ) {
237
- //remove sort if order is important
238
- const solution = [...this.solution[inputId]].sort(function(
239
- a,
240
- b
241
- ) {
242
- return a - b
243
- })
244
- const values = [...this.quizDragDropValue[inputId]].sort(
245
- function(a, b) {
246
- return a - b
247
- }
248
- )
249
- if (this.isEqual(solution, values)) {
250
- mess = `${this.$t('quizState.goodAnswer')}`
251
- } else {
252
- mess = `${this.$t('quizState.badAnswer')}`
253
- }
254
- }
255
- }
256
- }
257
- }
258
- return mess
259
- },
260
- /**
261
- * @description check if this question is correct
262
- * @fires quiz-submit to AppCompQuiz.vue
263
- */
264
- validateAnswers() {
265
- let theAnswer = {}
266
-
267
- switch (this.inputType) {
268
- case 'choix_unique': {
269
- let listInput = this.quizInputUnique
270
- if (listInput) {
271
- theAnswer = {
272
- [this.inputDataId]: listInput
273
- }
274
- } else {
275
- //did not answered
276
- theAnswer = null
277
- }
278
- break
279
- }
280
-
281
- case 'choix_mult': {
282
- let listInputCheck = this.quizInputMultiple
283
- if (listInputCheck.length > 0) {
284
- theAnswer = {
285
- [this.inputDataId]: listInputCheck
286
- }
287
- } else {
288
- //did not answered
289
- theAnswer = null
290
- }
291
-
292
- break
293
- }
294
-
295
- case 'dropdown': {
296
- let listQuizSelected = this.quizSelected
297
-
298
- if (
299
- listQuizSelected.length == this.inputData.length &&
300
- !this.containsValue(listQuizSelected, null)
301
- ) {
302
- let listQuizSelectedConvert = []
303
- for (let index = 0; index < this.inputData.length; index++) {
304
- const element = this.inputData[index]
305
- listQuizSelectedConvert.push({
306
- question_id: element.id,
307
- reponse_id: listQuizSelected[index]
308
- })
309
- }
310
- theAnswer = {
311
- [this.inputDataId]: listQuizSelectedConvert
312
- }
313
- } else {
314
- //did not answered
315
- theAnswer = null
316
- }
317
- break
318
- }
319
-
320
- case 'texte_troue_select': {
321
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
322
- let matchAll = this.textBase.split(regex)
323
- let listQuizSelectedText = this.quizSelected
324
- if (
325
- listQuizSelectedText.length == matchAll.length - 1 &&
326
- !this.containsValue(listQuizSelectedText, null)
327
- ) {
328
- let listQuizSelectedTextConvert = []
329
- for (let index = 0; index < listQuizSelectedText.length; index++) {
330
- listQuizSelectedTextConvert.push({
331
- question_id: index,
332
- reponse_id: listQuizSelectedText[index]
333
- })
334
- }
335
- theAnswer = {
336
- [this.inputDataId]: listQuizSelectedTextConvert
337
- }
338
- } else {
339
- //did not answered
340
- theAnswer = null
341
- }
342
- break
343
- }
344
-
345
- case 'reponse_ouverte': {
346
- let listInputText = this.quizTextArea
347
- if (listInputText.length > 0) {
348
- theAnswer = {
349
- [this.inputDataId]: listInputText
350
- }
351
- } else {
352
- //did not answered
353
- theAnswer = null
354
- }
355
- break
356
- }
357
- case 'texte_tableau': {
358
- let listInputTextTable = this.quizTextTable
359
- if (
360
- listInputTextTable.length == this.inputData.length &&
361
- !this.containsValue(listInputTextTable, null) &&
362
- !this.containsValue(listInputTextTable, '')
363
- ) {
364
- let listInputTextTableConvert = []
365
- for (let index = 0; index < this.inputData.length; index++) {
366
- const element = this.inputData[index]
367
- listInputTextTableConvert.push({
368
- question_id: element.id,
369
- reponse: listInputTextTable[index]
370
- })
371
- }
372
- theAnswer = {
373
- [this.inputDataId]: listInputTextTableConvert
374
- }
375
- } else {
376
- //did not answered
377
- theAnswer = null
378
- }
379
- break
380
- }
381
-
382
- case 'texte_troue': {
383
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
384
- let matchAll = this.textBase.split(regex)
385
- let listInputTextFill = this.quizTextTable
386
- if (
387
- listInputTextFill.length == matchAll.length - 1 &&
388
- !this.containsValue(listInputTextFill, null) &&
389
- !this.containsValue(listInputTextFill, '')
390
- ) {
391
- let listInputTextFillConvert = []
392
- for (let index = 0; index < listInputTextFill.length; index++) {
393
- listInputTextFillConvert.push({
394
- question_id: index,
395
- reponse: listInputTextFill[index]
396
- })
397
- }
398
- theAnswer = {
399
- [this.inputDataId]: listInputTextFillConvert
400
- }
401
- } else {
402
- //did not answered
403
- theAnswer = null
404
- }
405
- break
406
- }
407
-
408
- case 'association': {
409
- let listInputAssociation = this.quizAssociation
410
- if (
411
- Object.values(listInputAssociation).length ==
412
- Object.values(this.solution).length &&
413
- !this.containsValue(Object.values(listInputAssociation), '')
414
- ) {
415
- theAnswer = {
416
- [this.inputDataId]: listInputAssociation
417
- }
418
- } else {
419
- //did not answered
420
- theAnswer = null
421
- }
422
- break
423
- }
424
-
425
- case 'dragdrop': {
426
- let listInputDragDrop = this.quizDragDrop
427
- if (
428
- Object.keys(listInputDragDrop).length ==
429
- Object.keys(this.solution).length
430
- ) {
431
- theAnswer = {
432
- [this.inputDataId]: this.quizDragDrop
433
- }
434
- } else {
435
- //did not answered
436
- theAnswer = null
437
- }
438
- }
439
- }
440
- this.$emit('quiz-submit', theAnswer)
441
- },
442
- /**
443
- * @description - Method to get the question
444
- */
445
- getQuizQuestion() {
446
- const el = document.querySelector(`#${this.aBy}`)
447
- if (!el || !el.innerHTML) return
448
- const labelFor =
449
- this.$i18n.locale === 'fr'
450
- ? 'Choix de reponse pour la'
451
- : 'Answers available for the'
452
- return `${labelFor} ${el.innerText}`
453
- }
454
- }
455
- }
456
- export default $extendsQuiz
@@ -1,132 +0,0 @@
1
- /*
2
- @ Description: Mixins to extends general fonctionnalities in a page of an activity. Add time tracker in activities
3
- @ Note: .
4
- */
5
- export const timerMixin = {
6
- data() {
7
- return {
8
- lessonTimeCounter: 0,
9
- activityTimeCounter: 0,
10
- elapsedCounter: 0, // count the elapse time since lesson started
11
- activityInterval: null,
12
- lessonInterval: null,
13
- fullInterval: null,
14
- timerState: 'stopped',
15
- elapsedInterval: null // interval of passed time since the lesson is started. used only for saving purposed
16
- }
17
- },
18
- methods: {
19
- /* Start the timer */
20
- startTimer(op) {
21
- if (op && !['activity', 'lesson'].includes(op))
22
- throw new Error('this is not a valid option for the timer')
23
- if (this.timerState === 'stopped') {
24
- switch (op) {
25
- case 'activity':
26
- // if (this.activityDuration.length) this.activityDuration = '00:00:00'
27
- this.activityInterval = setInterval(() => {
28
- this.activityTimeCounter += 1
29
- }, 1000)
30
- this.timerState = 'started'
31
-
32
- break
33
-
34
- case 'lesson':
35
- this.lessonInterval = setInterval(() => {
36
- this.lessonTimeCounter += 1
37
- }, 1000)
38
- break
39
-
40
- default:
41
- this.fullInterval = setInterval(() => {
42
- this.activityTimeCounter += 1
43
- this.lessonTimeCounter += 1
44
- }, 1000)
45
- }
46
- }
47
- },
48
- /* Stop the timer and reset thimer to zero */
49
- stopTimer(op) {
50
- if (op && !['activity', 'lesson'].includes(op))
51
- throw new Error('this is not a valid parameter')
52
-
53
- if (this.timerState === 'started') {
54
- if (op === 'activity' && this.activityTimeCounter > 0) {
55
- this.lessonTimeCounter =
56
- this.lessonTimeCounter + this.activityTimeCounter //add to the lesson counter
57
- clearInterval(this.activityInterval) //clear the interval
58
- this.activityTimeCounter = 0 // reset the counter
59
- this.timerState = 'stopped'
60
- } else if (op === 'lesson' && this.lessonTimeCounter > 0) {
61
- clearInterval(this.lessonInterval)
62
- this.lessonTimeCounter = 0
63
- } else {
64
- clearInterval(this.fullInterval)
65
- clearInterval(this.elapsedCounter)
66
- clearInterval(this.elapsedInterval)
67
-
68
- this.activityTimeCounter = 0
69
- this.lessonTimeCounter = 0
70
- this.elapsedCounter = 0
71
- }
72
- }
73
- },
74
- /* Pause the timer but does not reset to zero*/
75
- pauseTimer(op) {
76
- if (op && !['activity', 'lesson'].includes(op))
77
- throw new Error('this is not a valid parameter')
78
-
79
- if (op === 'activity' && this.activityTimeCounter > 0) {
80
- clearInterval(this.activityInterval)
81
- } else if (op === 'lesson') {
82
- clearInterval(this.lessonInterval)
83
- } else {
84
- clearInterval(this.fullInterval)
85
- clearInterval(this.elapsedInterval)
86
- }
87
- },
88
- formatTime(seconds) {
89
- let d = new Date(null) //create a default date ref
90
- d.setSeconds(seconds) //set the time with passed numbers of seconds
91
- let ISOTime = d.toISOString().substr(11, 8) //convert the date in ISO 8601 format and get all only the time portion of it
92
- return ISOTime // time format 00:00:00
93
- }
94
- },
95
- mounted() {
96
- this.$bus.$on('start-timer', (op) => {
97
- this.startTimer(op)
98
- })
99
-
100
- this.$bus.$on('stop-timer', (op) => {
101
- this.stopTimer(op)
102
- })
103
-
104
- this.$bus.$on('pause-timer', (op) => {
105
- this.pauseTimer(op)
106
- })
107
-
108
- this.elapsedInterval = setInterval(() => {
109
- this.elapsedCounter += 1
110
- }, 1000)
111
- },
112
- computed: {
113
- activityDuration() {
114
- let duration
115
- if (this.activityTimeCounter > 0)
116
- duration = this.formatTime(this.activityTimeCounter)
117
- else duration = '00:00:00'
118
-
119
- return duration
120
- },
121
- lessonDuration() {
122
- this.lessonTimeCounter = this.lessonTimeCounter + this.activityTimeCounter
123
- let duration = this.formatTime(this.lessonTimeCounter)
124
- return duration
125
- },
126
- elapsedTime() {
127
- const eTime = this.elapsedCounter
128
- return eTime
129
- }
130
- }
131
- }
132
- //export default $extendsQuiz