fcad-core-dragon 2.0.0-beta.1 → 2.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +33 -33
- package/.eslintignore +29 -29
- package/{.eslintrc.js → .eslintrc.cjs} +81 -86
- package/CHANGELOG +364 -364
- package/README.md +71 -71
- package/bk.scss +117 -0
- package/package.json +61 -63
- package/src/$locales/en.json +143 -179
- package/src/$locales/fr.json +105 -181
- package/src/assets/data/onboardingMessages.json +47 -47
- package/src/components/AppBase.vue +1054 -614
- package/src/components/AppBaseButton.vue +87 -63
- package/src/components/AppBaseErrorDisplay.vue +438 -420
- package/src/components/AppBaseFlipCard.vue +84 -83
- package/src/components/AppBaseModule.vue +1673 -1842
- package/src/components/AppBasePage.vue +779 -312
- package/src/components/AppBasePopover.vue +41 -0
- package/src/components/AppCompAudio.vue +234 -0
- package/src/components/AppCompBranchButtons.vue +552 -582
- package/src/components/AppCompButtonProgress.vue +126 -147
- package/src/components/AppCompCarousel.vue +298 -192
- package/src/components/AppCompInputCheckBoxNext.vue +195 -0
- package/src/components/AppCompInputDropdownNext.vue +159 -0
- package/src/components/AppCompInputRadioNext.vue +152 -0
- package/src/components/{AppCompInputTextBox.vue → AppCompInputTextNext.vue} +106 -91
- package/src/components/AppCompInputTextTableNext.vue +141 -0
- package/src/components/AppCompInputTextToFillDropdownNext.vue +230 -0
- package/src/components/{AppCompInputTextToFillText.vue → AppCompInputTextToFillNext.vue} +171 -164
- package/src/components/AppCompJauge.vue +74 -55
- package/src/components/AppCompMenu.vue +413 -209
- package/src/components/AppCompMenuItem.vue +228 -174
- package/src/components/AppCompNavigation.vue +960 -949
- package/src/components/AppCompNoteCall.vue +133 -126
- package/src/components/AppCompNoteCredit.vue +292 -164
- package/src/components/AppCompPlayBar.vue +1218 -1319
- package/src/components/AppCompPlayBarNext.vue +2052 -0
- package/src/components/AppCompPlayBarProgress.vue +82 -0
- package/src/components/AppCompPopUpNext.vue +503 -0
- package/src/components/{AppCompQuiz.vue → AppCompQuizNext.vue} +2904 -2989
- package/src/components/AppCompQuizRecall.vue +276 -250
- package/src/components/AppCompSVGNext.vue +347 -0
- package/src/components/AppCompSettingsMenu.vue +172 -171
- package/src/components/AppCompTableOfContent.vue +387 -264
- package/src/components/AppCompTranscript.vue +24 -19
- package/src/components/AppCompVideoPlayer.vue +368 -336
- package/src/components/AppCompViewDisplay.vue +6 -6
- package/src/components/BaseModule.vue +72 -67
- package/src/composables/useQuiz.js +206 -0
- package/src/externalComps/ModuleView.vue +22 -0
- package/src/externalComps/SummaryView.vue +91 -0
- package/src/main.js +272 -227
- package/src/mixins/$mediaMixins.js +819 -0
- package/src/mixins/timerMixin.js +155 -156
- package/src/module/stores/appStore.js +893 -0
- package/src/module/xapi/ADL.js +376 -339
- package/src/module/xapi/Crypto/Hasher.js +241 -241
- package/src/module/xapi/Crypto/WordArray.js +278 -278
- package/src/module/xapi/Crypto/algorithms/BufferedBlockAlgorithm.js +103 -103
- package/src/module/xapi/Crypto/algorithms/C_algo.js +315 -319
- package/src/module/xapi/Crypto/algorithms/HMAC.js +9 -9
- package/src/module/xapi/Crypto/algorithms/SHA1.js +9 -9
- package/src/module/xapi/Crypto/encoders/Base.js +105 -105
- package/src/module/xapi/Crypto/encoders/Base64.js +99 -99
- package/src/module/xapi/Crypto/encoders/Hex.js +61 -61
- package/src/module/xapi/Crypto/encoders/Latin1.js +61 -61
- package/src/module/xapi/Crypto/encoders/Utf8.js +45 -45
- package/src/module/xapi/Crypto/index.js +53 -53
- package/src/module/xapi/Statement/activity.js +47 -47
- package/src/module/xapi/Statement/agent.js +55 -55
- package/src/module/xapi/Statement/group.js +26 -26
- package/src/module/xapi/Statement/index.js +259 -259
- package/src/module/xapi/Statement/statement.js +253 -253
- package/src/module/xapi/Statement/statementRef.js +23 -23
- package/src/module/xapi/Statement/substatement.js +22 -22
- package/src/module/xapi/Statement/verb.js +36 -36
- package/src/module/xapi/activitytypes.js +17 -17
- package/src/module/xapi/launch.js +157 -157
- package/src/module/xapi/utils.js +167 -167
- package/src/module/xapi/verbs.js +294 -294
- package/src/module/xapi/wrapper.js +1963 -1890
- package/src/module/xapi/xapiStatement.js +444 -444
- package/src/plugins/bus.js +8 -3
- package/src/plugins/gsap.js +14 -17
- package/src/plugins/helper.js +308 -295
- package/src/plugins/i18n.js +44 -31
- package/src/plugins/idb.js +219 -212
- package/src/plugins/save.js +37 -37
- package/src/plugins/scorm.js +287 -287
- package/src/plugins/xapi.js +11 -11
- package/src/public/index.html +33 -21
- package/src/router/index.js +43 -41
- package/src/router/routes.js +312 -337
- package/src/shared/generalfuncs.js +210 -188
- package/src/shared/validators.js +1069 -249
- package/vite.config.js +27 -0
- 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/AppCompBif.vue +0 -120
- 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/AppCompInputTextTable.vue +0 -155
- package/src/components/AppCompInputTextToFillDropdown.vue +0 -255
- package/src/components/AppCompMediaPlayer.vue +0 -397
- package/src/components/AppCompPopUp.vue +0 -522
- package/src/components/AppCompPopover.vue +0 -27
- package/src/components/AppCompSVG.vue +0 -309
- package/src/mixins/$pageMixins.js +0 -459
- package/src/mixins/$quizMixins.js +0 -456
- package/src/module/store.js +0 -895
- package/src/plugins/timeManager.js +0 -77
- package/src/routes_bckp.js +0 -313
- package/src/routes_static.js +0 -344
- package/vue.config.js +0 -83
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="input-box">
|
|
3
|
-
<div
|
|
4
|
-
v-for="singleDropdown in inputData"
|
|
5
|
-
:key="singleDropdown.id"
|
|
6
|
-
:class="
|
|
7
|
-
`dropdownlist-${singleDropdown.id} ${classInput(singleDropdown.id)}`
|
|
8
|
-
"
|
|
9
|
-
>
|
|
10
|
-
<label
|
|
11
|
-
:for="`${inputDataId}_${singleDropdown.id}`"
|
|
12
|
-
v-html="singleDropdown.ennonce"
|
|
13
|
-
></label>
|
|
14
|
-
<b-form-select
|
|
15
|
-
:id="inputDataId + '_' + singleDropdown.id"
|
|
16
|
-
v-model="quizSelectedValue[singleDropdown.id]"
|
|
17
|
-
:options="singleDropdown.option"
|
|
18
|
-
:disabled="quizCompleted"
|
|
19
|
-
></b-form-select>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</template>
|
|
23
|
-
<script>
|
|
24
|
-
import $extendsQuiz from '../mixins/$quizMixins'
|
|
25
|
-
export default {
|
|
26
|
-
name: 'AppCompInputDropdown',
|
|
27
|
-
mixins: [$extendsQuiz],
|
|
28
|
-
|
|
29
|
-
props: {
|
|
30
|
-
inputType: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: ''
|
|
33
|
-
},
|
|
34
|
-
inputDataId: {
|
|
35
|
-
type: String,
|
|
36
|
-
default: ''
|
|
37
|
-
},
|
|
38
|
-
inputData: {
|
|
39
|
-
type: Array,
|
|
40
|
-
default: () => []
|
|
41
|
-
},
|
|
42
|
-
quizCompleted: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
default: false
|
|
45
|
-
},
|
|
46
|
-
solution: {
|
|
47
|
-
type: Array,
|
|
48
|
-
default: () => []
|
|
49
|
-
},
|
|
50
|
-
showSolution: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
shuffleAnswers: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false
|
|
57
|
-
},
|
|
58
|
-
quizSelected: {
|
|
59
|
-
type: Array,
|
|
60
|
-
default: () => []
|
|
61
|
-
}, //use to pass the value of the input
|
|
62
|
-
quizSubmit: {
|
|
63
|
-
type: Boolean,
|
|
64
|
-
default: false
|
|
65
|
-
} //use to call a submit
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
data() {
|
|
69
|
-
return {
|
|
70
|
-
quizSelectedValue: [] //not using quizSelected because quizSelected is a prop
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
computed: {},
|
|
75
|
-
|
|
76
|
-
watch: {
|
|
77
|
-
/**
|
|
78
|
-
* @description to pass value to AppCompQuiz
|
|
79
|
-
* @emits input-change
|
|
80
|
-
*/
|
|
81
|
-
quizSelectedValue(newValue) {
|
|
82
|
-
this.$emit('input-change', newValue)
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* @description to pass the value from AppCompQuiz
|
|
87
|
-
*/
|
|
88
|
-
quizSelected(newValue) {
|
|
89
|
-
this.quizSelectedValue = newValue
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
mounted() {
|
|
94
|
-
if (this.solution !== null)
|
|
95
|
-
this.solution.sort(function(a, b) {
|
|
96
|
-
return a.question_id - b.question_id
|
|
97
|
-
})
|
|
98
|
-
//to show the defaultAnswer
|
|
99
|
-
const defaultAnswer = {
|
|
100
|
-
value: null,
|
|
101
|
-
disabled: true,
|
|
102
|
-
text: this.$t('message.first_option_dropdown')
|
|
103
|
-
}
|
|
104
|
-
let selectedChoices = []
|
|
105
|
-
for (let i = 0; i < this.inputData.length; i++) {
|
|
106
|
-
let singleDropdown
|
|
107
|
-
if (this.shuffleAnswers) {
|
|
108
|
-
singleDropdown = this.inputData[i]
|
|
109
|
-
singleDropdown.option = this.shuffleArray(singleDropdown.option)
|
|
110
|
-
} else {
|
|
111
|
-
singleDropdown = this.inputData[i]
|
|
112
|
-
}
|
|
113
|
-
if (
|
|
114
|
-
this.inputData[i].option[0].text !==
|
|
115
|
-
this.$t('message.first_option_dropdown')
|
|
116
|
-
) {
|
|
117
|
-
singleDropdown.option.unshift(defaultAnswer)
|
|
118
|
-
}
|
|
119
|
-
selectedChoices.push(null)
|
|
120
|
-
}
|
|
121
|
-
if (this.quizSelected.length == 0) {
|
|
122
|
-
this.quizSelectedValue = selectedChoices
|
|
123
|
-
} else {
|
|
124
|
-
this.quizSelectedValue = this.quizSelected
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
methods: {
|
|
129
|
-
/**
|
|
130
|
-
* @description used by the dropdown quiz
|
|
131
|
-
* @param {Array} answers what the user has answered
|
|
132
|
-
* @param {Array} solution the correct choices
|
|
133
|
-
* @returns {Boolean}
|
|
134
|
-
* @todo Add a catching for error if the 2 question_id dont match
|
|
135
|
-
*/
|
|
136
|
-
compareSelectedAnswers(answers, solution) {
|
|
137
|
-
for (let index = 0; index < answers.length; index++) {
|
|
138
|
-
const elementAnswers = answers[index]
|
|
139
|
-
const elementSolution = solution[index]
|
|
140
|
-
if (elementAnswers.question_id == elementSolution.question_id) {
|
|
141
|
-
if (elementAnswers.reponse_id !== elementSolution.reponse_id) {
|
|
142
|
-
return false
|
|
143
|
-
}
|
|
144
|
-
} else {
|
|
145
|
-
return //if it return nothing there is a bug since this means the 2 question_id dont match
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return true
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* @description check if a values exists in a array
|
|
153
|
-
* @param {Array} array
|
|
154
|
-
* @param value
|
|
155
|
-
* @returns {Boolean}
|
|
156
|
-
*/
|
|
157
|
-
containsValue(array, value) {
|
|
158
|
-
return array.includes(value)
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @description shuffles an array used to randomized the option order if shuffleAnswers is true
|
|
163
|
-
* @param {Array} array
|
|
164
|
-
* @returns {Array}
|
|
165
|
-
*/
|
|
166
|
-
shuffleArray(array) {
|
|
167
|
-
let newArray = []
|
|
168
|
-
let newArray2 = []
|
|
169
|
-
|
|
170
|
-
for (let i = 0; i < array.length; i++) {
|
|
171
|
-
const element = array[i]
|
|
172
|
-
//todo remove null values
|
|
173
|
-
newArray.push(element)
|
|
174
|
-
}
|
|
175
|
-
while (newArray.length > 0) {
|
|
176
|
-
let pos = Math.floor(newArray.length * Math.random())
|
|
177
|
-
newArray2.push(newArray[pos])
|
|
178
|
-
newArray.splice(pos, 1)
|
|
179
|
-
}
|
|
180
|
-
return newArray2
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
</script>
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="input-box">
|
|
3
|
-
<fieldset>
|
|
4
|
-
<legend
|
|
5
|
-
:id="`lgd_${inputDataId}`"
|
|
6
|
-
class="sr-only"
|
|
7
|
-
tabindex="-1"
|
|
8
|
-
v-html="getQuizQuestion()"
|
|
9
|
-
/>
|
|
10
|
-
|
|
11
|
-
<template v-for="choixReponse in inputDataValue">
|
|
12
|
-
<div
|
|
13
|
-
:Key="`div_chx_${inputDataId}-${choixReponse.id}`"
|
|
14
|
-
class="box-radio"
|
|
15
|
-
>
|
|
16
|
-
<label
|
|
17
|
-
:key="`lbl_chx_${inputDataId}_${choixReponse.id}`"
|
|
18
|
-
:for="`chx_${inputDataId}_${choixReponse.id}`"
|
|
19
|
-
:class="classInput(choixReponse.id)"
|
|
20
|
-
class="radio-label"
|
|
21
|
-
>
|
|
22
|
-
<input
|
|
23
|
-
:id="`chx_${inputDataId}_${choixReponse.id}`"
|
|
24
|
-
:key="`chx_${inputDataId}_${choixReponse.id}`"
|
|
25
|
-
v-model="quizInputUniqueValue"
|
|
26
|
-
type="radio"
|
|
27
|
-
:value="choixReponse.id"
|
|
28
|
-
:name="`btn-radios-${inputDataId}`"
|
|
29
|
-
:disabled="quizCompleted"
|
|
30
|
-
class="radio-input"
|
|
31
|
-
/>
|
|
32
|
-
|
|
33
|
-
<span class="radio-contenu" v-html="choixReponse.value" />
|
|
34
|
-
<span
|
|
35
|
-
:id="`${inputDataId}_${choixReponse.id}-msg-erreur`"
|
|
36
|
-
:key="`msg_chx_${inputDataId}_${choixReponse.id}`"
|
|
37
|
-
class="sr-only"
|
|
38
|
-
>
|
|
39
|
-
{{ messageAccessibility(choixReponse.id) }}
|
|
40
|
-
</span>
|
|
41
|
-
</label>
|
|
42
|
-
</div>
|
|
43
|
-
</template>
|
|
44
|
-
</fieldset>
|
|
45
|
-
</div>
|
|
46
|
-
</template>
|
|
47
|
-
<script>
|
|
48
|
-
import $extendsQuiz from '../mixins/$quizMixins'
|
|
49
|
-
export default {
|
|
50
|
-
name: 'AppCompInputRadio',
|
|
51
|
-
mixins: [$extendsQuiz],
|
|
52
|
-
|
|
53
|
-
props: {
|
|
54
|
-
inputType: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: ''
|
|
57
|
-
},
|
|
58
|
-
inputDataId: {
|
|
59
|
-
type: String,
|
|
60
|
-
default: ''
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
inputData: {
|
|
64
|
-
type: Array,
|
|
65
|
-
default: () => []
|
|
66
|
-
},
|
|
67
|
-
quizCompleted: {
|
|
68
|
-
type: Boolean,
|
|
69
|
-
default: false
|
|
70
|
-
},
|
|
71
|
-
solution: {
|
|
72
|
-
type: String,
|
|
73
|
-
default: ''
|
|
74
|
-
}, //may be null
|
|
75
|
-
showSolution: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: false
|
|
78
|
-
},
|
|
79
|
-
shuffleAnswers: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: false
|
|
82
|
-
},
|
|
83
|
-
quizInputUnique: {
|
|
84
|
-
type: String,
|
|
85
|
-
default: ''
|
|
86
|
-
}, //use to pass the value of the input
|
|
87
|
-
quizSubmit: {
|
|
88
|
-
type: Boolean,
|
|
89
|
-
default: false
|
|
90
|
-
}, //use to call a submit
|
|
91
|
-
aBy: {
|
|
92
|
-
type: String,
|
|
93
|
-
default: ''
|
|
94
|
-
} // use to pass id of the related question for the choices
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
data() {
|
|
98
|
-
return {
|
|
99
|
-
inputDataValue: [],
|
|
100
|
-
quizInputUniqueValue: null //not using quizInputUnique because quizInputUnique is a prop
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
computed: {},
|
|
105
|
-
|
|
106
|
-
watch: {
|
|
107
|
-
/**
|
|
108
|
-
* @description to pass value to AppCompQuiz
|
|
109
|
-
* @fires input-change to AppCompQuiz.vue
|
|
110
|
-
*/
|
|
111
|
-
quizInputUniqueValue(newValue) {
|
|
112
|
-
this.$emit('input-change', newValue)
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* @description to pass the value from AppCompQuiz
|
|
117
|
-
*/
|
|
118
|
-
quizInputUnique(newValue) {
|
|
119
|
-
this.quizInputUniqueValue = newValue
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
mounted() {
|
|
124
|
-
this.quizInputUniqueValue = this.quizInputUnique
|
|
125
|
-
if (this.shuffleAnswers) {
|
|
126
|
-
this.inputDataValue = this.shuffleArray(this.inputData)
|
|
127
|
-
} else {
|
|
128
|
-
this.inputDataValue = this.inputData
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
methods: {
|
|
133
|
-
/**
|
|
134
|
-
* @description shuffles an array used to randomized the option order if shuffleAnswers is true
|
|
135
|
-
* @param {Array} array
|
|
136
|
-
* @returns {Array}
|
|
137
|
-
*/
|
|
138
|
-
shuffleArray(array) {
|
|
139
|
-
let newArray = []
|
|
140
|
-
let newArray2 = []
|
|
141
|
-
|
|
142
|
-
for (let i = 0; i < array.length; i++) {
|
|
143
|
-
const element = array[i]
|
|
144
|
-
//todo remove null values
|
|
145
|
-
newArray.push(element)
|
|
146
|
-
}
|
|
147
|
-
while (newArray.length > 0) {
|
|
148
|
-
let pos = Math.floor(newArray.length * Math.random())
|
|
149
|
-
newArray2.push(newArray[pos])
|
|
150
|
-
newArray.splice(pos, 1)
|
|
151
|
-
}
|
|
152
|
-
return newArray2
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @description - Method to get the question
|
|
157
|
-
*/
|
|
158
|
-
getQuizQuestion() {
|
|
159
|
-
const el = document.querySelector(`#${this.aBy}`)
|
|
160
|
-
if (!el || !el.innerHTML) return
|
|
161
|
-
const labelFor =
|
|
162
|
-
this.$i18n.locale === 'fr'
|
|
163
|
-
? 'Choix de reponse pour la'
|
|
164
|
-
: 'Answers available for the'
|
|
165
|
-
return `${labelFor} ${el.innerText}`
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
</script>
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<div v-for="textInput in inputDataValue" :key="textInput.id">
|
|
4
|
-
<label
|
|
5
|
-
:for="`${inputDataId}_${textInput.id}-champ`"
|
|
6
|
-
v-html="textInput.ennonce"
|
|
7
|
-
></label>
|
|
8
|
-
<b-form-input
|
|
9
|
-
:id="`${inputDataId}_${textInput.id}-champ`"
|
|
10
|
-
v-model="quizTextTableValue[textInput.id]"
|
|
11
|
-
:class="classInput(textInput.id)"
|
|
12
|
-
:placeholder="$t('text.place_holder.for_textarea')"
|
|
13
|
-
:disabled="quizCompleted"
|
|
14
|
-
rows="1"
|
|
15
|
-
no-resize
|
|
16
|
-
:aria-describedby="`${inputDataId}_${textInput.id}-msg-erreur`"
|
|
17
|
-
></b-form-input>
|
|
18
|
-
<span :id="`${inputDataId}_${textInput.id}-msg-erreur`" class="sr-only">
|
|
19
|
-
{{ messageAccessibility(textInput.id) }}
|
|
20
|
-
</span>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
<script>
|
|
25
|
-
import $extendsQuiz from '../mixins/$quizMixins'
|
|
26
|
-
export default {
|
|
27
|
-
name: 'AppCompInputTextTable',
|
|
28
|
-
mixins: [$extendsQuiz],
|
|
29
|
-
|
|
30
|
-
props: {
|
|
31
|
-
inputType: {
|
|
32
|
-
type: String,
|
|
33
|
-
default: ''
|
|
34
|
-
},
|
|
35
|
-
inputDataId: {
|
|
36
|
-
type: String,
|
|
37
|
-
default: ''
|
|
38
|
-
},
|
|
39
|
-
inputData: {
|
|
40
|
-
type: Array,
|
|
41
|
-
default: () => []
|
|
42
|
-
},
|
|
43
|
-
quizCompleted: {
|
|
44
|
-
type: Boolean,
|
|
45
|
-
default: false
|
|
46
|
-
},
|
|
47
|
-
solution: {
|
|
48
|
-
type: Array,
|
|
49
|
-
default: () => []
|
|
50
|
-
},
|
|
51
|
-
showSolution: {
|
|
52
|
-
type: Boolean,
|
|
53
|
-
default: false
|
|
54
|
-
},
|
|
55
|
-
shuffleAnswers: {
|
|
56
|
-
type: Boolean,
|
|
57
|
-
default: false
|
|
58
|
-
},
|
|
59
|
-
quizTextTable: {
|
|
60
|
-
type: Array,
|
|
61
|
-
default: () => []
|
|
62
|
-
}, //use to pass the value of the input
|
|
63
|
-
quizSubmit: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false
|
|
66
|
-
} //use to call a submit
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
data() {
|
|
70
|
-
return {
|
|
71
|
-
inputDataValue: [],
|
|
72
|
-
quizTextTableValue: [] //not using quizTextTable because quizTextTable is a prop
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
computed: {},
|
|
77
|
-
|
|
78
|
-
watch: {
|
|
79
|
-
/**
|
|
80
|
-
* @description to pass value to AppCompQuiz
|
|
81
|
-
* @fires input-change to AppCompQuiz.vue
|
|
82
|
-
*/
|
|
83
|
-
quizTextTableValue(newValue) {
|
|
84
|
-
this.$emit('input-change', newValue)
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @description to pass the value from AppCompQuiz
|
|
89
|
-
*/
|
|
90
|
-
quizTextTable(newValue) {
|
|
91
|
-
this.quizTextTableValue = newValue
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
|
|
95
|
-
mounted() {
|
|
96
|
-
if (this.solution !== null) {
|
|
97
|
-
this.solution.sort(function(a, b) {
|
|
98
|
-
return a.question_id - b.question_id
|
|
99
|
-
})
|
|
100
|
-
}
|
|
101
|
-
let textChoices = []
|
|
102
|
-
|
|
103
|
-
for (let i = 0; i < this.inputData.length; i++) {
|
|
104
|
-
textChoices.push('')
|
|
105
|
-
}
|
|
106
|
-
//apply previous answers
|
|
107
|
-
if (this.quizTextTable && this.quizTextTable.length == 0) {
|
|
108
|
-
this.quizTextTableValue = textChoices
|
|
109
|
-
} else {
|
|
110
|
-
this.quizTextTableValue = this.quizTextTable
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (this.shuffleAnswers) {
|
|
114
|
-
this.inputDataValue = this.shuffleArray(this.inputData)
|
|
115
|
-
} else {
|
|
116
|
-
this.inputDataValue = this.inputData
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
methods: {
|
|
121
|
-
/**
|
|
122
|
-
* @description check if a values exists in a array
|
|
123
|
-
* @param {Array} array
|
|
124
|
-
* @param value
|
|
125
|
-
* @returns {Boolean}
|
|
126
|
-
*/
|
|
127
|
-
containsValue(array, value) {
|
|
128
|
-
return array.includes(value)
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @description shuffles an array used to randomized the option order if shuffleAnswers is true
|
|
133
|
-
* @param {Array} array
|
|
134
|
-
* @returns {Array}
|
|
135
|
-
*/
|
|
136
|
-
shuffleArray(array) {
|
|
137
|
-
let newArray = []
|
|
138
|
-
let newArray2 = []
|
|
139
|
-
|
|
140
|
-
for (let i = 0; i < array.length; i++) {
|
|
141
|
-
const element = array[i]
|
|
142
|
-
//todo remove null values
|
|
143
|
-
newArray.push(element)
|
|
144
|
-
}
|
|
145
|
-
while (newArray.length > 0) {
|
|
146
|
-
let pos = Math.floor(newArray.length * Math.random())
|
|
147
|
-
newArray2.push(newArray[pos])
|
|
148
|
-
newArray.splice(pos, 1)
|
|
149
|
-
}
|
|
150
|
-
return newArray2
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
</script>
|
|
155
|
-
<style lang="scss" scoped></style>
|