fcad-core-dragon 2.0.0-beta.0 → 2.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +6 -31
- package/.prettierrc +11 -0
- package/.vscode/extensions.json +8 -0
- package/.vscode/settings.json +16 -0
- package/CHANGELOG +153 -0
- package/README.md +28 -43
- package/documentation/.vitepress/config.js +114 -0
- package/documentation/api-examples.md +49 -0
- package/documentation/composants/app-base-button.md +58 -0
- package/documentation/composants/app-base-error-display.md +59 -0
- package/documentation/composants/app-base-popover.md +68 -0
- package/documentation/composants/app-comp-audio.md +75 -0
- package/documentation/composants/app-comp-branch-buttons.md +111 -0
- package/documentation/composants/app-comp-button-progress.md +53 -0
- package/documentation/composants/app-comp-carousel.md +53 -0
- package/documentation/composants/app-comp-container.md +53 -0
- package/documentation/composants/app-comp-input-checkbox-next.md +42 -0
- package/documentation/composants/app-comp-input-dropdown-next.md +34 -0
- package/documentation/composants/app-comp-input-radio-next.md +39 -0
- package/documentation/composants/app-comp-input-text-next.md +35 -0
- package/documentation/composants/app-comp-input-text-table-next.md +34 -0
- package/documentation/composants/app-comp-input-text-to-fill-dropdown-next.md +53 -0
- package/documentation/composants/app-comp-input-text-to-fill-next.md +31 -0
- package/documentation/composants/app-comp-jauge.md +31 -0
- package/documentation/composants/app-comp-menu-item.md +55 -0
- package/documentation/composants/app-comp-menu.md +29 -0
- package/documentation/composants/app-comp-navigation.md +41 -0
- package/documentation/composants/app-comp-note-call.md +53 -0
- package/documentation/composants/app-comp-note-credit.md +53 -0
- package/documentation/composants/app-comp-play-bar-next.md +53 -0
- package/documentation/composants/app-comp-pop-up-next.md +93 -0
- package/documentation/composants/app-comp-quiz-next.md +235 -0
- package/documentation/composants/app-comp-quiz-recall.md +53 -0
- package/documentation/composants/app-comp-svg-next.md +53 -0
- package/documentation/composants/app-comp-table-of-content.md +50 -0
- package/documentation/composants/app-comp-video-player.md +82 -0
- package/documentation/composants.md +46 -0
- package/documentation/composants_critiques/ModelPageComposant.md +53 -0
- package/documentation/composants_critiques/app-base-module.md +43 -0
- package/documentation/composants_critiques/app-base-page.md +48 -0
- package/documentation/composants_critiques/app-base.md +311 -0
- package/documentation/composants_critiques/main.md +15 -0
- package/documentation/demarrage.md +50 -0
- package/documentation/deploiement.md +58 -0
- package/documentation/index.md +33 -0
- package/documentation/markdown-examples.md +85 -0
- package/documentation/public/npm_version.png +0 -0
- package/documentation/public/vite.svg +15 -0
- package/documentation/public/vuejs.svg +2 -0
- package/documentation/public/vuetify.svg +6 -0
- package/eslint.config.js +60 -0
- package/package.json +43 -49
- package/src/$locales/en.json +94 -92
- package/src/$locales/fr.json +77 -113
- package/src/assets/data/onboardingMessages.json +1 -1
- package/src/components/AppBase.vue +971 -437
- package/src/components/AppBaseButton.test.js +21 -0
- package/src/components/AppBaseButton.vue +42 -10
- package/src/components/AppBaseErrorDisplay.vue +209 -162
- package/src/components/AppBaseFlipCard.vue +1 -0
- package/src/components/AppBaseModule.vue +1021 -976
- package/src/components/AppBasePage.vue +656 -128
- package/src/components/AppBasePopover.vue +41 -0
- package/src/components/AppBaseSkeleton.vue +66 -0
- package/src/components/AppCompAudio.vue +256 -0
- package/src/components/AppCompBranchButtons.vue +108 -181
- package/src/components/AppCompButtonProgress.vue +44 -70
- package/src/components/AppCompCarousel.vue +284 -233
- package/src/components/AppCompContainer.vue +29 -0
- package/src/components/AppCompInputCheckBoxNx.vue +323 -0
- package/src/components/AppCompInputDropdownNx.vue +299 -0
- package/src/components/AppCompInputRadioNx.vue +284 -0
- package/src/components/AppCompInputTextNx.vue +153 -0
- package/src/components/AppCompInputTextTableNx.vue +202 -0
- package/src/components/AppCompInputTextToFillDropdownNx.vue +340 -0
- package/src/components/AppCompInputTextToFillNx.vue +313 -0
- package/src/components/AppCompJauge.vue +36 -11
- package/src/components/AppCompMenu.vue +312 -92
- package/src/components/AppCompMenuItem.vue +129 -105
- package/src/components/AppCompNavigation.vue +972 -0
- package/src/components/AppCompNoteCall.vue +161 -0
- package/src/components/AppCompNoteCredit.vue +491 -0
- package/src/components/AppCompPlayBarNext.vue +2288 -0
- package/src/components/AppCompPopUpNext.vue +504 -0
- package/src/components/AppCompQuizNext.vue +510 -0
- package/src/components/AppCompQuizRecall.vue +350 -0
- package/src/components/AppCompSVGNext.vue +346 -0
- package/src/components/AppCompSettingsMenu.vue +18 -16
- package/src/components/AppCompTableOfContent.vue +340 -122
- package/src/components/AppCompVideoPlayer.vue +377 -0
- package/src/components/BaseModule.vue +24 -117
- package/src/components/tests__/AppBaseButton.spec.js +53 -0
- package/src/components/tests__/useTimer.spec.js +91 -0
- package/src/composables/useIdleDetector.js +56 -0
- package/src/composables/useQuiz.js +89 -0
- package/src/composables/useTimer.js +172 -0
- package/src/directives/nvdaFix.js +53 -0
- package/src/externalComps/ModuleView.vue +22 -0
- package/src/externalComps/SummaryView.vue +91 -0
- package/src/main.js +400 -142
- package/src/module/stores/appStore.js +947 -0
- package/src/module/xapi/ADL.js +241 -60
- package/src/module/xapi/Crypto/Hasher.js +8 -8
- package/src/module/xapi/Crypto/WordArray.js +6 -6
- package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +4 -4
- package/src/module/xapi/Crypto/algorithms/C_algo.js +14 -18
- package/src/module/xapi/Crypto/algorithms/HMAC.js +1 -1
- package/src/module/xapi/Crypto/algorithms/SHA1.js +1 -1
- package/src/module/xapi/Crypto/encoders/Base.js +7 -7
- package/src/module/xapi/Crypto/encoders/Base64.js +3 -3
- package/src/module/xapi/Crypto/encoders/Hex.js +4 -3
- package/src/module/xapi/Crypto/encoders/Latin1.js +3 -3
- package/src/module/xapi/Crypto/encoders/Utf8.js +3 -3
- package/src/module/xapi/Statement/index.js +3 -3
- package/src/module/xapi/launch.js +10 -10
- package/src/module/xapi/utils.js +17 -17
- package/src/module/xapi/wrapper.js +223 -218
- package/src/module/xapi/xapiStatement.js +29 -29
- package/src/plugins/analytics.js +34 -0
- package/src/plugins/bus.js +7 -2
- package/src/plugins/gsap.js +9 -8
- package/src/plugins/helper.js +141 -43
- package/src/plugins/i18n.js +13 -18
- package/src/plugins/idb.js +46 -30
- package/src/plugins/save.js +1 -1
- package/src/plugins/scorm.js +15 -15
- package/src/plugins/xapi.js +2 -2
- package/src/public/index.html +23 -11
- package/src/router/index.js +57 -0
- package/src/router/routes.js +312 -0
- package/src/shared/generalfuncs.js +241 -10
- package/src/shared/validators.js +1018 -0
- package/vitest.config.js +19 -0
- package/.eslintignore +0 -29
- package/.eslintrc.js +0 -86
- package/.prettierrc.js +0 -5
- package/babel.config.js +0 -3
- package/src/components/AppBaseDragChoice.vue +0 -91
- package/src/components/AppBaseDropZone.vue +0 -112
- package/src/components/AppCompDragAndDrop.vue +0 -339
- package/src/components/AppCompInputAssociation.vue +0 -332
- package/src/components/AppCompInputCheckBox.vue +0 -227
- package/src/components/AppCompInputDropdown.vue +0 -184
- package/src/components/AppCompInputRadio.vue +0 -169
- package/src/components/AppCompInputTextBox.vue +0 -91
- package/src/components/AppCompInputTextTable.vue +0 -155
- package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
- package/src/components/AppCompInputTextToFillText.vue +0 -164
- package/src/components/AppCompMediaPlayer.vue +0 -365
- package/src/components/AppCompNavigationFull.vue +0 -1791
- package/src/components/AppCompPlayBar.vue +0 -1540
- package/src/components/AppCompPopUp.vue +0 -523
- package/src/components/AppCompQuiz.vue +0 -2998
- package/src/components/AppCompToolTip.vue +0 -94
- package/src/mixins/$pageMixins.js +0 -381
- package/src/mixins/$quizMixins.js +0 -456
- package/src/mixins/timerMixin.js +0 -132
- package/src/module/store.js +0 -874
- package/src/plugins/timeManager.js +0 -77
- package/src/routes.js +0 -734
- package/vue.config.js +0 -83
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-for="singleDropdown in theInputData"
|
|
5
|
-
:key="singleDropdown.id"
|
|
6
|
-
class="texteatrou"
|
|
7
|
-
>
|
|
8
|
-
<span v-if="!singleDropdown.type" v-html="singleDropdown.content"></span>
|
|
9
|
-
<label
|
|
10
|
-
:for="`${inputDataId}_${singleDropdown.id}-champ`"
|
|
11
|
-
style="display:none;"
|
|
12
|
-
>
|
|
13
|
-
{{ $t('text.quiz') }}
|
|
14
|
-
</label>
|
|
15
|
-
<b-form-select
|
|
16
|
-
v-if="singleDropdown.type == 'dropdown'"
|
|
17
|
-
:id="`${inputDataId}_${singleDropdown.id}-champ`"
|
|
18
|
-
v-model="quizSelectedValue[singleDropdown.id]"
|
|
19
|
-
:class="classInput(singleDropdown.id)"
|
|
20
|
-
:options="singleDropdown.option"
|
|
21
|
-
:disabled="quizCompleted"
|
|
22
|
-
:aria-describedby="`${inputDataId}_${singleDropdown.id}-msg-erreur`"
|
|
23
|
-
></b-form-select>
|
|
24
|
-
<span
|
|
25
|
-
:id="`${inputDataId}_${singleDropdown.id}-msg-erreur`"
|
|
26
|
-
class="sr-only"
|
|
27
|
-
>
|
|
28
|
-
{{ messageAccessibility(singleDropdown.id) }}
|
|
29
|
-
</span>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</template>
|
|
33
|
-
<script>
|
|
34
|
-
import $extendsQuiz from '../mixins/$quizMixins'
|
|
35
|
-
export default {
|
|
36
|
-
name: 'AppCompInputTextToFillDropdown',
|
|
37
|
-
mixins: [$extendsQuiz],
|
|
38
|
-
|
|
39
|
-
props: {
|
|
40
|
-
inputType: {
|
|
41
|
-
type: String,
|
|
42
|
-
default: ''
|
|
43
|
-
},
|
|
44
|
-
inputDataId: {
|
|
45
|
-
type: String,
|
|
46
|
-
default: ''
|
|
47
|
-
},
|
|
48
|
-
inputData: {
|
|
49
|
-
type: Array,
|
|
50
|
-
default: () => []
|
|
51
|
-
},
|
|
52
|
-
textBase: {
|
|
53
|
-
type: String,
|
|
54
|
-
default: ''
|
|
55
|
-
},
|
|
56
|
-
quizCompleted: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
default: false
|
|
59
|
-
},
|
|
60
|
-
solution: {
|
|
61
|
-
type: Array,
|
|
62
|
-
default: () => []
|
|
63
|
-
},
|
|
64
|
-
showSolution: {
|
|
65
|
-
type: Boolean,
|
|
66
|
-
default: false
|
|
67
|
-
},
|
|
68
|
-
shuffleAnswers: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: false
|
|
71
|
-
},
|
|
72
|
-
quizSelected: {
|
|
73
|
-
type: Array,
|
|
74
|
-
default: () => []
|
|
75
|
-
}, //use to pass the value of the input
|
|
76
|
-
quizSubmit: {
|
|
77
|
-
type: Boolean,
|
|
78
|
-
default: false
|
|
79
|
-
} //use to call a submit
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
data() {
|
|
83
|
-
return {
|
|
84
|
-
quizSelectedValue: [], //not using quizSelected because quizSelected is a prop
|
|
85
|
-
theInputData: [] //to create the list of drop down and text mixed togeter
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
computed: {},
|
|
90
|
-
|
|
91
|
-
watch: {
|
|
92
|
-
/**
|
|
93
|
-
* @description to pass value to AppCompQuiz
|
|
94
|
-
* @fires input-change to AppCompQuiz.vue
|
|
95
|
-
*/
|
|
96
|
-
quizSelectedValue(newValue) {
|
|
97
|
-
this.$emit('input-change', newValue)
|
|
98
|
-
},
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* @description to pass the value from AppCompQuiz
|
|
102
|
-
*/
|
|
103
|
-
quizSelected(newValue) {
|
|
104
|
-
this.quizSelectedValue = newValue
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
mounted() {
|
|
109
|
-
if (this.solution !== null) {
|
|
110
|
-
this.solution.sort(function(a, b) {
|
|
111
|
-
return a.question_id - b.question_id
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
//to show the defaultAnswer
|
|
115
|
-
const defaultAnswer = {
|
|
116
|
-
value: null,
|
|
117
|
-
disabled: true,
|
|
118
|
-
text: this.$t('message.first_option_dropdown')
|
|
119
|
-
}
|
|
120
|
-
let selectedChoices = []
|
|
121
|
-
for (let i = 0; i < this.inputData.length; i++) {
|
|
122
|
-
let singleDropdown = {}
|
|
123
|
-
if (this.shuffleAnswers) {
|
|
124
|
-
singleDropdown = this.inputData[i]
|
|
125
|
-
singleDropdown[
|
|
126
|
-
Object.keys(this.inputData[i])[0].toString()
|
|
127
|
-
] = this.shuffleArray(Object.values(this.inputData[i])[0])
|
|
128
|
-
} else {
|
|
129
|
-
singleDropdown = this.inputData[i]
|
|
130
|
-
}
|
|
131
|
-
for (
|
|
132
|
-
let index = 0;
|
|
133
|
-
index < Object.values(singleDropdown)[0].length;
|
|
134
|
-
index++
|
|
135
|
-
) {
|
|
136
|
-
const element = Object.values(singleDropdown)[0][index]
|
|
137
|
-
if (
|
|
138
|
-
element.text &&
|
|
139
|
-
element.text == this.$t('message.first_option_dropdown')
|
|
140
|
-
) {
|
|
141
|
-
Object.values(singleDropdown)[0].splice(index, 1)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
Object.values(singleDropdown)[0].unshift(defaultAnswer)
|
|
145
|
-
|
|
146
|
-
selectedChoices.push(null)
|
|
147
|
-
}
|
|
148
|
-
if (this.quizSelected.length == 0) {
|
|
149
|
-
this.quizSelectedValue = selectedChoices
|
|
150
|
-
} else {
|
|
151
|
-
this.quizSelectedValue = this.quizSelected
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
this.createTextWithInput(this.textBase)
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
methods: {
|
|
158
|
-
/**
|
|
159
|
-
* @description create the object to genate the text and inputs
|
|
160
|
-
* @param {String} str the text with holes to fill
|
|
161
|
-
*/
|
|
162
|
-
createTextWithInput(str) {
|
|
163
|
-
const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
|
|
164
|
-
let matchAll = str.split(regex)
|
|
165
|
-
let listInput = []
|
|
166
|
-
for (let i = 0; i < this.inputData.length; i++) {
|
|
167
|
-
const element = this.inputData[i]
|
|
168
|
-
listInput.push({ id: 't' + i, content: matchAll[i] })
|
|
169
|
-
listInput.push({
|
|
170
|
-
id: i,
|
|
171
|
-
type: 'dropdown',
|
|
172
|
-
option: Object.values(element)[0]
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
let lastItem = matchAll.length - 1
|
|
176
|
-
listInput.push({ id: 't' + lastItem, content: matchAll[lastItem] })
|
|
177
|
-
this.theInputData = listInput
|
|
178
|
-
},
|
|
179
|
-
/**
|
|
180
|
-
* @description used by the dropdown quiz
|
|
181
|
-
* @param {Array} answers what the user has answered
|
|
182
|
-
* @param {Array} solution the correct choices
|
|
183
|
-
* @returns {Boolean}
|
|
184
|
-
* @todo Add a catching for error if the 2 question_id dont match
|
|
185
|
-
*/
|
|
186
|
-
compareSelectedAnswers(answers, solution) {
|
|
187
|
-
for (let index = 0; index < answers.length; index++) {
|
|
188
|
-
const elementAnswers = answers[index]
|
|
189
|
-
const elementSolution = solution[index]
|
|
190
|
-
if (elementAnswers.question_id == elementSolution.question_id) {
|
|
191
|
-
if (elementAnswers.reponse_id !== elementSolution.reponse_id) {
|
|
192
|
-
return false
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
return //if it return nothing there is a bug since this means the 2 question_id dont match
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return true
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* @description check if a values exists in a array
|
|
203
|
-
* @param {Array} array
|
|
204
|
-
* @param value
|
|
205
|
-
* @returns {Boolean}
|
|
206
|
-
*/
|
|
207
|
-
containsValue(array, value) {
|
|
208
|
-
return array.includes(value)
|
|
209
|
-
},
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* @description shuffles an array used to randomized the option order if shuffleAnswers is true
|
|
213
|
-
* @param {Array} array
|
|
214
|
-
* @returns {Array}
|
|
215
|
-
*/
|
|
216
|
-
shuffleArray(array) {
|
|
217
|
-
let newArray = []
|
|
218
|
-
let newArray2 = []
|
|
219
|
-
|
|
220
|
-
for (let i = 0; i < array.length; i++) {
|
|
221
|
-
const element = array[i]
|
|
222
|
-
//todo remove null values
|
|
223
|
-
newArray.push(element)
|
|
224
|
-
}
|
|
225
|
-
while (newArray.length > 0) {
|
|
226
|
-
let pos = Math.floor(newArray.length * Math.random())
|
|
227
|
-
newArray2.push(newArray[pos])
|
|
228
|
-
newArray.splice(pos, 1)
|
|
229
|
-
}
|
|
230
|
-
return newArray2
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
</script>
|
|
235
|
-
<style lang="scss" scoped>
|
|
236
|
-
select {
|
|
237
|
-
&.custom-select {
|
|
238
|
-
background-image: inherit;
|
|
239
|
-
|
|
240
|
-
&:focus {
|
|
241
|
-
border-color: inherit;
|
|
242
|
-
box-shadow: inherit;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/***** style dev *****/
|
|
248
|
-
.texteatrou {
|
|
249
|
-
display: inline;
|
|
250
|
-
}
|
|
251
|
-
.texteatrou > select {
|
|
252
|
-
display: inline;
|
|
253
|
-
width: auto;
|
|
254
|
-
}
|
|
255
|
-
</style>
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div
|
|
4
|
-
v-for="textInput in theInputData"
|
|
5
|
-
:key="textInput.id"
|
|
6
|
-
class="texteatrou"
|
|
7
|
-
>
|
|
8
|
-
<span v-if="!textInput.type" v-html="textInput.content"></span>
|
|
9
|
-
<label
|
|
10
|
-
:for="`${inputDataId}_${textInput.id}-champ`"
|
|
11
|
-
style="display:none;"
|
|
12
|
-
>
|
|
13
|
-
{{ $t('text.quiz') }}
|
|
14
|
-
</label>
|
|
15
|
-
<b-form-input
|
|
16
|
-
v-if="textInput.type == 'inputText'"
|
|
17
|
-
:id="`${inputDataId}_${textInput.id}-champ`"
|
|
18
|
-
v-model="quizTextTableValue[textInput.id]"
|
|
19
|
-
:class="classInput(textInput.id)"
|
|
20
|
-
:placeholder="$t('text.place_holder.for_textarea')"
|
|
21
|
-
:disabled="quizCompleted"
|
|
22
|
-
rows="1"
|
|
23
|
-
no-resize
|
|
24
|
-
:aria-describedby="`${inputDataId}_${textInput.id}-msg-erreur`"
|
|
25
|
-
></b-form-input>
|
|
26
|
-
<span :id="`${inputDataId}_${textInput.id}-msg-erreur`" class="sr-only">
|
|
27
|
-
{{ messageAccessibility(textInput.id) }}
|
|
28
|
-
</span>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
<script>
|
|
33
|
-
import $extendsQuiz from '../mixins/$quizMixins'
|
|
34
|
-
export default {
|
|
35
|
-
name: 'AppCompInputTextToFillText',
|
|
36
|
-
mixins: [$extendsQuiz],
|
|
37
|
-
|
|
38
|
-
props: {
|
|
39
|
-
inputType: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: ''
|
|
42
|
-
},
|
|
43
|
-
inputDataId: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: ''
|
|
46
|
-
},
|
|
47
|
-
inputData: {
|
|
48
|
-
type: Array,
|
|
49
|
-
default: () => []
|
|
50
|
-
},
|
|
51
|
-
textBase: {
|
|
52
|
-
type: String,
|
|
53
|
-
default: ''
|
|
54
|
-
},
|
|
55
|
-
quizCompleted: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
},
|
|
59
|
-
solution: {
|
|
60
|
-
type: Array,
|
|
61
|
-
default: () => []
|
|
62
|
-
},
|
|
63
|
-
showSolution: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
quizTextTable: {
|
|
68
|
-
type: Array,
|
|
69
|
-
default: () => []
|
|
70
|
-
}, //use to pass the value of the input
|
|
71
|
-
quizSubmit: {
|
|
72
|
-
type: Boolean,
|
|
73
|
-
default: false
|
|
74
|
-
} //use to call a submit
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
data() {
|
|
78
|
-
return {
|
|
79
|
-
quizTextTableValue: [], //not using quizTextTable because quizTextTable is a prop
|
|
80
|
-
theInputData: [] //to create the list of drop down and text mixed togeter
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
computed: {},
|
|
85
|
-
|
|
86
|
-
watch: {
|
|
87
|
-
/**
|
|
88
|
-
* @description to pass value to AppCompQuiz
|
|
89
|
-
* @fires input-change to AppCompQuiz.vue
|
|
90
|
-
*/
|
|
91
|
-
quizTextTableValue(newValue) {
|
|
92
|
-
this.$emit('input-change', newValue)
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @description to pass the value from AppCompQuiz
|
|
97
|
-
*/
|
|
98
|
-
quizTextTable(newValue) {
|
|
99
|
-
this.quizTextTableValue = newValue
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
mounted() {
|
|
104
|
-
if (this.solution !== null) {
|
|
105
|
-
this.solution.sort(function(a, b) {
|
|
106
|
-
return a.question_id - b.question_id
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
let textChoices = []
|
|
110
|
-
|
|
111
|
-
const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
|
|
112
|
-
let matchAll = this.textBase.split(regex)
|
|
113
|
-
|
|
114
|
-
for (let i = 0; i < matchAll.length - 1; i++) {
|
|
115
|
-
textChoices.push('')
|
|
116
|
-
}
|
|
117
|
-
//apply previous answers
|
|
118
|
-
if (this.quizTextTable && this.quizTextTable.length == 0) {
|
|
119
|
-
this.quizTextTableValue = textChoices
|
|
120
|
-
} else {
|
|
121
|
-
this.quizTextTableValue = this.quizTextTable
|
|
122
|
-
}
|
|
123
|
-
this.createTextWithInput(this.textBase)
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
methods: {
|
|
127
|
-
/**
|
|
128
|
-
* @description create the object to genate the text and inputs
|
|
129
|
-
* @param {String} str the text with holes to fill
|
|
130
|
-
*/
|
|
131
|
-
createTextWithInput(str) {
|
|
132
|
-
const regex = /\$%\S*%\$/g // regex pattern to match exp: $%number%$
|
|
133
|
-
let matchAll = str.split(regex)
|
|
134
|
-
let listInput = []
|
|
135
|
-
for (let i = 0; i < matchAll.length - 1; i++) {
|
|
136
|
-
listInput.push({ id: 't' + i, content: matchAll[i] })
|
|
137
|
-
listInput.push({ id: i, type: 'inputText' })
|
|
138
|
-
}
|
|
139
|
-
let lastItem = matchAll.length - 1
|
|
140
|
-
listInput.push({ id: 't' + lastItem, content: matchAll[lastItem] })
|
|
141
|
-
this.theInputData = listInput
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* @description check if a values exists in a array
|
|
146
|
-
* @param {Array} array
|
|
147
|
-
* @param value
|
|
148
|
-
* @returns {Boolean}
|
|
149
|
-
*/
|
|
150
|
-
containsValue(array, value) {
|
|
151
|
-
return array.includes(value)
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
</script>
|
|
156
|
-
<style lang="scss" scoped>
|
|
157
|
-
.texteatrou {
|
|
158
|
-
display: inline;
|
|
159
|
-
}
|
|
160
|
-
.texteatrou > input {
|
|
161
|
-
display: inline;
|
|
162
|
-
width: auto;
|
|
163
|
-
}
|
|
164
|
-
</style>
|