fcad-core-dragon 2.0.1 → 2.0.2-beta.2

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 (90) hide show
  1. package/.editorconfig +33 -33
  2. package/.eslintignore +29 -29
  3. package/.eslintrc.cjs +81 -81
  4. package/CHANGELOG +17 -1
  5. package/bk.scss +117 -117
  6. package/package.json +1 -1
  7. package/src/$locales/en.json +18 -4
  8. package/src/$locales/fr.json +17 -3
  9. package/src/assets/data/onboardingMessages.json +47 -47
  10. package/src/components/AppBase.vue +36 -341
  11. package/src/components/AppBaseErrorDisplay.vue +438 -438
  12. package/src/components/AppBaseFlipCard.vue +84 -84
  13. package/src/components/AppBaseModule.vue +16 -21
  14. package/src/components/AppBasePage.vue +45 -14
  15. package/src/components/AppBasePopover.vue +41 -41
  16. package/src/components/AppBaseSkeleton.vue +45 -0
  17. package/src/components/AppCompAudio.vue +12 -3
  18. package/src/components/AppCompButtonProgress.vue +13 -2
  19. package/src/components/AppCompCarousel.vue +12 -4
  20. package/src/components/AppCompInputCheckBoxNx.vue +324 -0
  21. package/src/components/AppCompInputDropdownNx.vue +295 -0
  22. package/src/components/AppCompInputRadioNx.vue +264 -0
  23. package/src/components/AppCompInputTextNx.vue +148 -0
  24. package/src/components/AppCompInputTextTableNx.vue +198 -0
  25. package/src/components/AppCompInputTextToFillDropdownNx.vue +291 -0
  26. package/src/components/AppCompInputTextToFillNx.vue +277 -0
  27. package/src/components/AppCompJauge.vue +11 -4
  28. package/src/components/AppCompMenu.vue +7 -14
  29. package/src/components/AppCompMenuItem.vue +7 -5
  30. package/src/components/AppCompNavigation.vue +21 -21
  31. package/src/components/AppCompNoteCall.vue +1 -0
  32. package/src/components/AppCompNoteCredit.vue +2 -1
  33. package/src/components/AppCompPlayBarNext.vue +94 -41
  34. package/src/components/AppCompPlayBarProgress.vue +82 -82
  35. package/src/components/AppCompPopUpNext.vue +6 -6
  36. package/src/components/AppCompQuiz.vue +500 -0
  37. package/src/components/AppCompQuizRecall.vue +113 -66
  38. package/src/components/AppCompSettingsMenu.vue +172 -172
  39. package/src/components/AppCompTableOfContent.vue +39 -10
  40. package/src/components/AppCompVideoPlayer.vue +1 -1
  41. package/src/components/AppCompViewDisplay.vue +6 -6
  42. package/src/composables/useQuiz.js +62 -179
  43. package/src/directives/nvdaFix.js +53 -0
  44. package/src/externalComps/ModuleView.vue +22 -22
  45. package/src/externalComps/SummaryView.vue +91 -91
  46. package/src/main.js +227 -30
  47. package/src/mixins/$mediaMixins.js +1 -11
  48. package/src/module/stores/appStore.js +29 -11
  49. package/src/module/xapi/Crypto/Hasher.js +241 -241
  50. package/src/module/xapi/Crypto/WordArray.js +278 -278
  51. package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
  52. package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -315
  53. package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
  54. package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
  55. package/src/module/xapi/Crypto/encoders/Base.js +105 -105
  56. package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
  57. package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
  58. package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
  59. package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
  60. package/src/module/xapi/Crypto/index.js +53 -53
  61. package/src/module/xapi/Statement/activity.js +47 -47
  62. package/src/module/xapi/Statement/agent.js +55 -55
  63. package/src/module/xapi/Statement/group.js +26 -26
  64. package/src/module/xapi/Statement/index.js +259 -259
  65. package/src/module/xapi/Statement/statement.js +253 -253
  66. package/src/module/xapi/Statement/statementRef.js +23 -23
  67. package/src/module/xapi/Statement/substatement.js +22 -22
  68. package/src/module/xapi/Statement/verb.js +36 -36
  69. package/src/module/xapi/activitytypes.js +17 -17
  70. package/src/module/xapi/utils.js +167 -167
  71. package/src/module/xapi/verbs.js +294 -294
  72. package/src/module/xapi/xapiStatement.js +444 -444
  73. package/src/plugins/bus.js +8 -8
  74. package/src/plugins/gsap.js +14 -14
  75. package/src/plugins/i18n.js +44 -44
  76. package/src/plugins/idb.js +1 -1
  77. package/src/plugins/save.js +37 -37
  78. package/src/plugins/scorm.js +287 -287
  79. package/src/plugins/xapi.js +11 -11
  80. package/src/public/index.html +33 -33
  81. package/src/shared/generalfuncs.js +134 -0
  82. package/src/shared/validators.js +308 -234
  83. package/src/components/AppCompInputCheckBoxNext.vue +0 -205
  84. package/src/components/AppCompInputDropdownNext.vue +0 -201
  85. package/src/components/AppCompInputRadioNext.vue +0 -158
  86. package/src/components/AppCompInputTextNext.vue +0 -124
  87. package/src/components/AppCompInputTextTableNext.vue +0 -142
  88. package/src/components/AppCompInputTextToFillDropdownNext.vue +0 -238
  89. package/src/components/AppCompInputTextToFillNext.vue +0 -171
  90. package/src/components/AppCompQuizNext.vue +0 -2908
