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,184 +0,0 @@
1
- <template>
2
- <div class="input-box">
3
- <div
4
- v-for="singleDropdown in inputData"
5
- :key="singleDropdown.id"
6
- :class="
7
- `dropdownlist-${singleDropdown.id} ${classInput(singleDropdown.id)}`
8
- "
9
- >
10
- <label
11
- :for="`${inputDataId}_${singleDropdown.id}`"
12
- v-html="singleDropdown.ennonce"
13
- ></label>
14
- <b-form-select
15
- :id="inputDataId + '_' + singleDropdown.id"
16
- v-model="quizSelectedValue[singleDropdown.id]"
17
- :options="singleDropdown.option"
18
- :disabled="quizCompleted"
19
- ></b-form-select>
20
- </div>
21
- </div>
22
- </template>
23
- <script>
24
- import $extendsQuiz from '../mixins/$quizMixins'
25
- export default {
26
- name: 'AppCompInputDropdown',
27
- mixins: [$extendsQuiz],
28
-
29
- props: {
30
- inputType: {
31
- type: String,
32
- default: ''
33
- },
34
- inputDataId: {
35
- type: String,
36
- default: ''
37
- },
38
- inputData: {
39
- type: Array,
40
- default: () => []
41
- },
42
- quizCompleted: {
43
- type: Boolean,
44
- default: false
45
- },
46
- solution: {
47
- type: Array,
48
- default: () => []
49
- },
50
- showSolution: {
51
- type: Boolean,
52
- default: false
53
- },
54
- shuffleAnswers: {
55
- type: Boolean,
56
- default: false
57
- },
58
- quizSelected: {
59
- type: Array,
60
- default: () => []
61
- }, //use to pass the value of the input
62
- quizSubmit: {
63
- type: Boolean,
64
- default: false
65
- } //use to call a submit
66
- },
67
-
68
- data() {
69
- return {
70
- quizSelectedValue: [] //not using quizSelected because quizSelected is a prop
71
- }
72
- },
73
-
74
- computed: {},
75
-
76
- watch: {
77
- /**
78
- * @description to pass value to AppCompQuiz
79
- * @emits input-change
80
- */
81
- quizSelectedValue(newValue) {
82
- this.$emit('input-change', newValue)
83
- },
84
-
85
- /**
86
- * @description to pass the value from AppCompQuiz
87
- */
88
- quizSelected(newValue) {
89
- this.quizSelectedValue = newValue
90
- }
91
- },
92
-
93
- mounted() {
94
- if (this.solution !== null)
95
- this.solution.sort(function(a, b) {
96
- return a.question_id - b.question_id
97
- })
98
- //to show the defaultAnswer
99
- const defaultAnswer = {
100
- value: null,
101
- disabled: true,
102
- text: this.$t('message.first_option_dropdown')
103
- }
104
- let selectedChoices = []
105
- for (let i = 0; i < this.inputData.length; i++) {
106
- let singleDropdown
107
- if (this.shuffleAnswers) {
108
- singleDropdown = this.inputData[i]
109
- singleDropdown.option = this.shuffleArray(singleDropdown.option)
110
- } else {
111
- singleDropdown = this.inputData[i]
112
- }
113
- if (
114
- this.inputData[i].option[0].text !==
115
- this.$t('message.first_option_dropdown')
116
- ) {
117
- singleDropdown.option.unshift(defaultAnswer)
118
- }
119
- selectedChoices.push(null)
120
- }
121
- if (this.quizSelected.length == 0) {
122
- this.quizSelectedValue = selectedChoices
123
- } else {
124
- this.quizSelectedValue = this.quizSelected
125
- }
126
- },
127
-
128
- methods: {
129
- /**
130
- * @description used by the dropdown quiz
131
- * @param {Array} answers what the user has answered
132
- * @param {Array} solution the correct choices
133
- * @returns {Boolean}
134
- * @todo Add a catching for error if the 2 question_id dont match
135
- */
136
- compareSelectedAnswers(answers, solution) {
137
- for (let index = 0; index < answers.length; index++) {
138
- const elementAnswers = answers[index]
139
- const elementSolution = solution[index]
140
- if (elementAnswers.question_id == elementSolution.question_id) {
141
- if (elementAnswers.reponse_id !== elementSolution.reponse_id) {
142
- return false
143
- }
144
- } else {
145
- return //if it return nothing there is a bug since this means the 2 question_id dont match
146
- }
147
- }
148
- return true
149
- },
150
-
151
- /**
152
- * @description check if a values exists in a array
153
- * @param {Array} array
154
- * @param value
155
- * @returns {Boolean}
156
- */
157
- containsValue(array, value) {
158
- return array.includes(value)
159
- },
160
-
161
- /**
162
- * @description shuffles an array used to randomized the option order if shuffleAnswers is true
163
- * @param {Array} array
164
- * @returns {Array}
165
- */
166
- shuffleArray(array) {
167
- let newArray = []
168
- let newArray2 = []
169
-
170
- for (let i = 0; i < array.length; i++) {
171
- const element = array[i]
172
- //todo remove null values
173
- newArray.push(element)
174
- }
175
- while (newArray.length > 0) {
176
- let pos = Math.floor(newArray.length * Math.random())
177
- newArray2.push(newArray[pos])
178
- newArray.splice(pos, 1)
179
- }
180
- return newArray2
181
- }
182
- }
183
- }
184
- </script>
@@ -1,169 +0,0 @@
1
- <template>
2
- <div class="input-box">
3
- <fieldset>
4
- <legend
5
- :id="`lgd_${inputDataId}`"
6
- class="sr-only"
7
- tabindex="-1"
8
- v-html="getQuizQuestion()"
9
- />
10
-
11
- <template v-for="choixReponse in inputDataValue">
12
- <div
13
- :Key="`div_chx_${inputDataId}-${choixReponse.id}`"
14
- class="box-radio"
15
- >
16
- <label
17
- :key="`lbl_chx_${inputDataId}_${choixReponse.id}`"
18
- :for="`chx_${inputDataId}_${choixReponse.id}`"
19
- :class="classInput(choixReponse.id)"
20
- class="radio-label"
21
- >
22
- <input
23
- :id="`chx_${inputDataId}_${choixReponse.id}`"
24
- :key="`chx_${inputDataId}_${choixReponse.id}`"
25
- v-model="quizInputUniqueValue"
26
- type="radio"
27
- :value="choixReponse.id"
28
- :name="`btn-radios-${inputDataId}`"
29
- :disabled="quizCompleted"
30
- class="radio-input"
31
- />
32
-
33
- <span class="radio-contenu" v-html="choixReponse.value" />
34
- <span
35
- :id="`${inputDataId}_${choixReponse.id}-msg-erreur`"
36
- :key="`msg_chx_${inputDataId}_${choixReponse.id}`"
37
- class="sr-only"
38
- >
39
- {{ messageAccessibility(choixReponse.id) }}
40
- </span>
41
- </label>
42
- </div>
43
- </template>
44
- </fieldset>
45
- </div>
46
- </template>
47
- <script>
48
- import $extendsQuiz from '../mixins/$quizMixins'
49
- export default {
50
- name: 'AppCompInputRadio',
51
- mixins: [$extendsQuiz],
52
-
53
- props: {
54
- inputType: {
55
- type: String,
56
- default: ''
57
- },
58
- inputDataId: {
59
- type: String,
60
- default: ''
61
- },
62
-
63
- inputData: {
64
- type: Array,
65
- default: () => []
66
- },
67
- quizCompleted: {
68
- type: Boolean,
69
- default: false
70
- },
71
- solution: {
72
- type: String,
73
- default: ''
74
- }, //may be null
75
- showSolution: {
76
- type: Boolean,
77
- default: false
78
- },
79
- shuffleAnswers: {
80
- type: Boolean,
81
- default: false
82
- },
83
- quizInputUnique: {
84
- type: String,
85
- default: ''
86
- }, //use to pass the value of the input
87
- quizSubmit: {
88
- type: Boolean,
89
- default: false
90
- }, //use to call a submit
91
- aBy: {
92
- type: String,
93
- default: ''
94
- } // use to pass id of the related question for the choices
95
- },
96
-
97
- data() {
98
- return {
99
- inputDataValue: [],
100
- quizInputUniqueValue: null //not using quizInputUnique because quizInputUnique is a prop
101
- }
102
- },
103
-
104
- computed: {},
105
-
106
- watch: {
107
- /**
108
- * @description to pass value to AppCompQuiz
109
- * @fires input-change to AppCompQuiz.vue
110
- */
111
- quizInputUniqueValue(newValue) {
112
- this.$emit('input-change', newValue)
113
- },
114
-
115
- /**
116
- * @description to pass the value from AppCompQuiz
117
- */
118
- quizInputUnique(newValue) {
119
- this.quizInputUniqueValue = newValue
120
- }
121
- },
122
-
123
- mounted() {
124
- this.quizInputUniqueValue = this.quizInputUnique
125
- if (this.shuffleAnswers) {
126
- this.inputDataValue = this.shuffleArray(this.inputData)
127
- } else {
128
- this.inputDataValue = this.inputData
129
- }
130
- },
131
-
132
- methods: {
133
- /**
134
- * @description shuffles an array used to randomized the option order if shuffleAnswers is true
135
- * @param {Array} array
136
- * @returns {Array}
137
- */
138
- shuffleArray(array) {
139
- let newArray = []
140
- let newArray2 = []
141
-
142
- for (let i = 0; i < array.length; i++) {
143
- const element = array[i]
144
- //todo remove null values
145
- newArray.push(element)
146
- }
147
- while (newArray.length > 0) {
148
- let pos = Math.floor(newArray.length * Math.random())
149
- newArray2.push(newArray[pos])
150
- newArray.splice(pos, 1)
151
- }
152
- return newArray2
153
- },
154
-
155
- /**
156
- * @description - Method to get the question
157
- */
158
- getQuizQuestion() {
159
- const el = document.querySelector(`#${this.aBy}`)
160
- if (!el || !el.innerHTML) return
161
- const labelFor =
162
- this.$i18n.locale === 'fr'
163
- ? 'Choix de reponse pour la'
164
- : 'Answers available for the'
165
- return `${labelFor} ${el.innerText}`
166
- }
167
- }
168
- }
169
- </script>
@@ -1,91 +0,0 @@
1
- <template>
2
- <div class="input-box">
3
- <b-form-textarea
4
- :id="`textArea_${inputDataId}`"
5
- v-model="quizTextAreaValue"
6
- :aria-labelledby="`textArea_${inputDataId}`"
7
- :class="classInput()"
8
- :placeholder="$t('text.place_holder.for_textarea')"
9
- :disabled="quizCompleted"
10
- rows="3"
11
- no-resize
12
- :aria-describedby="`${inputDataId}-msg-erreur`"
13
- ></b-form-textarea>
14
- <span :id="`${inputDataId}-msg-erreur`" class="sr-only">
15
- {{ messageAccessibility() }}
16
- </span>
17
- </div>
18
- </template>
19
- <script>
20
- import $extendsQuiz from '../mixins/$quizMixins'
21
- export default {
22
- name: 'AppCompInputTextBox',
23
- mixins: [$extendsQuiz],
24
-
25
- props: {
26
- inputType: {
27
- type: String,
28
- default: ''
29
- },
30
- inputDataId: {
31
- type: String,
32
- default: ''
33
- },
34
- inputData: {
35
- type: Array,
36
- default: () => []
37
- }, //not used just here to be the same
38
- quizCompleted: {
39
- type: Boolean,
40
- default: false
41
- },
42
- solution: {
43
- type: String,
44
- default: ''
45
- },
46
- showSolution: {
47
- type: Boolean,
48
- default: false
49
- },
50
- quizTextArea: {
51
- type: String,
52
- default: ''
53
- }, //use to pass the value of the input
54
- quizSubmit: {
55
- type: Boolean,
56
- default: false
57
- } //use to call a submit
58
- },
59
-
60
- data() {
61
- return {
62
- quizTextAreaValue: '' //not using quizTextArea because quizTextArea is a prop
63
- }
64
- },
65
-
66
- computed: {},
67
-
68
- watch: {
69
- /**
70
- * @description to pass value to AppCompQuiz
71
- * @fires input-change to AppCompQuiz.vue
72
- */
73
- quizTextAreaValue(newValue) {
74
- this.$emit('input-change', newValue)
75
- },
76
-
77
- /**
78
- * @description to pass the value from AppCompQuiz
79
- */
80
- quizTextArea(newValue) {
81
- this.quizTextAreaValue = newValue
82
- }
83
- },
84
-
85
- mounted() {
86
- this.quizTextAreaValue = this.quizTextArea
87
- },
88
-
89
- methods: {}
90
- }
91
- </script>
@@ -1,155 +0,0 @@
1
- <template>
2
- <div>
3
- <div v-for="textInput in inputDataValue" :key="textInput.id">
4
- <label
5
- :for="`${inputDataId}_${textInput.id}-champ`"
6
- v-html="textInput.ennonce"
7
- ></label>
8
- <b-form-input
9
- :id="`${inputDataId}_${textInput.id}-champ`"
10
- v-model="quizTextTableValue[textInput.id]"
11
- :class="classInput(textInput.id)"
12
- :placeholder="$t('text.place_holder.for_textarea')"
13
- :disabled="quizCompleted"
14
- rows="1"
15
- no-resize
16
- :aria-describedby="`${inputDataId}_${textInput.id}-msg-erreur`"
17
- ></b-form-input>
18
- <span :id="`${inputDataId}_${textInput.id}-msg-erreur`" class="sr-only">
19
- {{ messageAccessibility(textInput.id) }}
20
- </span>
21
- </div>
22
- </div>
23
- </template>
24
- <script>
25
- import $extendsQuiz from '../mixins/$quizMixins'
26
- export default {
27
- name: 'AppCompInputTextTable',
28
- mixins: [$extendsQuiz],
29
-
30
- props: {
31
- inputType: {
32
- type: String,
33
- default: ''
34
- },
35
- inputDataId: {
36
- type: String,
37
- default: ''
38
- },
39
- inputData: {
40
- type: Array,
41
- default: () => []
42
- },
43
- quizCompleted: {
44
- type: Boolean,
45
- default: false
46
- },
47
- solution: {
48
- type: Array,
49
- default: () => []
50
- },
51
- showSolution: {
52
- type: Boolean,
53
- default: false
54
- },
55
- shuffleAnswers: {
56
- type: Boolean,
57
- default: false
58
- },
59
- quizTextTable: {
60
- type: Array,
61
- default: () => []
62
- }, //use to pass the value of the input
63
- quizSubmit: {
64
- type: Boolean,
65
- default: false
66
- } //use to call a submit
67
- },
68
-
69
- data() {
70
- return {
71
- inputDataValue: [],
72
- quizTextTableValue: [] //not using quizTextTable because quizTextTable is a prop
73
- }
74
- },
75
-
76
- computed: {},
77
-
78
- watch: {
79
- /**
80
- * @description to pass value to AppCompQuiz
81
- * @fires input-change to AppCompQuiz.vue
82
- */
83
- quizTextTableValue(newValue) {
84
- this.$emit('input-change', newValue)
85
- },
86
-
87
- /**
88
- * @description to pass the value from AppCompQuiz
89
- */
90
- quizTextTable(newValue) {
91
- this.quizTextTableValue = newValue
92
- }
93
- },
94
-
95
- mounted() {
96
- if (this.solution !== null) {
97
- this.solution.sort(function(a, b) {
98
- return a.question_id - b.question_id
99
- })
100
- }
101
- let textChoices = []
102
-
103
- for (let i = 0; i < this.inputData.length; i++) {
104
- textChoices.push('')
105
- }
106
- //apply previous answers
107
- if (this.quizTextTable && this.quizTextTable.length == 0) {
108
- this.quizTextTableValue = textChoices
109
- } else {
110
- this.quizTextTableValue = this.quizTextTable
111
- }
112
-
113
- if (this.shuffleAnswers) {
114
- this.inputDataValue = this.shuffleArray(this.inputData)
115
- } else {
116
- this.inputDataValue = this.inputData
117
- }
118
- },
119
-
120
- methods: {
121
- /**
122
- * @description check if a values exists in a array
123
- * @param {Array} array
124
- * @param value
125
- * @returns {Boolean}
126
- */
127
- containsValue(array, value) {
128
- return array.includes(value)
129
- },
130
-
131
- /**
132
- * @description shuffles an array used to randomized the option order if shuffleAnswers is true
133
- * @param {Array} array
134
- * @returns {Array}
135
- */
136
- shuffleArray(array) {
137
- let newArray = []
138
- let newArray2 = []
139
-
140
- for (let i = 0; i < array.length; i++) {
141
- const element = array[i]
142
- //todo remove null values
143
- newArray.push(element)
144
- }
145
- while (newArray.length > 0) {
146
- let pos = Math.floor(newArray.length * Math.random())
147
- newArray2.push(newArray[pos])
148
- newArray.splice(pos, 1)
149
- }
150
- return newArray2
151
- }
152
- }
153
- }
154
- </script>
155
- <style lang="scss" scoped></style>