@@ -1,2908 +0,0 @@
1
- <!-- About this Component--
2
- * Component to render a Quiz to user: question with serie of inputs
3
- * Receives the a quiz data object defined by user
4
- * Base on Quiz type will render a specific input type for the quiz
5
- * Example of use: in an page you can add a quiz/exercice by calling:
6
- ** <app-comp-quiz-next :quiz-data="my_quiz_data_json"/>
7
- ** where "my_quiz_data_json" is a json object of the your quiz/exercices
8
-
9
- -->
10
- <template>
11
- <v-row v-if="!errorQuizItems">
12
- <v-col
13
- v-if="quizData"
14
- cols="12"
15
- :class="[
16
- { 'container-quiz-radio': quizData.type_question == 'choix_unique' },
17
- { 'container-quiz-checkbox': quizData.type_question == 'choix_mult' },
18
- { 'container-quiz-dropdown': quizData.type_question == 'dropdown' },
19
- {
20
- 'container-quiz-text-area':
21
- quizData.type_question == 'reponse_ouverte'
22
- },
23
- {
24
- 'container-quiz-texte-troue-select':
25
- quizData.type_question == 'texte_troue_select'
26
- },
27
- {
28
- 'container-quiz-texte-tableau':
29
- quizData.type_question == 'texte_tableau'
30
- },
31
- {
32
- 'container-quiz-texte-troue': quizData.type_question == 'texte_troue'
33
- }
34
- ]"
35
- >
36
- <div
37
- :class="[
38
- { 'quiz-radio': quizData.type_question == 'choix_unique' },
39
- { 'quiz-checkbox': quizData.type_question == 'choix_mult' },
40
- { 'quiz-dropdown': quizData.type_question == 'dropdown' },
41
- { 'quiz-text-area': quizData.type_question == 'reponse_ouverte' },
42
- {
43
- 'quiz-texte-troue-select':
44
- quizData.type_question == 'texte_troue_select'
45
- },
46
- { 'quiz-texte-tableau': quizData.type_question == 'texte_tableau' },
47
- { 'quiz-texte-troue': quizData.type_question == 'texte_troue' }
48
- ]"
49
- >
50
- <div
51
- :id="`${quizData.type_question}_${quizData.id}`"
52
- class="quiz-question"
53
- >
54
- <span class="sr-only">question :</span>
55
- <div v-html="quizEnnonce" />
56
- </div>
57
-
58
- <component
59
- :is="quizComponent"
60
- :quiz-type="quizData.type_question"
61
- :input-data-id="quizData.id"
62
- :input-data="quizData.choix_reponse"
63
- :quiz-limit-active="attemptsReached"
64
- :quiz-input-type="quizInputType"
65
- :solution="quizData.solution"
66
- :show-solution="showSolution"
67
- :shuffle-answers="shuffleAnswers"
68
- :quiz-submit="quizSubmit"
69
- :text-base="quizData.texte_base"
70
- :a-by="`${quizData.type_question}_${quizData.id}`"
71
- @input-change="inputChange($event)"
72
- @quiz-submit="checkEntry($event)"
73
- />
74
-
75
- <div class="btn-ctrl-quiz">
76
- <app-base-button
77
- :id="`btn_quiz_${quizData.id}`"
78
- ref="quiz"
79
- class="btn-quiz btn-main"
80
- :is-disabled="quizIsNotAnswered || attemptsReached"
81
- :title="txtBtnSubmit"
82
- @click="validateAnswers"
83
- >
84
- {{ txtBtnSubmit }}
85
- </app-base-button>
86
- </div>
87
- </div>
88
- </v-col>
89
- <v-col cols="12" aria-live="polite" class="ctn-retro">
90
- <transition name="fade" mode="in-out">
91
- <div
92
- v-if="showSolution && showRetro"
93
- :class="`retro_inline_wrapper retro_inline_${retroType}`"
94
- :aria-label="retroAriaLabel"
95
- >
96
- <div class="retro-title-container">
97
- <span class="retro-title">{{ retroTitle }}</span>
98
- </div>
99
- <div class="retro-text-container" v-html="retroHtml"></div>
100
- </div>
101
- </transition>
102
- </v-col>
103
- </v-row>
104
- <app-base-error-display
105
- v-else-if="errorQuizItems"
106
- :error-group="'component'"
107
- :error-title="'ERREUR: COMPOSANT DE QUIZ'"
108
- :errors-list="errorQuizItems"
109
- />
110
- </template>
111
- <script>
112
- import { mapState } from 'pinia'
113
- import { useAppStore } from '../module/stores/appStore'
114
- import { defineAsyncComponent } from 'vue'
115
- import { computed } from 'vue'
116
-
117
- export default {
118
- name: 'AppCompQuiz',
119
- components: {
120
- AppCompInputTextBox: defineAsyncComponent(
121
- () => import('./AppCompInputTextNext.vue')
122
- ),
123
- AppCompInputCheckBox: defineAsyncComponent(
124
- () => import('./AppCompInputCheckBoxNext.vue')
125
- ),
126
- AppCompInputDropdown: defineAsyncComponent(
127
- () => import('./AppCompInputDropdownNext.vue')
128
- ),
129
- AppCompInputRadio: defineAsyncComponent(
130
- () => import('./AppCompInputRadioNext.vue')
131
- ),
132
- AppCompInputTextToFillDropdown: defineAsyncComponent(
133
- () => import('./AppCompInputTextToFillDropdownNext.vue')
134
- ),
135
- AppCompInputTextTable: defineAsyncComponent(
136
- () => import('./AppCompInputTextTableNext.vue')
137
- ),
138
- AppCompInputTextToFill: defineAsyncComponent(
139
- () => import('./AppCompInputTextToFillNext.vue')
140
- )
141
- },
142
- inject: ['userInteraction'],
143
- provide() {
144
- return {
145
- quizAssociation: computed(() => this.quizAssociation),
146
- quizDragDrop: computed(() => this.quizDragDrop),
147
- quizSubmit: computed(() => this.quizSubmit), //added to explod comp^
148
- initQuizSelected: computed(() => this.initQuizSelected), //value of the saved answers of the dropdown quiz
149
- initQuizTable: computed(() => this.initQuizTable) //value of the saved answers of the table quiz
150
- // quizType: this.quizComponent
151
- }
152
- },
153
- props: {
154
- consigne: {
155
- type: Boolean,
156
- default: true
157
- },
158
- shuffleAnswers: {
159
- type: Boolean,
160
- default: false
161
- },
162
-
163
- quizData: {
164
- type: Object,
165
- validator: function (value) {
166
- //verify that element has all required properties
167
- if (
168
- value.id &&
169
- value.type_question &&
170
- value.ennonce &&
171
- value.retroaction
172
- ) {
173
- return true
174
- } else {
175
- console.warn(
176
- '%c WARNING!>>> AppCompQuiz: Your quizData is not valid',
177
- 'background: orange; color: white; display: block; margin:5px;'
178
- )
179
- if (!value.id) {
180
- console.warn(
181
- '%c WARNING!>>> AppCompQuiz: Your quizData id is missing',
182
- 'background: orange; color: white; display: block; margin:5px;'
183
- )
184
- }
185
- if (!value.type_question) {
186
- console.warn(
187
- '%c WARNING!>>> AppCompQuiz: Your quizData type_question is missing',
188
- 'background: orange; color: white; display: block; margin:5px;'
189
- )
190
- }
191
- if (!value.ennonce) {
192
- console.warn(
193
- '%c WARNING!>>> AppCompQuiz: Your quizData ennonce is missing',
194
- 'background: orange; color: white; display: block; margin:5px;'
195
- )
196
- }
197
- if (!value.retroaction) {
198
- console.warn(
199
- '%c WARNING!>>> AppCompQuiz: Your quizData retroaction is missing',
200
- 'background: orange; color: white; display: block; margin:5px;'
201
- )
202
- }
203
- return false
204
- }
205
- },
206
- default: () => {}
207
- }
208
- },
209
- setup(props) {
210
- const { quizData } = props
211
-
212
- const defaultInputType = computed(() => {
213
- const { type_question } = quizData
214
- let inputToReturn = null
215
- const arrayType = [
216
- 'texte_tableau',
217
- 'texte_troue_select',
218
- 'texte_troue',
219
- 'choix_mult',
220
- 'dropdown'
221
- ]
222
- const objectType = []
223
- const boolType = []
224
- const stringType = ['choix_unique', 'reponse_ouverte']
225
-
226
- switch (true) {
227
- case arrayType.includes(type_question):
228
- inputToReturn = []
229
-
230
- break
231
-
232
- case objectType.includes(type_question):
233
- inputToReturn = {}
234
- break
235
-
236
- case stringType.includes(type_question):
237
- inputToReturn = ''
238
- break
239
-
240
- case boolType.includes(type_question):
241
- inputToReturn = null
242
- break
243
- }
244
- return inputToReturn
245
- })
246
- return { defaultInputType }
247
- },
248
- data() {
249
- return {
250
- totalAttempts: 0, //added (to be replace by scrom)
251
- showSolution: false, //used for when a quiz displays it solution
252
- quizCompleted: false,
253
- quizInputType: this.defaultInputType,
254
- quizAssociation: {},
255
- quizDragDrop: {},
256
- quizSubmit: false, //added to explod comp^
257
- initQuizSelected: [], //value of the saved answers of the dropdown quiz
258
- initQuizTable: [], //value of the saved answers of the table quiz
259
- retroType: '',
260
- retroTitle: '',
261
- retroHtml: '',
262
- showRetro: false,
263
- oldQuizValue: null
264
- }
265
- },
266
- computed: {
267
- ...mapState(useAppStore, [
268
- 'getUserInteraction',
269
- 'getPageInteraction',
270
- 'getCurrentPage',
271
- 'getConnectionInfo',
272
- 'getDataFromServer'
273
- ]),
274
- retroAriaLabel() {
275
- let label = ''
276
- switch (this.retroType) {
277
- case 'neutral':
278
- label = this.$t('quizState.neutralAnswer')
279
- break
280
- case 'positive':
281
- label = this.$t('quizState.goodAnswer')
282
- break
283
- case 'negative':
284
- label = this.$t('quizState.badAnswer')
285
- break
286
- }
287
- return label
288
- },
289
- /**
290
- * @description To control whether or not the submit button is disabled
291
- * @returns {Boolean} true if the quiz is not yet answered, false the button is enable
292
- */
293
- quizIsNotAnswered() {
294
- const { type_question, choix_reponse, texte_base, solution } =
295
- this.quizData
296
- let notAnswer = false
297
-
298
- switch (true) {
299
- case ['choix_unique', 'reponse_ouverte'].includes(type_question):
300
- if (!this.quizInputType) {
301
- notAnswer = true
302
- }
303
- break
304
- case type_question == 'choix_mult':
305
- if (this.quizInputType.length == 0) notAnswer = true
306
- break
307
- case ['dropdown', 'texte_troue_select', 'texte_tableau'].includes(
308
- type_question
309
- ): {
310
- const searchedVal = type_question == 'texte_tableau' ? '' : null
311
- if (
312
- this.quizInputType.length < choix_reponse.length ||
313
- this.$helper.containsValue(this.quizInputType, searchedVal)
314
- )
315
- notAnswer = true
316
- break
317
- }
318
-
319
- case type_question == 'texte_troue':
320
- if (texte_base) {
321
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
322
- let matchAll = texte_base.split(regex)
323
-
324
- if (
325
- this.quizInputType.length < matchAll.length - 1 ||
326
- this.$helper.containsValue(this.quizInputType, '')
327
- ) {
328
- notAnswer = true
329
- }
330
- }
331
- break
332
- case type_question == 'association':
333
- if (
334
- this.quizAssociation &&
335
- (Object.keys(this.quizAssociation).length <
336
- Object.keys(solution).length ||
337
- this.$helper.containsValue(
338
- Object.values(this.quizAssociation),
339
- ''
340
- ))
341
- ) {
342
- notAnswer = true
343
- }
344
- break
345
- case type_question == 'dragdrop':
346
- if (this.quizDragDrop && Object.values(this.quizDragDrop)) {
347
- for (
348
- let index = 0;
349
- index < Object.values(this.quizDragDrop).length;
350
- index++
351
- ) {
352
- const element = Object.values(this.quizDragDrop)[index]
353
- if (element.length >= 0) {
354
- notAnswer = false
355
- }
356
- }
357
- } else notAnswer = true
358
- break
359
- }
360
-
361
- return notAnswer
362
- },
363
-
364
- /**
365
- * @description To control whether or not the reset button is disabled
366
- * @returns {Boolean} true if the quiz is not yet started, false the button is enable
367
- */
368
- quizIsNotStarted() {
369
- const { type_question } = this.quizData
370
- if (this.quizCompleted) {
371
- return true
372
- } else {
373
- switch (true) {
374
- case ['choix_unique', 'reponse_ouverte'].includes(type_question):
375
- if (this.quizInputType) {
376
- return true
377
- }
378
- break
379
- case type_question == 'choix_mult':
380
- if (this.quizInputType.length == 0) {
381
- return true
382
- }
383
- break
384
- case [
385
- 'dropdown',
386
- 'texte_troue_select',
387
- 'texte_tableau',
388
- 'texte_troue'
389
- ].includes(type_question):
390
- if (this.quizInputType.length == 0) {
391
- return true
392
- } else {
393
- for (let index = 0; index < this.quizInputType.length; index++) {
394
- const element = this.quizInputType[index]
395
- if (element !== null || element == '') {
396
- return false
397
- }
398
- }
399
- return true
400
- }
401
- }
402
- return false
403
- }
404
- },
405
- /**
406
- * @description
407
- * @returns {string} the componant of the quiz input
408
- */
409
- quizComponent() {
410
- const { type_question } = this.quizData
411
- let value
412
- switch (type_question) {
413
- case 'choix_unique':
414
- value = 'app-comp-input-radio'
415
- break
416
- case 'choix_mult':
417
- value = 'app-comp-input-check-box'
418
- break
419
- case 'dropdown':
420
- value = 'app-comp-input-dropdown'
421
- break
422
- case 'texte_troue_select':
423
- value = 'app-comp-input-text-to-fill-dropdown'
424
- break
425
- case 'reponse_ouverte':
426
- value = 'app-comp-input-text-box'
427
- break
428
- case 'texte_tableau':
429
- value = 'app-comp-input-text-table'
430
- break
431
- case 'texte_troue':
432
- value = 'app-comp-input-text-to-fill'
433
- break
434
- }
435
- return value
436
- },
437
- /**
438
- * @description controls the showin of warning in the page when a prop is wrongly passed
439
- */
440
- errorQuizItems() {
441
- let err = false
442
- let errorList = [] //array for errors dectected
443
-
444
- if (this.quizData) {
445
- const {
446
- type_question,
447
- ennonce,
448
- retroaction,
449
- id,
450
- choix_reponse,
451
- texte_base,
452
- solution
453
- } = this.quizData
454
- //pour les paramettre de quizData present pour tous les quiz
455
- if (!id && !errorList.includes('id')) {
456
- errorList.push('id')
457
- console.warn(
458
- '%c WARNING!>>> AppCompQuiz: Your quizData id is missing',
459
- 'background: orange; color: white; display: block; margin:5px;'
460
- )
461
- }
462
- if (!ennonce && !errorList.includes('ennonce')) {
463
- errorList.push('ennonce')
464
- console.warn(
465
- '%c WARNING!>>> AppCompQuiz: Your quizData ennonce is missing',
466
- 'background: orange; color: white; display: block; margin:5px;'
467
- )
468
- }
469
- if (!retroaction && !errorList.includes('retroaction')) {
470
- errorList.push('retroaction')
471
- console.warn(
472
- '%c WARNING!>>> AppCompQuiz: Your quizData retroaction is missing',
473
- 'background: orange; color: white; display: block; margin:5px;'
474
- )
475
- }
476
-
477
- let typeQuestionList = [
478
- 'choix_unique',
479
- 'choix_mult',
480
- 'dropdown',
481
- 'texte_troue_select',
482
- 'reponse_ouverte',
483
- 'texte_tableau',
484
- 'texte_troue',
485
- 'association',
486
- 'dragdrop'
487
- ]
488
- if (!type_question && !errorList.includes('type_question')) {
489
- errorList.push('type_question')
490
- console.warn(
491
- '%c WARNING!>>> AppCompQuiz: Your quizData type_question is missing',
492
- 'background: orange; color: white; display: block; margin:5px;'
493
- )
494
- } else if (!typeQuestionList.includes(type_question)) {
495
- errorList.push(
496
- "type_question n'est pas un des type suivant: 'choix_unique', 'choix_mult', 'dropdown', 'texte_troue_select', 'reponse_ouverte', 'texte_tableau', 'texte_troue', 'association' ou 'dragdrop'"
497
- )
498
- console.warn(
499
- "%c WARNING!>>> AppCompQuiz: Your quizData type_question is not 'choix_unique', 'choix_mult', 'dropdown', 'texte_troue_select', 'reponse_ouverte', 'texte_tableau', 'texte_troue', 'association' or 'dragdrop'",
500
- 'background: orange; color: white; display: block; margin:5px;'
501
- )
502
- } else {
503
- //pour les paramettre de quizData present pour certains des quiz
504
- switch (type_question) {
505
- case 'choix_unique':
506
- if (
507
- solution &&
508
- typeof solution !== 'string' &&
509
- !errorList.includes('solution')
510
- ) {
511
- errorList.push('solution')
512
- console.warn(
513
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
514
- 'background: orange; color: white; display: block; margin:5px;'
515
- )
516
- }
517
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
518
- errorList.push('choix_reponse')
519
- console.warn(
520
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
521
- 'background: orange; color: white; display: block; margin:5px;'
522
- )
523
- } else if (
524
- !choix_reponse.length &&
525
- !errorList.includes('choix_reponse')
526
- ) {
527
- errorList.push('choix_reponse')
528
- console.warn(
529
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
530
- 'background: orange; color: white; display: block; margin:5px;'
531
- )
532
- } else {
533
- choix_reponse.forEach((element) => {
534
- if (!element.id && !errorList.includes('choix_reponse id')) {
535
- errorList.push('choix_reponse id')
536
- console.warn(
537
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse id is missing',
538
- 'background: orange; color: white; display: block; margin:5px;'
539
- )
540
- }
541
- if (
542
- !element.value &&
543
- !errorList.includes('choix_reponse value')
544
- ) {
545
- errorList.push('choix_reponse value')
546
- console.warn(
547
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse value is missing',
548
- 'background: orange; color: white; display: block; margin:5px;'
549
- )
550
- }
551
- })
552
- }
553
- break
554
- case 'choix_mult':
555
- if (
556
- solution &&
557
- !Array.isArray(solution) &&
558
- !errorList.includes('solution')
559
- ) {
560
- errorList.push('solution')
561
- console.warn(
562
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
563
- 'background: orange; color: white; display: block; margin:5px;'
564
- )
565
- } else if (solution) {
566
- solution.forEach((element) => {
567
- if (
568
- typeof element !== 'string' &&
569
- !errorList.includes('solution')
570
- ) {
571
- errorList.push('solution')
572
- console.warn(
573
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is not a string missing',
574
- 'background: orange; color: white; display: block; margin:5px;'
575
- )
576
- }
577
- })
578
- }
579
-
580
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
581
- errorList.push('choix_reponse')
582
- console.warn(
583
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
584
- 'background: orange; color: white; display: block; margin:5px;'
585
- )
586
- } else if (
587
- !choix_reponse.length &&
588
- !errorList.includes('choix_reponse')
589
- ) {
590
- errorList.push('choix_reponse')
591
- console.warn(
592
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is not an array',
593
- 'background: orange; color: white; display: block; margin:5px;'
594
- )
595
- } else {
596
- choix_reponse.forEach((element) => {
597
- if (!element.id && !errorList.includes('choix_reponse id')) {
598
- errorList.push('choix_reponse id')
599
- console.warn(
600
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse id is missing',
601
- 'background: orange; color: white; display: block; margin:5px;'
602
- )
603
- }
604
- if (
605
- !element.value &&
606
- !errorList.includes('choix_reponse value')
607
- ) {
608
- errorList.push('choix_reponse value')
609
- console.warn(
610
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse value is missing',
611
- 'background: orange; color: white; display: block; margin:5px;'
612
- )
613
- }
614
- })
615
- }
616
- break
617
- case 'dropdown':
618
- if (
619
- solution &&
620
- !Array.isArray(solution) &&
621
- !errorList.includes('solution')
622
- ) {
623
- errorList.push('solution')
624
- console.warn(
625
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
626
- 'background: orange; color: white; display: block; margin:5px;'
627
- )
628
- } else if (solution) {
629
- if (solution.length == choix_reponse.length) {
630
- solution.forEach((element) => {
631
- if (
632
- typeof element !== 'string' &&
633
- !errorList.includes('solution')
634
- ) {
635
- errorList.push('solution')
636
- console.warn(
637
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is not a string',
638
- 'background: orange; color: white; display: block; margin:5px;'
639
- )
640
- }
641
- })
642
- } else {
643
- errorList.push(
644
- 'solution length does not match choix_reponse length'
645
- )
646
- console.warn(
647
- '%c WARNING!>>> AppCompQuiz: Your quizData solution length does not match your quizData choix_reponse length',
648
- 'background: orange; color: white; display: block; margin:5px;'
649
- )
650
- }
651
- }
652
-
653
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
654
- errorList.push('choix_reponse')
655
- console.warn(
656
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
657
- 'background: orange; color: white; display: block; margin:5px;'
658
- )
659
- } else if (
660
- !choix_reponse.length &&
661
- !errorList.includes('choix_reponse')
662
- ) {
663
- errorList.push('choix_reponse')
664
- console.warn(
665
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is not an array',
666
- 'background: orange; color: white; display: block; margin:5px;'
667
- )
668
- } else {
669
- choix_reponse.forEach((element) => {
670
- if (!element.id && !errorList.includes('choix_reponse id')) {
671
- errorList.push('choix_reponse id')
672
- console.warn(
673
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse id is missing',
674
- 'background: orange; color: white; display: block; margin:5px;'
675
- )
676
- }
677
- if (
678
- !element.ennonce &&
679
- !errorList.includes('choix_reponse ennonce')
680
- ) {
681
- errorList.push('choix_reponse ennonce')
682
- console.warn(
683
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse ennonce is missing',
684
- 'background: orange; color: white; display: block; margin:5px;'
685
- )
686
- }
687
-
688
- if (
689
- !element.option &&
690
- !errorList.includes('choix_reponse option')
691
- ) {
692
- errorList.push('choix_reponse option')
693
- console.warn(
694
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is missing',
695
- 'background: orange; color: white; display: block; margin:5px;'
696
- )
697
- } else if (
698
- !element.option.length &&
699
- !errorList.includes('choix_reponse option')
700
- ) {
701
- errorList.push('choix_reponse option')
702
- console.warn(
703
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is not an array',
704
- 'background: orange; color: white; display: block; margin:5px;'
705
- )
706
- } else {
707
- element.option.forEach((element2) => {
708
- if (
709
- typeof element2 !== 'string' &&
710
- !errorList.includes('choix_reponse option')
711
- ) {
712
- if (typeof element2 !== 'object') {
713
- errorList.push('choix_reponse option')
714
- console.warn(
715
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is not an object',
716
- 'background: orange; color: white; display: block; margin:5px;'
717
- )
718
- } else if (element2.value !== null) {
719
- errorList.push('choix_reponse option')
720
- }
721
- }
722
- })
723
- }
724
- })
725
- }
726
-
727
- break
728
- case 'texte_troue_select':
729
- if (
730
- solution &&
731
- !Array.isArray(solution) &&
732
- !errorList.includes('solution')
733
- ) {
734
- errorList.push('solution')
735
- console.warn(
736
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is not an array',
737
- 'background: orange; color: white; display: block; margin:5px;'
738
- )
739
- } else if (solution) {
740
- if (choix_reponse) {
741
- if (solution.length == choix_reponse.length) {
742
- solution.forEach((element) => {
743
- if (
744
- typeof element !== 'object' &&
745
- !errorList.includes('solution')
746
- ) {
747
- errorList.push('solution')
748
- console.warn(
749
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is not an array of object',
750
- 'background: orange; color: white; display: block; margin:5px;'
751
- )
752
- }
753
- })
754
- } else {
755
- errorList.push(
756
- 'solution length does not match choix_reponse length'
757
- )
758
- console.warn(
759
- '%c WARNING!>>> AppCompQuiz: Your quizData solution length does not match your quizData choix_reponse length',
760
- 'background: orange; color: white; display: block; margin:5px;'
761
- )
762
- }
763
- }
764
- }
765
-
766
- if (
767
- (!texte_base || typeof texte_base !== 'string') &&
768
- !errorList.includes('texte_base')
769
- ) {
770
- errorList.push('texte_base')
771
- console.warn(
772
- '%c WARNING!>>> AppCompQuiz: Your quizData texte_base is not a string',
773
- 'background: orange; color: white; display: block; margin:5px;'
774
- )
775
- } else {
776
- if (solution) {
777
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
778
- let textSplit = texte_base.split(regex)
779
- let textSplit2 = texte_base.match(regex)
780
- if (textSplit.length - 1 !== solution.length) {
781
- errorList.push(
782
- 'amount of holes in texte_base does not match solution length'
783
- )
784
- console.warn(
785
- '%c WARNING!>>> AppCompQuiz: the amount of holes in quizData texte_base does not match quizData solution length',
786
- 'background: orange; color: white; display: block; margin:5px;'
787
- )
788
- } else {
789
- for (let index = 0; index < choix_reponse.length; index++) {
790
- const element = Object.keys(choix_reponse[index])[0]
791
- const element2 = textSplit2[index].slice(2, -2)
792
- if (
793
- element !== element2 &&
794
- !errorList.includes(
795
- 'choix_reponse keys and texte_base keys dont match'
796
- )
797
- ) {
798
- errorList.push(
799
- 'choix_reponse keys and texte_base keys dont match'
800
- )
801
- console.warn(
802
- '%c WARNING!>>> AppCompQuiz: quizData choix_reponse keys and quizData texte_base keys dont match',
803
- 'background: orange; color: white; display: block; margin:5px;'
804
- )
805
- } else if (
806
- !errorList.includes('solution') &&
807
- !errorList.includes(
808
- 'choix_reponse keys and texte_base keys dont match'
809
- )
810
- ) {
811
- const element3 = Object.keys(solution[index])[0]
812
- if (
813
- element3 !== element2 &&
814
- !errorList.includes(
815
- 'solution keys and texte_base keys dont match'
816
- )
817
- ) {
818
- errorList.push(
819
- 'solution keys and texte_base keys dont match'
820
- )
821
- console.warn(
822
- '%c WARNING!>>> AppCompQuiz:quizData solution keys and quizData texte_base keys dont match',
823
- 'background: orange; color: white; display: block; margin:5px;'
824
- )
825
- }
826
- }
827
- }
828
- }
829
- }
830
- }
831
-
832
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
833
- errorList.push('choix_reponse')
834
- console.warn(
835
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
836
- 'background: orange; color: white; display: block; margin:5px;'
837
- )
838
- } else if (
839
- !choix_reponse.length &&
840
- !errorList.includes('choix_reponse')
841
- ) {
842
- errorList.push('choix_reponse')
843
- console.warn(
844
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is not an array',
845
- 'background: orange; color: white; display: block; margin:5px;'
846
- )
847
- } else {
848
- choix_reponse.forEach((element) => {
849
- if (
850
- !Object.values(element)[0] &&
851
- !errorList.includes('choix_reponse option')
852
- ) {
853
- errorList.push('choix_reponse option')
854
- console.warn(
855
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is missing',
856
- 'background: orange; color: white; display: block; margin:5px;'
857
- )
858
- } else if (
859
- !Object.values(element)[0].length &&
860
- !errorList.includes('choix_reponse option')
861
- ) {
862
- errorList.push('choix_reponse option')
863
- console.warn(
864
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is not an array',
865
- 'background: orange; color: white; display: block; margin:5px;'
866
- )
867
- } else {
868
- Object.values(element)[0].forEach((element2) => {
869
- if (
870
- typeof element2 !== 'string' &&
871
- !errorList.includes('choix_reponse option')
872
- ) {
873
- if (typeof element2 !== 'object') {
874
- errorList.push('choix_reponse option')
875
- console.warn(
876
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse option is not an array of strings or an array of objects',
877
- 'background: orange; color: white; display: block; margin:5px;'
878
- )
879
- } else if (element2.value !== null) {
880
- errorList.push('choix_reponse option')
881
- }
882
- }
883
- })
884
- }
885
- })
886
- }
887
-
888
- break
889
- case 'reponse_ouverte':
890
- if (choix_reponse !== null) {
891
- errorList.push(
892
- 'choix_reponse doit être mis a null pour un quiz de type reponse_ouverte'
893
- )
894
- console.warn(
895
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is must be null for reponse_ouverte',
896
- 'background: orange; color: white; display: block; margin:5px;'
897
- )
898
- }
899
- break
900
- case 'texte_tableau':
901
- if (
902
- solution &&
903
- !Array.isArray(solution) &&
904
- !errorList.includes('solution')
905
- ) {
906
- errorList.push('solution')
907
- console.warn(
908
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
909
- 'background: orange; color: white; display: block; margin:5px;'
910
- )
911
- } else if (solution) {
912
- if (choix_reponse) {
913
- if (solution.length == choix_reponse.length) {
914
- solution.forEach((element) => {
915
- if (typeof element == 'object') {
916
- if (
917
- (!element.question_id ||
918
- typeof element.question_id !== 'string') &&
919
- !errorList.includes('solution question_id')
920
- ) {
921
- errorList.push('solution question_id')
922
- console.warn(
923
- '%c WARNING!>>> AppCompQuiz: Your quizData solution element question_id is not a string',
924
- 'background: orange; color: white; display: block; margin:5px;'
925
- )
926
- }
927
- if (
928
- (!element.reponse_value ||
929
- Array.isArray(element.reponse_value)) &&
930
- !errorList.includes('solution reponse_id')
931
- ) {
932
- element.reponse_value.forEach((element2) => {
933
- if (
934
- typeof element2 !== 'string' &&
935
- !errorList.includes('solution reponse_value')
936
- ) {
937
- errorList.push('solution reponse_value')
938
- console.warn(
939
- '%c WARNING!>>> AppCompQuiz: Your quizData solution element reponse_value is not a string',
940
- 'background: orange; color: white; display: block; margin:5px;'
941
- )
942
- }
943
- })
944
- } else if (
945
- !errorList.includes('solution reponse_value')
946
- ) {
947
- errorList.push('solution reponse_value')
948
- }
949
- } else if (!errorList.includes('solution')) {
950
- errorList.push('solution')
951
- }
952
- })
953
- } else {
954
- errorList.push(
955
- 'solution length does not match choix_reponse length'
956
- )
957
- console.warn(
958
- '%c WARNING!>>> AppCompQuiz: Your quizData solution length does not match your quizData choix_reponse length',
959
- 'background: orange; color: white; display: block; margin:5px;'
960
- )
961
- }
962
- }
963
- }
964
-
965
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
966
- errorList.push('choix_reponse')
967
- console.warn(
968
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
969
- 'background: orange; color: white; display: block; margin:5px;'
970
- )
971
- } else if (
972
- !choix_reponse.length &&
973
- !errorList.includes('choix_reponse')
974
- ) {
975
- errorList.push('choix_reponse')
976
- console.warn(
977
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is noty an array',
978
- 'background: orange; color: white; display: block; margin:5px;'
979
- )
980
- } else {
981
- choix_reponse.forEach((element) => {
982
- if (!element.id && !errorList.includes('choix_reponse id')) {
983
- errorList.push('choix_reponse id')
984
- console.warn(
985
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse element id is missing',
986
- 'background: orange; color: white; display: block; margin:5px;'
987
- )
988
- }
989
- if (
990
- !element.ennonce &&
991
- !errorList.includes('choix_reponse ennonce')
992
- ) {
993
- errorList.push('choix_reponse ennonce')
994
- console.warn(
995
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse element ennonce is missing',
996
- 'background: orange; color: white; display: block; margin:5px;'
997
- )
998
- }
999
- })
1000
- }
1001
- break
1002
- case 'texte_troue':
1003
- if (
1004
- solution &&
1005
- !Array.isArray(solution) &&
1006
- !errorList.includes('solution')
1007
- ) {
1008
- errorList.push('solution')
1009
- console.warn(
1010
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
1011
- 'background: orange; color: white; display: block; margin:5px;'
1012
- )
1013
- } else if (solution) {
1014
- solution.forEach((element) => {
1015
- if (typeof element == 'object') {
1016
- let elementValue = Object.values(element)
1017
- if (
1018
- !elementValue.length == 1 &&
1019
- !errorList.includes('une solution a trop de clef')
1020
- ) {
1021
- errorList.push('une solution a trop de clef')
1022
- console.warn(
1023
- '%c WARNING!>>> AppCompQuiz: Your quizData solution has too many keys',
1024
- 'background: orange; color: white; display: block; margin:5px;'
1025
- )
1026
- } else if (Array.isArray(elementValue[0])) {
1027
- elementValue[0].forEach((element2) => {
1028
- if (
1029
- typeof element2 !== 'string' &&
1030
- !errorList.includes('solution reponse_value')
1031
- ) {
1032
- errorList.push('solution reponse_value')
1033
- console.warn(
1034
- '%c WARNING!>>> AppCompQuiz: Your quizData solution reponse_value is not a string or an array',
1035
- 'background: orange; color: white; display: block; margin:5px;'
1036
- )
1037
- }
1038
- })
1039
- } else if (!errorList.includes('solution reponse_value')) {
1040
- errorList.push('solution reponse_value')
1041
- console.warn(
1042
- '%c WARNING!>>> AppCompQuiz: Your quizData solution reponse_value is not an array or a string',
1043
- 'background: orange; color: white; display: block; margin:5px;'
1044
- )
1045
- }
1046
- } else if (!errorList.includes('solution')) {
1047
- errorList.push('solution')
1048
- console.warn(
1049
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is not an object',
1050
- 'background: orange; color: white; display: block; margin:5px;'
1051
- )
1052
- }
1053
- })
1054
- }
1055
- if (
1056
- (!texte_base || typeof texte_base !== 'string') &&
1057
- !errorList.includes('texte_base')
1058
- ) {
1059
- errorList.push('texte_base')
1060
- console.warn(
1061
- '%c WARNING!>>> AppCompQuiz: Your quizData texte_base is not a string',
1062
- 'background: orange; color: white; display: block; margin:5px;'
1063
- )
1064
- } else {
1065
- if (solution) {
1066
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
1067
- let textSplit = texte_base.split(regex)
1068
- let textSplit2 = texte_base.match(regex)
1069
- if (textSplit.length - 1 !== solution.length) {
1070
- errorList.push(
1071
- 'amount of holes in texte_base does not match solution length'
1072
- )
1073
- console.warn(
1074
- '%c WARNING!>>> AppCompQuiz: The amount of holes in texte_base does not match solution length',
1075
- 'background: orange; color: white; display: block; margin:5px;'
1076
- )
1077
- } else {
1078
- for (let index = 0; index < solution.length; index++) {
1079
- const element = Object.keys(solution[index])[0]
1080
- const element2 = textSplit2[index].slice(2, -2)
1081
- if (
1082
- element !== element2 &&
1083
- !errorList.includes(
1084
- 'solution keys and texte_base keys dont match'
1085
- )
1086
- ) {
1087
- errorList.push(
1088
- 'solution keys and texte_base keys dont match'
1089
- )
1090
- console.warn(
1091
- '%c WARNING!>>> AppCompQuiz: solution keys and texte_base keys dont match',
1092
- 'background: orange; color: white; display: block; margin:5px;'
1093
- )
1094
- }
1095
- }
1096
- }
1097
- }
1098
- }
1099
- break
1100
- case 'association':
1101
- if (
1102
- solution &&
1103
- typeof solution !== 'object' &&
1104
- !errorList.includes('solution')
1105
- ) {
1106
- errorList.push('solution')
1107
- console.warn(
1108
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
1109
- 'background: orange; color: white; display: block; margin:5px;'
1110
- )
1111
- }
1112
-
1113
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
1114
- errorList.push('choix_reponse')
1115
- console.warn(
1116
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
1117
- 'background: orange; color: white; display: block; margin:5px;'
1118
- )
1119
- } else {
1120
- if (
1121
- choix_reponse.zone_depots &&
1122
- choix_reponse.choix_deplaceable
1123
- ) {
1124
- if (
1125
- Array.isArray(choix_reponse.zone_depots) &&
1126
- Array.isArray(choix_reponse.choix_deplaceable)
1127
- ) {
1128
- if (
1129
- choix_reponse.zone_depots.length ==
1130
- choix_reponse.choix_deplaceable.length
1131
- ) {
1132
- if (solution && typeof solution == 'object') {
1133
- if (
1134
- Object.keys(solution).length !==
1135
- choix_reponse.zone_depots.length &&
1136
- !errorList.includes(
1137
- 'choix_reponse zone_depot choix_deplaceable and solution'
1138
- )
1139
- ) {
1140
- errorList.push(
1141
- 'choix_reponse zone_depot choix_deplaceable and solution'
1142
- )
1143
- console.warn(
1144
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot/choix_deplaceable and solution do not have matching size',
1145
- 'background: orange; color: white; display: block; margin:5px;'
1146
- )
1147
- } else {
1148
- //-------------------solution vs zone_depot
1149
- let listIdZone = []
1150
- for (
1151
- let index = 0;
1152
- index < choix_reponse.zone_depots.length;
1153
- index++
1154
- ) {
1155
- listIdZone.push(choix_reponse.zone_depots[index].id)
1156
- }
1157
- if (
1158
- !this.isEqual(
1159
- Object.keys(solution).sort(function (a, b) {
1160
- return a - b
1161
- }),
1162
- listIdZone.sort(function (a, b) {
1163
- return a - b
1164
- })
1165
- ) &&
1166
- !errorList.includes(
1167
- 'choix_reponse zone_depot and solution'
1168
- )
1169
- ) {
1170
- errorList.push(
1171
- 'choix_reponse zone_depot and solution'
1172
- )
1173
- console.warn(
1174
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot and solution do not have matching keys',
1175
- 'background: orange; color: white; display: block; margin:5px;'
1176
- )
1177
- }
1178
- //-------------------solution vs zone_depot end
1179
- //-------------------solution vs choix_deplaceable
1180
- let listIdChoice = []
1181
- for (
1182
- let index = 0;
1183
- index < choix_reponse.choix_deplaceable.length;
1184
- index++
1185
- ) {
1186
- listIdChoice.push(
1187
- choix_reponse.choix_deplaceable[index].id
1188
- )
1189
- }
1190
- if (
1191
- !this.isEqual(
1192
- Object.values(solution).sort(function (a, b) {
1193
- return a - b
1194
- }),
1195
- listIdChoice.sort(function (a, b) {
1196
- return a - b
1197
- })
1198
- ) &&
1199
- !errorList.includes(
1200
- 'choix_reponse choix_deplaceable and solution'
1201
- )
1202
- ) {
1203
- errorList.push(
1204
- 'choix_reponse choix_deplaceable and solution'
1205
- )
1206
- console.warn(
1207
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable and solution do not have matching values',
1208
- 'background: orange; color: white; display: block; margin:5px;'
1209
- )
1210
- }
1211
- //-------------------solution vs choix_deplaceable end
1212
- }
1213
- }
1214
- } else if (
1215
- !errorList.includes(
1216
- 'choix_reponse zone_depot choix_deplaceable'
1217
- )
1218
- ) {
1219
- errorList.push(
1220
- 'choix_reponse zone_depot choix_deplaceable'
1221
- )
1222
- console.warn(
1223
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot and your quizData choix_reponse choix_deplaceable are not the same lenght',
1224
- 'background: orange; color: white; display: block; margin:5px;'
1225
- )
1226
- }
1227
-
1228
- //--test zone_depots
1229
- for (
1230
- let index = 0;
1231
- index < choix_reponse.zone_depots.length;
1232
- index++
1233
- ) {
1234
- const element = choix_reponse.zone_depots[index]
1235
-
1236
- if (
1237
- !element.id &&
1238
- !errorList.includes('choix_reponse zone_depot id')
1239
- ) {
1240
- errorList.push('choix_reponse zone_depot id')
1241
- console.warn(
1242
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot does not hace an id',
1243
- 'background: orange; color: white; display: block; margin:5px;'
1244
- )
1245
- } else if (
1246
- element.id &&
1247
- typeof element.id !== 'string' &&
1248
- !errorList.includes('choix_reponse zone_depot id')
1249
- ) {
1250
- errorList.push('choix_reponse zone_depot id')
1251
- console.warn(
1252
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot id is not a string',
1253
- 'background: orange; color: white; display: block; margin:5px;'
1254
- )
1255
- }
1256
- //contenu
1257
- if (
1258
- !element.contenu &&
1259
- !errorList.includes('choix_reponse zone_depot contenu')
1260
- ) {
1261
- errorList.push('choix_reponse zone_depot contenu')
1262
- console.warn(
1263
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot does not have a contenu',
1264
- 'background: orange; color: white; display: block; margin:5px;'
1265
- )
1266
- } else {
1267
- if (
1268
- element.contenu &&
1269
- typeof element.contenu == 'object'
1270
- ) {
1271
- //type
1272
- if (element.contenu.type) {
1273
- if (
1274
- typeof element.contenu.type !== 'string' &&
1275
- !errorList.includes(
1276
- 'choix_reponse zone_depot contenu type'
1277
- )
1278
- ) {
1279
- errorList.push(
1280
- 'choix_reponse zone_depot contenu type'
1281
- )
1282
- console.warn(
1283
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu type does not string',
1284
- 'background: orange; color: white; display: block; margin:5px;'
1285
- )
1286
- } else if (
1287
- !errorList.includes(
1288
- 'choix_reponse zone_depot contenu type'
1289
- )
1290
- ) {
1291
- if (
1292
- !(
1293
- element.contenu.type == 'img' ||
1294
- element.contenu.type == 'str'
1295
- ) &&
1296
- !errorList.includes(
1297
- 'choix_reponse zone_depot contenu type valid'
1298
- )
1299
- ) {
1300
- errorList.push(
1301
- 'choix_reponse zone_depot contenu type valid'
1302
- )
1303
- console.warn(
1304
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu type is not valid. Must be img or str',
1305
- 'background: orange; color: white; display: block; margin:5px;'
1306
- )
1307
- }
1308
- }
1309
- } else if (
1310
- !errorList.includes(
1311
- 'choix_reponse zone_depot contenu type'
1312
- )
1313
- ) {
1314
- errorList.push(
1315
- 'choix_reponse zone_depot contenu type'
1316
- )
1317
- console.warn(
1318
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have a type',
1319
- 'background: orange; color: white; display: block; margin:5px;'
1320
- )
1321
- }
1322
- //type end
1323
- //affichage
1324
- if (element.contenu.affichage) {
1325
- if (
1326
- typeof element.contenu.affichage !== 'string' &&
1327
- !errorList.includes(
1328
- 'choix_reponse zone_depot contenu affichage'
1329
- )
1330
- ) {
1331
- errorList.push(
1332
- 'choix_reponse zone_depot contenu affichage'
1333
- )
1334
- console.warn(
1335
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu affichage does not string',
1336
- 'background: orange; color: white; display: block; margin:5px;'
1337
- )
1338
- }
1339
- } else if (
1340
- !errorList.includes(
1341
- 'choix_reponse zone_depot contenu affichage'
1342
- )
1343
- ) {
1344
- errorList.push(
1345
- 'choix_reponse zone_depot contenu affichage'
1346
- )
1347
- console.warn(
1348
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have an affichage',
1349
- 'background: orange; color: white; display: block; margin:5px;'
1350
- )
1351
- }
1352
- //affichage end
1353
- //alt
1354
- if (element.contenu.alt) {
1355
- if (
1356
- typeof element.contenu.alt !== 'string' &&
1357
- !errorList.includes(
1358
- 'choix_reponse zone_depot contenu alt'
1359
- )
1360
- ) {
1361
- errorList.push(
1362
- 'choix_reponse zone_depot contenu alt'
1363
- )
1364
- console.warn(
1365
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu alt does not string',
1366
- 'background: orange; color: white; display: block; margin:5px;'
1367
- )
1368
- }
1369
- } else if (
1370
- !errorList.includes(
1371
- 'choix_reponse zone_depot contenu alt'
1372
- )
1373
- ) {
1374
- errorList.push(
1375
- 'choix_reponse zone_depot contenu alt'
1376
- )
1377
- console.warn(
1378
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have an alt',
1379
- 'background: orange; color: white; display: block; margin:5px;'
1380
- )
1381
- }
1382
- //alt end
1383
- } else if (
1384
- !errorList.includes(
1385
- 'choix_reponse zone_depot contenu'
1386
- )
1387
- ) {
1388
- errorList.push('choix_reponse zone_depot contenu')
1389
- console.warn(
1390
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu is not an object',
1391
- 'background:orange; color: white; display: block; margin:5px;'
1392
- )
1393
- }
1394
- }
1395
- }
1396
- //--test zone_depots end
1397
- //--test choix_deplaceable
1398
- for (
1399
- let index = 0;
1400
- index < choix_reponse.choix_deplaceable.length;
1401
- index++
1402
- ) {
1403
- const element = choix_reponse.choix_deplaceable[index]
1404
-
1405
- if (
1406
- !element.id &&
1407
- !errorList.includes(
1408
- 'choix_reponse choix_deplaceable id'
1409
- )
1410
- ) {
1411
- errorList.push('choix_reponse choix_deplaceable id')
1412
- console.warn(
1413
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable does not hace an id',
1414
- 'background: orange; color: white; display: block; margin:5px;'
1415
- )
1416
- } else if (
1417
- element.id &&
1418
- typeof element.id !== 'string' &&
1419
- !errorList.includes(
1420
- 'choix_reponse choix_deplaceable id'
1421
- )
1422
- ) {
1423
- errorList.push('choix_reponse choix_deplaceable id')
1424
- console.warn(
1425
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable id is not a string',
1426
- 'background: orange; color: white; display: block; margin:5px;'
1427
- )
1428
- }
1429
- //contenu
1430
- if (
1431
- !element.contenu &&
1432
- !errorList.includes(
1433
- 'choix_reponse choix_deplaceable contenu'
1434
- )
1435
- ) {
1436
- errorList.push(
1437
- 'choix_reponse choix_deplaceable contenu'
1438
- )
1439
- console.warn(
1440
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable does not have a contenu',
1441
- 'background: orange; color: white; display: block; margin:5px;'
1442
- )
1443
- } else {
1444
- if (
1445
- element.contenu &&
1446
- typeof element.contenu == 'object'
1447
- ) {
1448
- //type
1449
- if (element.contenu.type) {
1450
- if (
1451
- typeof element.contenu.type !== 'string' &&
1452
- !errorList.includes(
1453
- 'choix_reponse choix_deplaceable contenu type'
1454
- )
1455
- ) {
1456
- errorList.push(
1457
- 'choix_reponse choix_deplaceable contenu type'
1458
- )
1459
- console.warn(
1460
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu type does not string',
1461
- 'background: orange; color: white; display: block; margin:5px;'
1462
- )
1463
- } else if (
1464
- !errorList.includes(
1465
- 'choix_reponse choix_deplaceable contenu type'
1466
- )
1467
- ) {
1468
- if (
1469
- !(
1470
- element.contenu.type == 'img' ||
1471
- element.contenu.type == 'str'
1472
- ) &&
1473
- !errorList.includes(
1474
- 'choix_reponse choix_deplaceable contenu type valid'
1475
- )
1476
- ) {
1477
- errorList.push(
1478
- 'choix_reponse choix_deplaceable contenu type valid'
1479
- )
1480
- console.warn(
1481
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu type is not valid. Must be img or str',
1482
- 'background: orange; color: white; display: block; margin:5px;'
1483
- )
1484
- }
1485
- }
1486
- } else if (
1487
- !errorList.includes(
1488
- 'choix_reponse choix_deplaceable contenu type'
1489
- )
1490
- ) {
1491
- errorList.push(
1492
- 'choix_reponse choix_deplaceable contenu type'
1493
- )
1494
- console.warn(
1495
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have a type',
1496
- 'background: orange; color: white; display: block; margin:5px;'
1497
- )
1498
- }
1499
- //type end
1500
- //affichage
1501
- if (element.contenu.affichage) {
1502
- if (
1503
- typeof element.contenu.affichage !== 'string' &&
1504
- !errorList.includes(
1505
- 'choix_reponse choix_deplaceable contenu affichage'
1506
- )
1507
- ) {
1508
- errorList.push(
1509
- 'choix_reponse choix_deplaceable contenu affichage'
1510
- )
1511
- console.warn(
1512
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu affichage does not string',
1513
- 'background: orange; color: white; display: block; margin:5px;'
1514
- )
1515
- }
1516
- } else if (
1517
- !errorList.includes(
1518
- 'choix_reponse choix_deplaceable contenu affichage'
1519
- )
1520
- ) {
1521
- errorList.push(
1522
- 'choix_reponse choix_deplaceable contenu affichage'
1523
- )
1524
- console.warn(
1525
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have an affichage',
1526
- 'background: orange; color: white; display: block; margin:5px;'
1527
- )
1528
- }
1529
- //affichage end
1530
- //alt
1531
- if (element.contenu.alt) {
1532
- if (
1533
- typeof element.contenu.alt !== 'string' &&
1534
- !errorList.includes(
1535
- 'choix_reponse choix_deplaceable contenu alt'
1536
- )
1537
- ) {
1538
- errorList.push(
1539
- 'choix_reponse choix_deplaceable contenu alt'
1540
- )
1541
- console.warn(
1542
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu alt does not string',
1543
- 'background: orange; color: white; display: block; margin:5px;'
1544
- )
1545
- }
1546
- } else if (
1547
- !errorList.includes(
1548
- 'choix_reponse choix_deplaceable contenu alt'
1549
- )
1550
- ) {
1551
- errorList.push(
1552
- 'choix_reponse choix_deplaceable contenu alt'
1553
- )
1554
- console.warn(
1555
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have an alt',
1556
- 'background: orange; color: white; display: block; margin:5px;'
1557
- )
1558
- }
1559
- //alt end
1560
- } else if (
1561
- !errorList.includes(
1562
- 'choix_reponse choix_deplaceable contenu'
1563
- )
1564
- ) {
1565
- errorList.push(
1566
- 'choix_reponse choix_deplaceable contenu'
1567
- )
1568
- console.warn(
1569
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu is not an object',
1570
- 'background:orange; color: white; display: block; margin:5px;'
1571
- )
1572
- }
1573
- }
1574
- }
1575
-
1576
- //--test choix_deplaceable end
1577
- } else {
1578
- if (
1579
- !Array.isArray(choix_reponse.zone_depots) &&
1580
- !errorList.includes('choix_reponse zone_depot')
1581
- ) {
1582
- errorList.push('choix_reponse zone_depot')
1583
- console.warn(
1584
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot is not an array',
1585
- 'background: orange; color: white; display: block; margin:5px;'
1586
- )
1587
- }
1588
-
1589
- if (
1590
- !Array.isArray(choix_reponse.choix_deplaceable) &&
1591
- !errorList.includes('choix_reponse choix_deplaceable')
1592
- ) {
1593
- errorList.push('choix_reponse choix_deplaceable')
1594
- console.warn(
1595
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable is not an array',
1596
- 'background: orange; color: white; display: block; margin:5px;'
1597
- )
1598
- }
1599
- }
1600
- } else {
1601
- if (
1602
- !choix_reponse.zone_depots &&
1603
- !errorList.includes('choix_reponse zone_depot')
1604
- ) {
1605
- errorList.push('choix_reponse zone_depot')
1606
- console.warn(
1607
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot is missing',
1608
- 'background: orange; color: white; display: block; margin:5px;'
1609
- )
1610
- }
1611
-
1612
- if (
1613
- !choix_reponse.choix_deplaceable &&
1614
- !errorList.includes('choix_reponse choix_deplaceable')
1615
- ) {
1616
- errorList.push('choix_reponse choix_deplaceable')
1617
- console.warn(
1618
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable is missing',
1619
- 'background: orange; color: white; display: block; margin:5px;'
1620
- )
1621
- }
1622
- }
1623
- }
1624
- break
1625
- case 'dragdrop':
1626
- if (
1627
- solution &&
1628
- typeof solution !== 'object' &&
1629
- !errorList.includes('solution')
1630
- ) {
1631
- errorList.push('solution')
1632
- console.warn(
1633
- '%c WARNING!>>> AppCompQuiz: Your quizData solution is missing',
1634
- 'background: orange; color: white; display: block; margin:5px;'
1635
- )
1636
- } else if (solution && typeof solution == 'object') {
1637
- for (
1638
- let index = 0;
1639
- index < Object.values(solution).length;
1640
- index++
1641
- ) {
1642
- const element = Object.values(solution)[index]
1643
- if (
1644
- !Array.isArray(element) &&
1645
- !errorList.includes('solution values type')
1646
- ) {
1647
- errorList.push('solution values type')
1648
- console.warn(
1649
- '%c WARNING!>>> AppCompQuiz: Your quizData solution values do not have only arrays',
1650
- 'background: orange; color: white; display: block; margin:5px;'
1651
- )
1652
- }
1653
- }
1654
- }
1655
-
1656
- if (!choix_reponse && !errorList.includes('choix_reponse')) {
1657
- errorList.push('choix_reponse')
1658
- console.warn(
1659
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse is missing',
1660
- 'background: orange; color: white; display: block; margin:5px;'
1661
- )
1662
- } else {
1663
- if (
1664
- choix_reponse.zone_depots &&
1665
- choix_reponse.choix_deplaceable
1666
- ) {
1667
- if (
1668
- Array.isArray(choix_reponse.zone_depots) &&
1669
- Array.isArray(choix_reponse.choix_deplaceable)
1670
- ) {
1671
- if (solution && typeof solution == 'object') {
1672
- if (
1673
- Object.keys(solution).length !==
1674
- choix_reponse.zone_depots.length &&
1675
- !errorList.includes(
1676
- 'choix_reponse zone_depot choix_deplaceable and solution'
1677
- )
1678
- ) {
1679
- errorList.push(
1680
- 'choix_reponse zone_depot choix_deplaceable and solution'
1681
- )
1682
- console.warn(
1683
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot/choix_deplaceable and solution do not have matching size',
1684
- 'background: orange; color: white; display: block; margin:5px;'
1685
- )
1686
- } else {
1687
- //-------------------solution vs zone_depot
1688
- let listIdZone = []
1689
- for (
1690
- let index = 0;
1691
- index < choix_reponse.zone_depots.length;
1692
- index++
1693
- ) {
1694
- listIdZone.push(choix_reponse.zone_depots[index].id)
1695
- }
1696
- if (
1697
- !this.isEqual(
1698
- Object.keys(solution).sort(function (a, b) {
1699
- return a - b
1700
- }),
1701
- listIdZone.sort(function (a, b) {
1702
- return a - b
1703
- })
1704
- ) &&
1705
- !errorList.includes(
1706
- 'choix_reponse zone_depot and solution'
1707
- )
1708
- ) {
1709
- errorList.push(
1710
- 'choix_reponse zone_depot and solution'
1711
- )
1712
- console.warn(
1713
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot and solution do not have matching keys',
1714
- 'background: orange; color: white; display: block; margin:5px;'
1715
- )
1716
- }
1717
- //-------------------solution vs zone_depot end
1718
- }
1719
- }
1720
-
1721
- //--test zone_depots
1722
- for (
1723
- let index = 0;
1724
- index < choix_reponse.zone_depots.length;
1725
- index++
1726
- ) {
1727
- const element = choix_reponse.zone_depots[index]
1728
-
1729
- if (
1730
- !element.id &&
1731
- !errorList.includes('choix_reponse zone_depot id')
1732
- ) {
1733
- errorList.push('choix_reponse zone_depot id')
1734
- console.warn(
1735
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot does not hace an id',
1736
- 'background: orange; color: white; display: block; margin:5px;'
1737
- )
1738
- } else if (
1739
- element.id &&
1740
- typeof element.id !== 'string' &&
1741
- !errorList.includes('choix_reponse zone_depot id')
1742
- ) {
1743
- errorList.push('choix_reponse zone_depot id')
1744
- console.warn(
1745
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot id is not a string',
1746
- 'background: orange; color: white; display: block; margin:5px;'
1747
- )
1748
- }
1749
- //contenu
1750
- if (
1751
- !element.contenu &&
1752
- !errorList.includes('choix_reponse zone_depot contenu')
1753
- ) {
1754
- errorList.push('choix_reponse zone_depot contenu')
1755
- console.warn(
1756
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot does not have a contenu',
1757
- 'background: orange; color: white; display: block; margin:5px;'
1758
- )
1759
- } else {
1760
- if (
1761
- element.contenu &&
1762
- typeof element.contenu == 'object'
1763
- ) {
1764
- //type
1765
- if (element.contenu.type) {
1766
- if (
1767
- typeof element.contenu.type !== 'string' &&
1768
- !errorList.includes(
1769
- 'choix_reponse zone_depot contenu type'
1770
- )
1771
- ) {
1772
- errorList.push(
1773
- 'choix_reponse zone_depot contenu type'
1774
- )
1775
- console.warn(
1776
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu type does not string',
1777
- 'background: orange; color: white; display: block; margin:5px;'
1778
- )
1779
- } else if (
1780
- !errorList.includes(
1781
- 'choix_reponse zone_depot contenu type'
1782
- )
1783
- ) {
1784
- if (
1785
- !(
1786
- element.contenu.type == 'img' ||
1787
- element.contenu.type == 'str'
1788
- ) &&
1789
- !errorList.includes(
1790
- 'choix_reponse zone_depot contenu type valid'
1791
- )
1792
- ) {
1793
- errorList.push(
1794
- 'choix_reponse zone_depot contenu type valid'
1795
- )
1796
- console.warn(
1797
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu type is not valid. Must be img or str',
1798
- 'background: orange; color: white; display: block; margin:5px;'
1799
- )
1800
- }
1801
- }
1802
- } else if (
1803
- !errorList.includes(
1804
- 'choix_reponse zone_depot contenu type'
1805
- )
1806
- ) {
1807
- errorList.push(
1808
- 'choix_reponse zone_depot contenu type'
1809
- )
1810
- console.warn(
1811
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have a type',
1812
- 'background: orange; color: white; display: block; margin:5px;'
1813
- )
1814
- }
1815
- //type end
1816
- //affichage
1817
- if (element.contenu.affichage) {
1818
- if (
1819
- typeof element.contenu.affichage !== 'string' &&
1820
- !errorList.includes(
1821
- 'choix_reponse zone_depot contenu affichage'
1822
- )
1823
- ) {
1824
- errorList.push(
1825
- 'choix_reponse zone_depot contenu affichage'
1826
- )
1827
- console.warn(
1828
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu affichage does not string',
1829
- 'background: orange; color: white; display: block; margin:5px;'
1830
- )
1831
- }
1832
- } else if (
1833
- !errorList.includes(
1834
- 'choix_reponse zone_depot contenu affichage'
1835
- )
1836
- ) {
1837
- errorList.push(
1838
- 'choix_reponse zone_depot contenu affichage'
1839
- )
1840
- console.warn(
1841
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have an affichage',
1842
- 'background: orange; color: white; display: block; margin:5px;'
1843
- )
1844
- }
1845
- //affichage end
1846
- //alt
1847
- if (element.contenu.alt) {
1848
- if (
1849
- typeof element.contenu.alt !== 'string' &&
1850
- !errorList.includes(
1851
- 'choix_reponse zone_depot contenu alt'
1852
- )
1853
- ) {
1854
- errorList.push(
1855
- 'choix_reponse zone_depot contenu alt'
1856
- )
1857
- console.warn(
1858
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu alt does not string',
1859
- 'background: orange; color: white; display: block; margin:5px;'
1860
- )
1861
- }
1862
- } else if (
1863
- !errorList.includes(
1864
- 'choix_reponse zone_depot contenu alt'
1865
- )
1866
- ) {
1867
- errorList.push(
1868
- 'choix_reponse zone_depot contenu alt'
1869
- )
1870
- console.warn(
1871
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu does not have an alt',
1872
- 'background: orange; color: white; display: block; margin:5px;'
1873
- )
1874
- }
1875
- //alt end
1876
- } else if (
1877
- !errorList.includes(
1878
- 'choix_reponse zone_depot contenu'
1879
- )
1880
- ) {
1881
- errorList.push('choix_reponse zone_depot contenu')
1882
- console.warn(
1883
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot contenu is not an object',
1884
- 'background:orange; color: white; display: block; margin:5px;'
1885
- )
1886
- }
1887
- }
1888
- }
1889
- //--test zone_depots end
1890
- //--test choix_deplaceable
1891
- for (
1892
- let index = 0;
1893
- index < choix_reponse.choix_deplaceable.length;
1894
- index++
1895
- ) {
1896
- const element = choix_reponse.choix_deplaceable[index]
1897
-
1898
- if (
1899
- !element.id &&
1900
- !errorList.includes(
1901
- 'choix_reponse choix_deplaceable id'
1902
- )
1903
- ) {
1904
- errorList.push('choix_reponse choix_deplaceable id')
1905
- console.warn(
1906
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable does not hace an id',
1907
- 'background: orange; color: white; display: block; margin:5px;'
1908
- )
1909
- } else if (
1910
- element.id &&
1911
- typeof element.id !== 'string' &&
1912
- !errorList.includes(
1913
- 'choix_reponse choix_deplaceable id'
1914
- )
1915
- ) {
1916
- errorList.push('choix_reponse choix_deplaceable id')
1917
- console.warn(
1918
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable id is not a string',
1919
- 'background: orange; color: white; display: block; margin:5px;'
1920
- )
1921
- }
1922
- //repetition
1923
- if (
1924
- !element.repetition &&
1925
- !errorList.includes(
1926
- 'choix_reponse choix_deplaceable repetition'
1927
- )
1928
- ) {
1929
- errorList.push(
1930
- 'choix_reponse choix_deplaceable repetition'
1931
- )
1932
- console.warn(
1933
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable does not hace a repetition',
1934
- 'background: orange; color: white; display: block; margin:5px;'
1935
- )
1936
- } else if (
1937
- element.repetition &&
1938
- typeof element.repetition == 'number' &&
1939
- !errorList.includes(
1940
- 'choix_reponse choix_deplaceable repetition'
1941
- )
1942
- ) {
1943
- errorList.push(
1944
- 'choix_reponse choix_deplaceable repetition'
1945
- )
1946
- console.warn(
1947
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable repetition value is not an array',
1948
- 'background: orange; color: white; display: block; margin:5px;'
1949
- )
1950
- }
1951
-
1952
- //contenu
1953
- if (
1954
- !element.contenu &&
1955
- !errorList.includes(
1956
- 'choix_reponse choix_deplaceable contenu'
1957
- )
1958
- ) {
1959
- errorList.push(
1960
- 'choix_reponse choix_deplaceable contenu'
1961
- )
1962
- console.warn(
1963
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable does not have a contenu',
1964
- 'background: orange; color: white; display: block; margin:5px;'
1965
- )
1966
- } else {
1967
- if (
1968
- element.contenu &&
1969
- typeof element.contenu == 'object'
1970
- ) {
1971
- //type
1972
- if (element.contenu.type) {
1973
- if (
1974
- typeof element.contenu.type !== 'string' &&
1975
- !errorList.includes(
1976
- 'choix_reponse choix_deplaceable contenu type'
1977
- )
1978
- ) {
1979
- errorList.push(
1980
- 'choix_reponse choix_deplaceable contenu type'
1981
- )
1982
- console.warn(
1983
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu type does not string',
1984
- 'background: orange; color: white; display: block; margin:5px;'
1985
- )
1986
- } else if (
1987
- !errorList.includes(
1988
- 'choix_reponse choix_deplaceable contenu type'
1989
- )
1990
- ) {
1991
- if (
1992
- !(
1993
- element.contenu.type == 'img' ||
1994
- element.contenu.type == 'str'
1995
- ) &&
1996
- !errorList.includes(
1997
- 'choix_reponse choix_deplaceable contenu type valid'
1998
- )
1999
- ) {
2000
- errorList.push(
2001
- 'choix_reponse choix_deplaceable contenu type valid'
2002
- )
2003
- console.warn(
2004
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu type is not valid. Must be img or str',
2005
- 'background: orange; color: white; display: block; margin:5px;'
2006
- )
2007
- }
2008
- }
2009
- } else if (
2010
- !errorList.includes(
2011
- 'choix_reponse choix_deplaceable contenu type'
2012
- )
2013
- ) {
2014
- errorList.push(
2015
- 'choix_reponse choix_deplaceable contenu type'
2016
- )
2017
- console.warn(
2018
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have a type',
2019
- 'background: orange; color: white; display: block; margin:5px;'
2020
- )
2021
- }
2022
- //type end
2023
- //affichage
2024
- if (element.contenu.affichage) {
2025
- if (
2026
- typeof element.contenu.affichage !== 'string' &&
2027
- !errorList.includes(
2028
- 'choix_reponse choix_deplaceable contenu affichage'
2029
- )
2030
- ) {
2031
- errorList.push(
2032
- 'choix_reponse choix_deplaceable contenu affichage'
2033
- )
2034
- console.warn(
2035
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu affichage does not string',
2036
- 'background: orange; color: white; display: block; margin:5px;'
2037
- )
2038
- }
2039
- } else if (
2040
- !errorList.includes(
2041
- 'choix_reponse choix_deplaceable contenu affichage'
2042
- )
2043
- ) {
2044
- errorList.push(
2045
- 'choix_reponse choix_deplaceable contenu affichage'
2046
- )
2047
- console.warn(
2048
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have an affichage',
2049
- 'background: orange; color: white; display: block; margin:5px;'
2050
- )
2051
- }
2052
- //affichage end
2053
- //alt
2054
- if (element.contenu.alt) {
2055
- if (
2056
- typeof element.contenu.alt !== 'string' &&
2057
- !errorList.includes(
2058
- 'choix_reponse choix_deplaceable contenu alt'
2059
- )
2060
- ) {
2061
- errorList.push(
2062
- 'choix_reponse choix_deplaceable contenu alt'
2063
- )
2064
- console.warn(
2065
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu alt does not string',
2066
- 'background: orange; color: white; display: block; margin:5px;'
2067
- )
2068
- }
2069
- } else if (
2070
- !errorList.includes(
2071
- 'choix_reponse choix_deplaceable contenu alt'
2072
- )
2073
- ) {
2074
- errorList.push(
2075
- 'choix_reponse choix_deplaceable contenu alt'
2076
- )
2077
- console.warn(
2078
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu does not have an alt',
2079
- 'background: orange; color: white; display: block; margin:5px;'
2080
- )
2081
- }
2082
- //alt end
2083
- } else if (
2084
- !errorList.includes(
2085
- 'choix_reponse choix_deplaceable contenu'
2086
- )
2087
- ) {
2088
- errorList.push(
2089
- 'choix_reponse choix_deplaceable contenu'
2090
- )
2091
- console.warn(
2092
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable contenu is not an object',
2093
- 'background:orange; color: white; display: block; margin:5px;'
2094
- )
2095
- }
2096
- }
2097
- }
2098
-
2099
- //--test choix_deplaceable end
2100
- } else {
2101
- if (
2102
- !Array.isArray(choix_reponse.zone_depots) &&
2103
- !errorList.includes('choix_reponse zone_depot')
2104
- ) {
2105
- errorList.push('choix_reponse zone_depot')
2106
- console.warn(
2107
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot is not an array',
2108
- 'background: orange; color: white; display: block; margin:5px;'
2109
- )
2110
- }
2111
-
2112
- if (
2113
- !Array.isArray(choix_reponse.choix_deplaceable) &&
2114
- !errorList.includes('choix_reponse choix_deplaceable')
2115
- ) {
2116
- errorList.push('choix_reponse choix_deplaceable')
2117
- console.warn(
2118
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable is not an array',
2119
- 'background: orange; color: white; display: block; margin:5px;'
2120
- )
2121
- }
2122
- }
2123
- } else {
2124
- if (
2125
- !choix_reponse.zone_depots &&
2126
- !errorList.includes('choix_reponse zone_depot')
2127
- ) {
2128
- errorList.push('choix_reponse zone_depot')
2129
- console.warn(
2130
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse zone_depot is missing',
2131
- 'background: orange; color: white; display: block; margin:5px;'
2132
- )
2133
- }
2134
-
2135
- if (
2136
- !choix_reponse.choix_deplaceable &&
2137
- !errorList.includes('choix_reponse choix_deplaceable')
2138
- ) {
2139
- errorList.push('choix_reponse choix_deplaceable')
2140
- console.warn(
2141
- '%c WARNING!>>> AppCompQuiz: Your quizData choix_reponse choix_deplaceable is missing',
2142
- 'background: orange; color: white; display: block; margin:5px;'
2143
- )
2144
- }
2145
- }
2146
- }
2147
- }
2148
- }
2149
- } else {
2150
- errorList.push('quizData manquant')
2151
- console.warn(
2152
- '%c WARNING!>>> AppCompQuiz: Your quizData is missing',
2153
- 'background: orange; color: white; display: block; margin:5px;'
2154
- )
2155
- }
2156
- // all item have required field.There is no error
2157
- if (!errorList.length) err = false
2158
- //return list of error
2159
- else err = errorList
2160
-
2161
- return err
2162
- },
2163
-
2164
- /**
2165
- * @description Instruction phrase to show for a quiz
2166
- */
2167
- instruction() {
2168
- let instructionStr = null
2169
- let localInstruction = null
2170
-
2171
- const {
2172
- type_question,
2173
- solution,
2174
- choix_reponse,
2175
- texte_base,
2176
- consigne: customInstruction
2177
- } = this.quizData
2178
-
2179
- //Custom instruction was set for the quiz
2180
- if (customInstruction) {
2181
- instructionStr = customInstruction
2182
- } else {
2183
- let isMulti = [
2184
- 'texte_tableau',
2185
- 'texte_troue',
2186
- 'texte_troue_select'
2187
- ].includes(type_question)
2188
- ? true
2189
- : false
2190
-
2191
- if (isMulti) {
2192
- //instruction to use
2193
- localInstruction =
2194
- solution !== null
2195
- ? `instruction.${type_question}`
2196
- : `instruction.${type_question}_no_validation`
2197
-
2198
- // Check if the question as multi input fields
2199
- let hasMultiInput = []
2200
-
2201
- // This is a texte_troue
2202
- if (texte_base) {
2203
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
2204
- hasMultiInput = texte_base.match(regex)
2205
- }
2206
- // not a text_troue (texte_tableau or texte_troue_select)
2207
- else if (choix_reponse) hasMultiInput = choix_reponse
2208
-
2209
- //Use mutli or single
2210
- hasMultiInput.length > 1
2211
- ? (localInstruction = `${localInstruction}.multi`)
2212
- : (localInstruction = `${localInstruction}.single`)
2213
- } else {
2214
- localInstruction =
2215
- solution !== null
2216
- ? `instruction.${type_question}`
2217
- : `instruction.${type_question}_no_validation`
2218
- }
2219
- instructionStr = this.$t(localInstruction)
2220
- }
2221
- return instructionStr
2222
- },
2223
-
2224
- /**
2225
- * @description Text to display for the quiz button
2226
- * @return {String} string to use by the local
2227
- * */
2228
- txtBtnSubmit() {
2229
- let str = ''
2230
- const { solution } = this.quizData
2231
-
2232
- if (solution === null) str = this.$t('button.save')
2233
- //There is more than on element in the solution
2234
- else str = this.$t('button.quiz_verify')
2235
-
2236
- return str
2237
- },
2238
- /*
2239
- *description return wiether user initiated input or not
2240
- */
2241
- inputIsEmpty() {
2242
- const input = this.quizInputType
2243
- // Input is empty if it is null or it content is bellow 1
2244
- return input == null || Object.keys(input).length < 1
2245
- },
2246
-
2247
- /**
2248
- * @description Ennonce of the quiz - parse to add image if defined
2249
- */
2250
-
2251
- quizEnnonce() {
2252
- const { ennonce } = this.quizData
2253
- let _ennonce = ennonce
2254
- return _ennonce
2255
- },
2256
- /**
2257
- * @description Allowed attemps to quiz base of number of max attemps- should be unlimited if max attent is null
2258
- */
2259
-
2260
- attemptsReached() {
2261
- let reached = this.quizData.max_essai
2262
-
2263
- if (!reached) return false
2264
- else return this.totalAttempts >= reached
2265
- }
2266
- },
2267
- watch: {
2268
- /**
2269
- * @description disable solution
2270
- */
2271
- quizInputType: {
2272
- deep: true,
2273
- handler(newValue, oldValue) {
2274
- const { type_question } = this.quizData
2275
- switch (true) {
2276
- case ['choix_unique', 'reponse_ouverte'].includes(type_question):
2277
- if (newValue !== null && oldValue !== '') {
2278
- this.showSolution = false
2279
- }
2280
- break
2281
-
2282
- case type_question === 'choix_mult':
2283
- if (newValue.length !== oldValue.length && oldValue.length !== 0) {
2284
- this.showSolution = false
2285
- }
2286
- break
2287
- case ['dropdown', 'texte_troue_select'].includes(type_question):
2288
- if (
2289
- this.showSolution == true &&
2290
- this.oldQuizValue !== null &&
2291
- this.oldQuizValue !== this.quizInputType
2292
- ) {
2293
- this.showSolution = false
2294
- }
2295
- //save the value with spread syntax to prevent copying a reference only
2296
- this.oldQuizValue = [...this.quizInputType]
2297
- break
2298
- case ['texte_tableau', 'texte_troue'].includes(type_question):
2299
- if (
2300
- this.showSolution == true &&
2301
- this.oldQuizValue !== null &&
2302
- this.oldQuizValue.length !== 0 &&
2303
- !this.isEqual(this.initQuizTable, newValue)
2304
- ) {
2305
- this.showSolution = false
2306
- }
2307
- this.oldQuizValue = [...this.quizInputType]
2308
- break
2309
- }
2310
- }
2311
- },
2312
- /**
2313
- * @description disable solution
2314
- */
2315
- quizAssociation: {
2316
- deep: true,
2317
- handler(newValue, oldValue) {
2318
- if (this.showSolution == true && Object.keys(oldValue).length !== 0) {
2319
- this.showSolution = false
2320
- }
2321
- }
2322
- },
2323
- /**
2324
- * @description disable solution
2325
- */
2326
- quisDragDrop: {
2327
- deep: true,
2328
- handler(newValue, oldValue) {
2329
- if (this.showSolution == true && Object.keys(oldValue).length !== 0) {
2330
- this.showSolution = false
2331
- }
2332
- }
2333
- },
2334
- getPageInteraction: {
2335
- //in development environment (localhost), don't wait for the axios call
2336
- // immediate: import.meta.env.DEV,
2337
- deep: true,
2338
- immediate: true,
2339
- handler() {
2340
- if (!this.getPageInteraction) return
2341
- this.getPreviousAnswers()
2342
- }
2343
- }
2344
- },
2345
- created() {},
2346
- beforeUnmount() {},
2347
- mounted() {},
2348
- methods: {
2349
- showNoAnswerPopup() {
2350
- this.$bus.$emit('quizNoAnswer')
2351
- },
2352
- /**
2353
- * @description this is called to validate de answers
2354
- * @param {Object} theAnswer
2355
- */
2356
- checkEntry(theAnswer) {
2357
- this.quizSubmit = false //re enables the ability to submit
2358
- if (this.quizCompleted == false) {
2359
- const { id, type_question, retroaction, solution } = this.quizData
2360
- if (!this.attemptsReached) {
2361
- this.totalAttempts++
2362
-
2363
- if (theAnswer == null) {
2364
- this.showNoAnswerPopup()
2365
- } else {
2366
- let theSolution = solution
2367
- if (theSolution == null) {
2368
- //Create the popup with the content of the retrotaction neutre
2369
- this.retroType = 'neutral'
2370
- this.retroTitle = retroaction.retro_neutre.title
2371
- this.retroHtml = retroaction.retro_neutre.hypertext_1
2372
- this.showSolution = true
2373
- this.showRetro = true
2374
- } else {
2375
- let correctAnswer = false
2376
- switch (type_question) {
2377
- case 'choix_unique':
2378
- correctAnswer = theAnswer[id] == theSolution
2379
-
2380
- break
2381
- case 'choix_mult':
2382
- correctAnswer = this.isEqual(
2383
- theAnswer[id].sort(function (a, b) {
2384
- return a - b
2385
- }),
2386
- theSolution.sort(function (a, b) {
2387
- return a - b
2388
- })
2389
- )
2390
- break
2391
- case 'dropdown': {
2392
- let listQuizSelected = theAnswer[id]
2393
- correctAnswer = this.compareSelectedAnswers(
2394
- listQuizSelected,
2395
- theSolution
2396
- )
2397
- break
2398
- }
2399
- case 'texte_troue_select': {
2400
- let listQuizSelectedText = theAnswer[id]
2401
- correctAnswer = this.compareSelectedTextToFillAnswers(
2402
- listQuizSelectedText,
2403
- theSolution
2404
- )
2405
- break
2406
- }
2407
- case 'reponse_ouverte':
2408
- correctAnswer = theAnswer[id] == theSolution
2409
-
2410
- break
2411
- case 'texte_tableau': {
2412
- let listQuizTextTable = theAnswer[id]
2413
- correctAnswer = this.compareTextAnswers(
2414
- listQuizTextTable,
2415
- theSolution
2416
- )
2417
- break
2418
- }
2419
- case 'texte_troue': {
2420
- let listQuizTextFill = theAnswer[id]
2421
- correctAnswer = this.compareTextAnswers2(
2422
- listQuizTextFill,
2423
- theSolution
2424
- )
2425
- break
2426
- }
2427
- }
2428
- if (correctAnswer) {
2429
- this.retroTitle = retroaction.retro_positive.title
2430
- this.retroHtml = retroaction.retro_positive.hypertext_1
2431
- this.retroType = 'positive'
2432
- this.showSolution = true
2433
- this.showRetro = true
2434
- } else {
2435
- this.retroTitle = retroaction.retro_negative.title
2436
- this.retroHtml = retroaction.retro_negative.hypertext_1
2437
- this.retroType = 'negative'
2438
- this.showSolution = true
2439
- this.showRetro = true
2440
-
2441
- if (this.attemptsReached) {
2442
- this.setQuizCompleted()
2443
- // this.createPopUp(
2444
- // {
2445
- // type: 'popup-retro',
2446
- // value: {
2447
- // title: 'retroaction',
2448
- // text_1: this.$t('message.no_attempts')
2449
- // }
2450
- // },
2451
- // 'no_attempts'
2452
- // )
2453
- }
2454
- }
2455
- }
2456
- }
2457
-
2458
- this.saveAnswer(theAnswer)
2459
- } else {
2460
- //this should be unnecessary, it's just a failsafe.
2461
- // this.setQuizCompleted()
2462
- // this.createPopUp(
2463
- // {
2464
- // type: 'popup-retro',
2465
- // value: {
2466
- // title: 'retroaction',
2467
- // text_1: this.$t('message.no_attempts')
2468
- // }
2469
- // },
2470
- // 'no_attempts'
2471
- // )
2472
- }
2473
- } /**/
2474
- },
2475
-
2476
- /**
2477
- * @description creates a pop up
2478
- * @param {object} popUpData data for the pop up
2479
- * @fires open-popup to the AppBaseModule.vue
2480
- */
2481
- createPopUp(popUpData, type) {
2482
- this.$bus.$emit('open-popup', popUpData)
2483
- this.$bus.$emit('retro-type', type)
2484
- },
2485
-
2486
- /**
2487
- * @description disables the quiz
2488
- * @todo must be expanded for what happens when the quiz is disabled
2489
- */
2490
- setQuizCompleted() {
2491
- this.quizCompleted = true
2492
- },
2493
- /**
2494
- * @description compares 2 array
2495
- * @param {Array} array1
2496
- * @param {Array} array2
2497
- * @returns {Boolean}
2498
- */
2499
- isEqual(array1, array2) {
2500
- // if length is not equal
2501
- if (array1.length != array2.length) {
2502
- return false
2503
- } else {
2504
- // comapring each element of array
2505
- for (let i = 0; i < array1.length; i++) {
2506
- if (array1[i] != array2[i]) {
2507
- return false
2508
- }
2509
- }
2510
- return true
2511
- }
2512
- },
2513
- /**
2514
- * @description used by the dropdown quiz
2515
- * @param {Array} answers what the user has answered
2516
- * @param {Array} solution the correct choices
2517
- * @returns {Boolean}
2518
- */
2519
- compareSelectedAnswers(answers, solution) {
2520
- for (let index = 0; index < answers.length; index++) {
2521
- const elementAnswers = answers[index]
2522
- const elementSolution = solution[index]
2523
- if (elementAnswers.reponse_id !== elementSolution) {
2524
- return false
2525
- }
2526
- }
2527
- return true
2528
- },
2529
-
2530
- /**
2531
- * @description used by the texte_troue_select quiz
2532
- * @param {Array} answers what the user has answered
2533
- * @param {Array} solution the correct choices
2534
- * @returns {Boolean}
2535
- */
2536
- compareSelectedTextToFillAnswers(answers, solution) {
2537
- for (let index = 0; index < answers.length; index++) {
2538
- const elementAnswers = answers[index]
2539
- const elementSolution = Object.values(solution[index])[0]
2540
- if (elementAnswers.reponse_id !== elementSolution) {
2541
- return false
2542
- }
2543
- }
2544
- return true
2545
- },
2546
-
2547
- /**
2548
- * @description used by the texte_tableau quiz and texte_troue quiz
2549
- * @param {Array} answers what the user has answered
2550
- * @param {Array} solution the correct choices
2551
- * @returns {Boolean}
2552
- */
2553
- compareTextAnswers(answers, solution) {
2554
- for (let index = 0; index < answers.length; index++) {
2555
- const elementAnswers = answers[index]
2556
- const elementSolution = solution[index]
2557
- if (
2558
- !this.$helper.containsValue(
2559
- elementSolution.reponse_value,
2560
- elementAnswers.reponse
2561
- )
2562
- ) {
2563
- return false
2564
- }
2565
- }
2566
- return true
2567
- },
2568
-
2569
- /**
2570
- * @description used by the texte_tableau quiz and texte_troue quiz
2571
- * @param {Array} answers what the user has answered
2572
- * @param {Array} solution the correct choices
2573
- * @returns {Boolean}
2574
- */
2575
- compareTextAnswers2(answers, solution) {
2576
- for (let index = 0; index < answers.length; index++) {
2577
- const elementAnswers = answers[index]
2578
- const elementSolution = solution[index]
2579
- if (
2580
- !this.$helper.containsValue(
2581
- Object.values(elementSolution)[0],
2582
- elementAnswers.reponse
2583
- )
2584
- ) {
2585
- return false
2586
- }
2587
- }
2588
- return true
2589
- },
2590
-
2591
- /**
2592
- * @description used by the association quiz
2593
- * @param {Object} answers what the user has answered
2594
- * @param {Object} solution the correct choices
2595
- * @returns {Boolean}
2596
- */
2597
- compareObjectAnswers(answers, solution) {
2598
- let answersKey = Object.keys(answers)
2599
- for (let index = 0; index < answersKey.length; index++) {
2600
- const elementAnswers = answers[answersKey[index]]
2601
- const elementSolution = solution[answersKey[index]]
2602
- if (elementAnswers !== elementSolution) {
2603
- return false
2604
- }
2605
- }
2606
- return true
2607
- },
2608
-
2609
- /**
2610
- * @description used by the dragdrop quiz
2611
- * @param {Object} answers what the user has answered
2612
- * @param {Object} solution the correct choices
2613
- * @returns {Boolean}
2614
- */
2615
- compareObjectAnswers2(answers, solution) {
2616
- let answersKey = Object.keys(answers)
2617
- for (let index = 0; index < answersKey.length; index++) {
2618
- const elementAnswers = answers[answersKey[index]]
2619
- const elementSolution = solution[answersKey[index]]
2620
- if (!this.isEqual(elementAnswers, elementSolution)) {
2621
- return false
2622
- }
2623
- }
2624
- return true
2625
- },
2626
-
2627
- /**
2628
- * @description re enables the quiz
2629
- */
2630
- resetQuiz() {
2631
- this.totalAttempts = 0
2632
- //removes the css class
2633
- this.showSolution = false
2634
- this.quizCompleted = false
2635
- //empty the inputs
2636
- this.quizInputType = this.defaultInputType
2637
- // this.quizInputType = []
2638
-
2639
- if (this.quizData.type_question == 'association') {
2640
- let listZone = this.quizData.choix_reponse.zone_depots
2641
- for (let index = 0; index < listZone.length; index++) {
2642
- const element = listZone[index].id
2643
- this.quizAssociation[element] = ''
2644
- }
2645
- }
2646
- if (this.quizData.type_question == 'dragdrop') {
2647
- let listZone = this.quizData.choix_reponse.zone_depots
2648
- for (let index = 0; index < listZone.length; index++) {
2649
- const element = listZone[index].id
2650
- this.quizDragDrop[element] = []
2651
- }
2652
- }
2653
-
2654
- if (this.quizData.type_question == 'texte_tableau') {
2655
- for (
2656
- let index = 0;
2657
- index < this.quizData.choix_reponse.length;
2658
- index++
2659
- ) {
2660
- this.quizInputType.push('')
2661
- }
2662
- }
2663
- if (this.quizData.type_question == 'texte_troue') {
2664
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
2665
- let matchAll = this.quizData.texte_base.split(regex)
2666
- for (let index = 0; index < matchAll.length - 1; index++) {
2667
- this.quizInputType.push('')
2668
- }
2669
- }
2670
- },
2671
-
2672
- /**
2673
- * @description saves the submitted answer in the store
2674
- * @param {Object} theAnswer
2675
- * deprecated param {Boolean} isCounted inticates in wich array it will ba saved, true = quizAnswers, false = pollAnswers
2676
- */
2677
- saveAnswer(theAnswer) {
2678
- //Sould only save (add/update) the current quizAnswer (answer and total attempts) in UserInteraction for related page
2679
-
2680
- if (
2681
- this.userInteraction &&
2682
- this.userInteraction.quizAnswers &&
2683
- this.userInteraction.quizAnswers[this.quizData.id]
2684
- ) {
2685
- this.userInteraction.quizAnswers[this.quizData.id] = {
2686
- value: theAnswer[this.quizData.id],
2687
- total_attempts: this.totalAttempts
2688
- }
2689
- } else {
2690
- theAnswer.total_attempts = this.totalAttempts
2691
- this.userInteraction.quizAnswers = {
2692
- ...this.userInteraction.quizAnswers,
2693
- [this.quizData.id]: {
2694
- value: theAnswer[this.quizData.id],
2695
- total_attempts: this.totalAttempts
2696
- }
2697
- }
2698
- }
2699
- },
2700
- /**
2701
- * @description
2702
- * @param {object} value
2703
- */
2704
- inputChange(value) {
2705
- this.quizInputType = value
2706
- },
2707
- /**
2708
- * @description gets the answers in the scorm if they exists
2709
- */
2710
- getPreviousAnswers() {
2711
- const { id, type_question } = this.quizData
2712
- if (
2713
- this.userInteraction &&
2714
- this.userInteraction.quizAnswers &&
2715
- this.userInteraction.quizAnswers[id]
2716
- ) {
2717
- const { value: theValue, total_attempts } =
2718
- this.userInteraction.quizAnswers[id]
2719
- this.totalAttempts = total_attempts
2720
- if (this.quizLimitActive) this.quizCompleted = true //Signal that quiz has been completed
2721
-
2722
- switch (true) {
2723
- case ['choix_unique', 'choix_mult', 'reponse_ouverte'].includes(
2724
- type_question
2725
- ):
2726
- this.quizInputType = theValue
2727
- break
2728
-
2729
- case [
2730
- 'dropdown',
2731
- 'texte_troue_select',
2732
- 'texte_tableau',
2733
- 'texte_troue'
2734
- ].includes(type_question): {
2735
- let theDropdownValues = []
2736
-
2737
- for (
2738
- let singleValuePos = 0;
2739
- singleValuePos < theValue.length;
2740
- singleValuePos++
2741
- ) {
2742
- const singleValue = ['texte_troue_select', 'dropdown'].includes(
2743
- type_question
2744
- )
2745
- ? theValue[singleValuePos].reponse_id
2746
- : theValue[singleValuePos].reponse
2747
-
2748
- theDropdownValues.push(singleValue)
2749
- }
2750
-
2751
- this.quizInputType = theDropdownValues
2752
- break
2753
- }
2754
- }
2755
- this.showSolution = true
2756
- }
2757
- },
2758
- /**
2759
- * @description check if this question is correct
2760
- * @fires quiz-submit to AppCompQuiz.vue
2761
- */
2762
- validateAnswers() {
2763
- let theAnswer = {}
2764
- const { type_question, id, choix_reponse, texte_base } = this.quizData
2765
-
2766
- switch (true) {
2767
- case type_question == 'choix_unique': {
2768
- let simpleInput = this.quizInputType
2769
- if (simpleInput) {
2770
- theAnswer = {
2771
- [id]: simpleInput
2772
- }
2773
- } else {
2774
- //did not answered
2775
- theAnswer = null
2776
- }
2777
-
2778
- break
2779
- }
2780
-
2781
- case ['choix_mult', 'reponse_ouverte'].includes(type_question): {
2782
- let listInput = this.quizInputType
2783
- if (listInput.length > 0) {
2784
- theAnswer = {
2785
- [id]: listInput
2786
- }
2787
- } else {
2788
- //did not answered
2789
- theAnswer = null
2790
- }
2791
-
2792
- break
2793
- }
2794
-
2795
- case type_question == 'dropdown': {
2796
- let listQuizSelected = this.quizInputType
2797
-
2798
- if (
2799
- listQuizSelected.length &&
2800
- !this.$helper.containsValue(listQuizSelected, null)
2801
- ) {
2802
- let listQuizSelectedConvert = []
2803
- for (let index = 0; index < choix_reponse.length; index++) {
2804
- const element = choix_reponse[index]
2805
-
2806
- listQuizSelectedConvert.push({
2807
- question_id: element.id,
2808
- reponse_id: listQuizSelected[index]
2809
- })
2810
- }
2811
- theAnswer = {
2812
- [id]: listQuizSelectedConvert
2813
- }
2814
- } else {
2815
- //did not answered
2816
- theAnswer = null
2817
- }
2818
- break
2819
- }
2820
-
2821
- case type_question == 'texte_troue_select': {
2822
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
2823
- let matchAll = texte_base.split(regex)
2824
- let listQuizSelectedText = this.quizInputType
2825
- if (
2826
- listQuizSelectedText.length == matchAll.length - 1 &&
2827
- !this.$helper.containsValue(listQuizSelectedText, null)
2828
- ) {
2829
- let listQuizSelectedTextConvert = []
2830
- for (let index = 0; index < listQuizSelectedText.length; index++) {
2831
- listQuizSelectedTextConvert.push({
2832
- question_id: index,
2833
- reponse_id: listQuizSelectedText[index]
2834
- })
2835
- }
2836
- theAnswer = {
2837
- [id]: listQuizSelectedTextConvert
2838
- }
2839
- } else {
2840
- //did not answered
2841
- theAnswer = null
2842
- }
2843
- break
2844
- }
2845
-
2846
- case type_question == 'texte_tableau': {
2847
- let listInputTextTable = this.quizInputType
2848
-
2849
- if (
2850
- listInputTextTable.length == choix_reponse.length &&
2851
- !this.$helper.containsValue(listInputTextTable, null) &&
2852
- !this.$helper.containsValue(listInputTextTable, '')
2853
- ) {
2854
- let listInputTextTableConvert = []
2855
- for (let index = 0; index < choix_reponse.length; index++) {
2856
- const element = choix_reponse[index]
2857
- listInputTextTableConvert.push({
2858
- question_id: element.id,
2859
- reponse: listInputTextTable[index]
2860
- })
2861
- }
2862
- theAnswer = {
2863
- [id]: listInputTextTableConvert
2864
- }
2865
- } else {
2866
- //did not answered
2867
- theAnswer = null
2868
- }
2869
- break
2870
- }
2871
-
2872
- case type_question == 'texte_troue': {
2873
- const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
2874
- let matchAll = texte_base.split(regex)
2875
- let listInputTextFill = this.quizInputType
2876
-
2877
- if (
2878
- listInputTextFill.length == matchAll.length - 1 &&
2879
- !this.$helper.containsValue(listInputTextFill, null) &&
2880
- !this.$helper.containsValue(listInputTextFill, '')
2881
- ) {
2882
- let listInputTextFillConvert = []
2883
- for (let index = 0; index < listInputTextFill.length; index++) {
2884
- listInputTextFillConvert.push({
2885
- question_id: index,
2886
- reponse: listInputTextFill[index]
2887
- })
2888
- }
2889
- theAnswer = {
2890
- [id]: listInputTextFillConvert
2891
- }
2892
- } else {
2893
- //did not answered
2894
- theAnswer = null
2895
- }
2896
- break
2897
- }
2898
- }
2899
- this.checkEntry(theAnswer)
2900
- }
2901
- }
2902
- }
2903
- </script>
2904
- <style lang="scss">
2905
- .custom-control {
2906
- z-index: 0;
2907
- }
2908
- </style>