@pocketprep/ui-kit 3.4.51 → 3.4.53
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/dist/@pocketprep/ui-kit.js +12257 -11132
- package/dist/@pocketprep/ui-kit.js.map +1 -1
- package/dist/@pocketprep/ui-kit.umd.cjs +10 -10
- package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/lib/components/Forms/Checkbox.vue +9 -1
- package/lib/components/Forms/Radio.vue +11 -11
- package/lib/components/Forms/RadioButton.vue +140 -0
- package/lib/components/Quiz/Question/MatrixChoicesContainer.vue +614 -0
- package/lib/components/Quiz/Question/MatrixRadioGroup.vue +98 -0
- package/lib/components/Quiz/Question/MobileMatrixChoicesContainer.vue +710 -0
- package/lib/components/Quiz/Question/MobileMatrixRadioGroup.vue +131 -0
- package/lib/components/Quiz/Question/StatsSummary.vue +11 -3
- package/lib/components/Quiz/Question/Summary.vue +9 -2
- package/lib/components/Quiz/Question.vue +325 -14
- package/lib/components/Quiz/QuizContainer.vue +15 -1
- package/lib/components/Quiz/question.d.ts +12 -0
- package/package.json +2 -2
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-dark="isDarkMode"
|
|
4
|
+
class="uikit-question-mobile-matrix-choices-container"
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
class="uikit-question-mobile-matrix-choices-container__choices-container"
|
|
8
|
+
:class="{
|
|
9
|
+
'uikit-question-mobile-matrix-choices-container__choices-container--correct':
|
|
10
|
+
(showMatrixAnswers || reviewMode) && isMatrixQuestionCorrect,
|
|
11
|
+
'uikit-question-mobile-matrix-choices-container__choices-container--incorrect':
|
|
12
|
+
(showMatrixAnswers || reviewMode) && !isMatrixQuestionCorrect,
|
|
13
|
+
|
|
14
|
+
}"
|
|
15
|
+
v-dark="isDarkMode"
|
|
16
|
+
v-breakpoint:questionEl="breakpoints"
|
|
17
|
+
>
|
|
18
|
+
<div
|
|
19
|
+
class="uikit-question-mobile-matrix-choices-container__row-container"
|
|
20
|
+
v-for="(rowLabel, rowIndex) in matrixRowLabels"
|
|
21
|
+
:key="rowIndex"
|
|
22
|
+
v-dark="isDarkMode"
|
|
23
|
+
v-breakpoint:questionEl="breakpoints"
|
|
24
|
+
>
|
|
25
|
+
<div
|
|
26
|
+
class="uikit-question-mobile-matrix-choices-container__row"
|
|
27
|
+
:class="{
|
|
28
|
+
'uikit-question-mobile-matrix-choices-container__row--expanded':
|
|
29
|
+
expandedRowNumbers.includes(rowIndex),
|
|
30
|
+
}"
|
|
31
|
+
v-dark="isDarkMode"
|
|
32
|
+
v-breakpoint:questionEl="breakpoints"
|
|
33
|
+
@click.stop="toggleChoiceDropdown(rowIndex)"
|
|
34
|
+
>
|
|
35
|
+
<Icon
|
|
36
|
+
v-if="(showMatrixAnswers || reviewMode) && correctRow(rowIndex)"
|
|
37
|
+
class="uikit-question-mobile-matrix-choices-container__row-label-correct-icon"
|
|
38
|
+
type="check"
|
|
39
|
+
/>
|
|
40
|
+
<Icon
|
|
41
|
+
v-if="(showMatrixAnswers || reviewMode) && !correctRow(rowIndex)"
|
|
42
|
+
class="uikit-question-mobile-matrix-choices-container__row-label-incorrect-icon"
|
|
43
|
+
type="incorrect"
|
|
44
|
+
/>
|
|
45
|
+
<div
|
|
46
|
+
class="uikit-question-mobile-matrix-choices-container__row-label"
|
|
47
|
+
v-dark="isDarkMode"
|
|
48
|
+
>
|
|
49
|
+
{{ stripText(rowLabel) }}
|
|
50
|
+
<Icon
|
|
51
|
+
class="uikit-question-mobile-matrix-choices-container__toggle-row-icon"
|
|
52
|
+
:class="{
|
|
53
|
+
'uikit-question-mobile-matrix-choices-container__toggle-row-icon--up':
|
|
54
|
+
expandedRowNumbers.includes(rowIndex),
|
|
55
|
+
}"
|
|
56
|
+
v-dark="isDarkMode"
|
|
57
|
+
type="accordionArrow"
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
<div
|
|
61
|
+
class="uikit-question-mobile-matrix-choices-container__selected-choice-labels-container"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
|
|
65
|
+
v-dark="isDarkMode"
|
|
66
|
+
v-for="(colHeader, colHeaderIndex) in selectedColumnHeaders"
|
|
67
|
+
:key="colHeaderIndex"
|
|
68
|
+
>
|
|
69
|
+
<template v-if="
|
|
70
|
+
selectedColumnHeaders &&
|
|
71
|
+
selectedColumnHeaders[rowIndex] &&
|
|
72
|
+
selectedColumnHeaders[rowIndex][colHeaderIndex]">
|
|
73
|
+
<div
|
|
74
|
+
class="uikit-question-mobile-matrix-choices-container__selected-choice-labels"
|
|
75
|
+
v-dark="isDarkMode"
|
|
76
|
+
v-breakpoint:questionEl="breakpoints"
|
|
77
|
+
>
|
|
78
|
+
{{ selectedColumnHeaders[rowIndex][colHeaderIndex] ===
|
|
79
|
+
selectedColumnHeaders[rowIndex][selectedColumnHeaders[rowIndex].length - 1] ?
|
|
80
|
+
stripText(selectedColumnHeaders[rowIndex][colHeaderIndex]) :
|
|
81
|
+
`${stripText(selectedColumnHeaders[rowIndex][colHeaderIndex])},`
|
|
82
|
+
}}
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
</template>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
<div
|
|
90
|
+
v-if="
|
|
91
|
+
expandedRowNumbers.includes(rowIndex) &&
|
|
92
|
+
question.type === 'Matrix Checkbox' &&
|
|
93
|
+
matrixCheckboxGrid &&
|
|
94
|
+
matrixCheckboxGrid[rowIndex]"
|
|
95
|
+
>
|
|
96
|
+
<div
|
|
97
|
+
class="uikit-question-mobile-matrix-choices-container__choice"
|
|
98
|
+
v-dark="isDarkMode"
|
|
99
|
+
v-for="(column, columnIndex) in matrixColumnLabels"
|
|
100
|
+
:key="columnIndex"
|
|
101
|
+
>
|
|
102
|
+
<Checkbox
|
|
103
|
+
v-if="(showMatrixAnswers || reviewMode) &&
|
|
104
|
+
correctAnswerButNotSelected(rowIndex, columnIndex)"
|
|
105
|
+
:model-value="true"
|
|
106
|
+
:is-dark-mode="isDarkMode"
|
|
107
|
+
:disabled="showMatrixAnswers || reviewMode"
|
|
108
|
+
:checkbox-check-styles="checkboxCheckStyling(rowIndex, columnIndex)"
|
|
109
|
+
/>
|
|
110
|
+
<Checkbox
|
|
111
|
+
v-else
|
|
112
|
+
v-model="matrixCheckboxGrid[rowIndex][columnIndex]"
|
|
113
|
+
:is-dark-mode="isDarkMode"
|
|
114
|
+
:disabled="showMatrixAnswers || reviewMode"
|
|
115
|
+
:checkbox-styles="checkboxContainerStyling(rowIndex, columnIndex)"
|
|
116
|
+
/>
|
|
117
|
+
<div
|
|
118
|
+
class="uikit-question-mobile-matrix-choices-container__checkbox-label"
|
|
119
|
+
:class="{
|
|
120
|
+
'uikit-question-mobile-matrix-choices-container__checkbox-label--distractor':
|
|
121
|
+
(showMatrixAnswers || reviewMode) &&
|
|
122
|
+
matrixChoiceLayout[rowIndex] &&
|
|
123
|
+
matrixChoiceLayout[rowIndex][columnIndex]?.startsWith('d'),
|
|
124
|
+
}"
|
|
125
|
+
>
|
|
126
|
+
{{ stripText(column) }}
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
<div
|
|
131
|
+
v-if="expandedRowNumbers.includes(rowIndex) &&
|
|
132
|
+
question.type === 'Matrix Radio Button' &&
|
|
133
|
+
matrixRadioGrid && matrixRadioGrid[rowIndex]"
|
|
134
|
+
>
|
|
135
|
+
<MobileMatrixRadioGroup
|
|
136
|
+
:modelValue="getRadioRowSelection(rowIndex)"
|
|
137
|
+
:review-mode="reviewMode"
|
|
138
|
+
:show-answers="showMatrixAnswers"
|
|
139
|
+
class="uikit-question-mobile-matrix-choices-container__radio-btns"
|
|
140
|
+
:choices="getRadioRowChoices(rowIndex)"
|
|
141
|
+
:labels="matrixColumnLabels"
|
|
142
|
+
:matrix-answer-keys="matrixAnswerKeys"
|
|
143
|
+
:is-dark-mode="isDarkMode"
|
|
144
|
+
:question-el="questionEl"
|
|
145
|
+
:breakpoints="breakpoints"
|
|
146
|
+
:disabled="false"
|
|
147
|
+
@update:modelValue="updateRadioRowSelection(rowIndex, $event)"
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</div>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
|
|
155
|
+
<script lang="ts">
|
|
156
|
+
import { Component, Vue, Prop, Emit, Watch } from 'vue-facing-decorator'
|
|
157
|
+
import Icon from '../../Icons/Icon.vue'
|
|
158
|
+
import PocketButton from '../../Buttons/Button.vue'
|
|
159
|
+
import Checkbox from '../../Forms/Checkbox.vue'
|
|
160
|
+
import MobileMatrixRadioGroup from './MobileMatrixRadioGroup.vue'
|
|
161
|
+
import { dark, breakpoint } from '../../../directives'
|
|
162
|
+
import type { TBreakPointsObject, IRadioOptions, TMatrixChoiceKey } from './../question'
|
|
163
|
+
import type { Study } from '@pocketprep/types'
|
|
164
|
+
import BrandColors from '../../../pocketprep-export.module.scss'
|
|
165
|
+
|
|
166
|
+
@Component({
|
|
167
|
+
components: {
|
|
168
|
+
Icon,
|
|
169
|
+
Checkbox,
|
|
170
|
+
PocketButton,
|
|
171
|
+
MobileMatrixRadioGroup,
|
|
172
|
+
},
|
|
173
|
+
directives: {
|
|
174
|
+
dark,
|
|
175
|
+
breakpoint,
|
|
176
|
+
},
|
|
177
|
+
})
|
|
178
|
+
export default class MobileMatrixChoicesContainer extends Vue {
|
|
179
|
+
@Prop({ default: false }) reviewMode!: boolean
|
|
180
|
+
@Prop({ default: false }) isDarkMode!: boolean
|
|
181
|
+
@Prop({ default: null }) questionEl!: Element | null
|
|
182
|
+
@Prop({ default: {
|
|
183
|
+
'mobile': 767,
|
|
184
|
+
'tablet-portrait': 1023,
|
|
185
|
+
'tablet-landscape': 1439,
|
|
186
|
+
} }) breakpoints!: TBreakPointsObject
|
|
187
|
+
@Prop() question!: Study.Class.QuestionJSON
|
|
188
|
+
@Prop() matrixChoiceLayout!: string[][]
|
|
189
|
+
@Prop({ default: false }) showMatrixAnswers!: boolean
|
|
190
|
+
@Prop({ default: false }) isUnanswered!: boolean
|
|
191
|
+
@Prop({ default: false }) isMatrixQuestionCorrect!: boolean
|
|
192
|
+
@Prop() matrixAnswerKeys!: TMatrixChoiceKey[]
|
|
193
|
+
@Prop() matrixDistractorKeys!: TMatrixChoiceKey[]
|
|
194
|
+
@Prop() selectedMatrixChoices!: TMatrixChoiceKey[]
|
|
195
|
+
@Prop() matrixChoices!: TMatrixChoiceKey[]
|
|
196
|
+
|
|
197
|
+
matrixCheckboxGrid: boolean[][] | undefined = undefined
|
|
198
|
+
matrixRadioGrid: IRadioOptions[] | undefined = undefined
|
|
199
|
+
expandedRowNumbers: number[] = []
|
|
200
|
+
selectedColumnHeaders: string[][] = []
|
|
201
|
+
brandColors = BrandColors
|
|
202
|
+
|
|
203
|
+
stripText (string?: string) {
|
|
204
|
+
return string?.replace(/<[^\s>]+[^>]*>/gi, ' ').trim()
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get defaultCheckboxGrid () {
|
|
208
|
+
return this.matrixChoiceLayout?.map(row => {
|
|
209
|
+
const choiceRow = row.map(() => false)
|
|
210
|
+
return choiceRow
|
|
211
|
+
})
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
get defaultRadioButtonGrid () {
|
|
215
|
+
return this.matrixChoiceLayout?.map(row => {
|
|
216
|
+
return {
|
|
217
|
+
choices: row as TMatrixChoiceKey[],
|
|
218
|
+
value: null,
|
|
219
|
+
}
|
|
220
|
+
})
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
get matrixRowLabels () {
|
|
224
|
+
return this.question.matrixLabels?.rows
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
get matrixColumnLabels () {
|
|
228
|
+
return this.question.matrixLabels?.columns
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
mounted () {
|
|
232
|
+
if (this.question.type === 'Matrix Checkbox') {
|
|
233
|
+
this.matrixCheckboxGrid = this.defaultCheckboxGrid
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this.question.type === 'Matrix Radio Button') {
|
|
237
|
+
this.matrixRadioGrid = this.defaultRadioButtonGrid
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
this.question.matrixChoiceLayout?.forEach(() => {
|
|
241
|
+
this.selectedColumnHeaders.push([])
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
toggleChoiceDropdown (rowIndex: number) {
|
|
246
|
+
const includedRowNumberIndex = this.expandedRowNumbers.findIndex(row => row === rowIndex)
|
|
247
|
+
if (includedRowNumberIndex === -1) {
|
|
248
|
+
this.expandedRowNumbers.push(rowIndex)
|
|
249
|
+
} else {
|
|
250
|
+
this.expandedRowNumbers.splice(includedRowNumberIndex, 1)
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
selectedChoiceKey (rowIndex: number, colIndex: number) {
|
|
255
|
+
const row = rowIndex += 1
|
|
256
|
+
const column = colIndex += 1
|
|
257
|
+
if (this.selectedMatrixChoices.length && this.matrixAnswerKeys.length) {
|
|
258
|
+
const matrixSelectedChoiceKey = this.selectedMatrixChoices.find((choice) => {
|
|
259
|
+
const substring = choice.substring(1)
|
|
260
|
+
return substring === `${row}_${column}`
|
|
261
|
+
})
|
|
262
|
+
|
|
263
|
+
return matrixSelectedChoiceKey
|
|
264
|
+
}
|
|
265
|
+
return undefined
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
getRadioRowSelection (rowIndex: number) {
|
|
269
|
+
return this.matrixRadioGrid?.[rowIndex]?.value
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
getRadioRowChoices (rowIndex: number) {
|
|
273
|
+
const choices = this.matrixRadioGrid?.[rowIndex]?.choices
|
|
274
|
+
return choices
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
updateRadioRowSelection (rowIndex: number, choiceKey: TMatrixChoiceKey) {
|
|
278
|
+
const row = this.matrixRadioGrid?.[rowIndex]
|
|
279
|
+
if (row) {
|
|
280
|
+
row.value = choiceKey
|
|
281
|
+
|
|
282
|
+
// update row header label
|
|
283
|
+
const choiceKeyIndex = row.choices.findIndex(choice => choice === choiceKey)
|
|
284
|
+
const rowHeader = this.question.matrixLabels?.columns[choiceKeyIndex]
|
|
285
|
+
if (rowHeader) {
|
|
286
|
+
this.selectedColumnHeaders[rowIndex]?.pop()
|
|
287
|
+
this.selectedColumnHeaders[rowIndex]?.push(rowHeader)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
correctlySelectedChoice (rowIndex: number, colIndex: number) {
|
|
293
|
+
if (this.selectedMatrixChoices && this.matrixAnswerKeys) {
|
|
294
|
+
const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
|
|
295
|
+
if (selectedChoice && selectedChoice.startsWith('a') && this.matrixAnswerKeys.includes(selectedChoice)) {
|
|
296
|
+
return true
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return false
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
incorrectlySelectedChoice (rowIndex: number, colIndex: number) {
|
|
303
|
+
if (this.selectedMatrixChoices && this.matrixAnswerKeys) {
|
|
304
|
+
const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
|
|
305
|
+
if (selectedChoice && selectedChoice.startsWith('d')) {
|
|
306
|
+
return true
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return false
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
correctAnswerButNotSelected (rowIndex: number, colIndex: number) {
|
|
313
|
+
const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
|
|
314
|
+
const answerKey = this.matrixAnswerKeys.find(choice => choice === `a${rowIndex + 1}_${colIndex + 1}`)
|
|
315
|
+
return answerKey && !selectedChoice
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
checkboxContainerStyling (rowIndex: number, columnIndex: number) {
|
|
319
|
+
const isReviewMode = this.showMatrixAnswers || this.reviewMode
|
|
320
|
+
const incorrectlySelectedChoice = this.incorrectlySelectedChoice(rowIndex, columnIndex)
|
|
321
|
+
|
|
322
|
+
// check box is correctlySelected
|
|
323
|
+
if (isReviewMode && this.correctlySelectedChoice(rowIndex, columnIndex)) {
|
|
324
|
+
const borderColor = this.isDarkMode ? this.brandColors.jungleGreen : this.brandColors.cadaverous
|
|
325
|
+
return {
|
|
326
|
+
borderColor: `${borderColor} !important`,
|
|
327
|
+
background: `${borderColor} !important`,
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (isReviewMode && incorrectlySelectedChoice) {
|
|
332
|
+
return {
|
|
333
|
+
background: `${this.brandColors.steel} !important`,
|
|
334
|
+
border: `1px solid ${this.brandColors.steel} !important`,
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
checkboxCheckStyling (rowIndex: number, columnIndex: number) {
|
|
340
|
+
const isReviewMode = this.showMatrixAnswers || this.reviewMode
|
|
341
|
+
if (isReviewMode && this.correctAnswerButNotSelected(rowIndex, columnIndex)) {
|
|
342
|
+
const color = this.isDarkMode ? this.brandColors.jungleGreen : this.brandColors.cadaverous
|
|
343
|
+
return {
|
|
344
|
+
color: `${color} !important`,
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
correctRow (rowIndex: number) {
|
|
350
|
+
if (this.question?.matrixChoiceLayout && this.question?.matrixChoiceLayout[rowIndex]) {
|
|
351
|
+
if (
|
|
352
|
+
this.question?.type === 'Matrix Checkbox' &&
|
|
353
|
+
this.matrixCheckboxGrid &&
|
|
354
|
+
this.matrixCheckboxGrid[rowIndex]
|
|
355
|
+
) {
|
|
356
|
+
const correctAnswerKeys = this.question?.matrixChoiceLayout[rowIndex].filter(choice =>
|
|
357
|
+
choice.startsWith('a')
|
|
358
|
+
)
|
|
359
|
+
const selectedAnswerKeys = this.matrixCheckboxGrid[rowIndex].map((choice, choiceIndex) => {
|
|
360
|
+
return this.selectedChoiceKey(rowIndex, choiceIndex)
|
|
361
|
+
})
|
|
362
|
+
const correctSelectedKeys = this.matrixCheckboxGrid[rowIndex].filter((choice, choiceIndex) => {
|
|
363
|
+
const selectedChoice = this.selectedChoiceKey(rowIndex, choiceIndex)
|
|
364
|
+
return selectedChoice?.startsWith('a')
|
|
365
|
+
})
|
|
366
|
+
return !selectedAnswerKeys.some(choice => choice?.startsWith('d')) &&
|
|
367
|
+
(correctAnswerKeys.length === correctSelectedKeys.length)
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (
|
|
371
|
+
this.question?.type === 'Matrix Radio Button' &&
|
|
372
|
+
this.matrixRadioGrid &&
|
|
373
|
+
this.matrixRadioGrid[rowIndex]
|
|
374
|
+
) {
|
|
375
|
+
if (this.matrixRadioGrid[rowIndex] && this.matrixRadioGrid[rowIndex].value) {
|
|
376
|
+
return this.matrixRadioGrid[rowIndex].value.startsWith('a')
|
|
377
|
+
}
|
|
378
|
+
return false
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return false
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
convertSelectedMatrixChoiceToCheckboxGrid () {
|
|
385
|
+
const checkboxGrid = this.defaultCheckboxGrid
|
|
386
|
+
this.selectedMatrixChoices.forEach(choice => {
|
|
387
|
+
const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
|
|
388
|
+
const colIndex = Number(choice.split('_').pop()) - 1
|
|
389
|
+
if (checkboxGrid && checkboxGrid[rowIndex]) {
|
|
390
|
+
checkboxGrid[rowIndex][colIndex] = true
|
|
391
|
+
if (this.selectedColumnHeaders[rowIndex] && this.question.matrixLabels?.columns[colIndex]) {
|
|
392
|
+
const columnHeader = this.question.matrixLabels?.columns[colIndex]
|
|
393
|
+
this.selectedColumnHeaders[rowIndex].push(columnHeader)
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
})
|
|
397
|
+
return checkboxGrid
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
convertSelectedMatrixChoiceToRadioBtnGrid () {
|
|
401
|
+
const radioBtnGrid = this.matrixRadioGrid
|
|
402
|
+
this.selectedMatrixChoices.forEach(choice => {
|
|
403
|
+
const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
|
|
404
|
+
const colIndex = Number(choice.split('_').pop()) - 1
|
|
405
|
+
if (this.selectedColumnHeaders[rowIndex] && this.question.matrixLabels?.columns[colIndex]) {
|
|
406
|
+
const columnHeader = this.question.matrixLabels?.columns[colIndex]
|
|
407
|
+
this.selectedColumnHeaders[rowIndex].push(columnHeader)
|
|
408
|
+
}
|
|
409
|
+
if (radioBtnGrid && radioBtnGrid[rowIndex]) {
|
|
410
|
+
radioBtnGrid[rowIndex].value = choice
|
|
411
|
+
}
|
|
412
|
+
})
|
|
413
|
+
return radioBtnGrid
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
@Emit('emitSelectedMatrixChoice')
|
|
417
|
+
emitSelectedMatrixChoice (matrixChoiceKeys: TMatrixChoiceKey[]) {
|
|
418
|
+
return matrixChoiceKeys
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@Emit('emitAnsweredMatrixRowIndex')
|
|
422
|
+
emitAnsweredMatrixRowIndex (answeredRowIndexes: number[]) {
|
|
423
|
+
return answeredRowIndexes
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
@Watch('matrixCheckboxGrid', { deep: true })
|
|
427
|
+
matrixCheckboxGridChange () {
|
|
428
|
+
if (this.matrixChoiceLayout && this.matrixCheckboxGrid && (!this.reviewMode || !this.showMatrixAnswers)) {
|
|
429
|
+
const selectedCheckboxChoices: TMatrixChoiceKey[] = []
|
|
430
|
+
const answeredCheckBoxRowIndexes: number[] = []
|
|
431
|
+
|
|
432
|
+
this.matrixCheckboxGrid.forEach((row, rowIndex) => {
|
|
433
|
+
row.forEach((choice, choiceIndex) => {
|
|
434
|
+
if (
|
|
435
|
+
choice &&
|
|
436
|
+
this.matrixChoiceLayout[rowIndex] &&
|
|
437
|
+
this.matrixChoiceLayout[rowIndex][choiceIndex]
|
|
438
|
+
) {
|
|
439
|
+
const choiceKey = this.matrixChoiceLayout[rowIndex][choiceIndex] as TMatrixChoiceKey
|
|
440
|
+
selectedCheckboxChoices.push(choiceKey)
|
|
441
|
+
if (!answeredCheckBoxRowIndexes.some(index => index === rowIndex)) {
|
|
442
|
+
answeredCheckBoxRowIndexes.push(rowIndex)
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
})
|
|
446
|
+
})
|
|
447
|
+
|
|
448
|
+
this.emitSelectedMatrixChoice(selectedCheckboxChoices)
|
|
449
|
+
this.emitAnsweredMatrixRowIndex(answeredCheckBoxRowIndexes)
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
@Watch('matrixCheckboxGrid', { deep: true })
|
|
454
|
+
addRemoveCheckboxColumnHeaders () {
|
|
455
|
+
if (this.matrixCheckboxGrid) {
|
|
456
|
+
const selectedCheckboxColumnLabels: string[][] = []
|
|
457
|
+
this.matrixCheckboxGrid.forEach((row, rowIndex) => {
|
|
458
|
+
selectedCheckboxColumnLabels.push([])
|
|
459
|
+
row.forEach((choice, choiceIndex) => {
|
|
460
|
+
if (
|
|
461
|
+
choice
|
|
462
|
+
&& this.question.matrixLabels?.columns
|
|
463
|
+
&& this.question.matrixLabels?.columns[choiceIndex]
|
|
464
|
+
) {
|
|
465
|
+
const columnLabel = this.question.matrixLabels?.columns[choiceIndex]
|
|
466
|
+
if (selectedCheckboxColumnLabels[rowIndex]) {
|
|
467
|
+
selectedCheckboxColumnLabels[rowIndex].push(columnLabel)
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
})
|
|
471
|
+
this.selectedColumnHeaders = selectedCheckboxColumnLabels
|
|
472
|
+
})
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
@Watch('matrixRadioGrid', { deep: true })
|
|
477
|
+
matrixRadioGridChange () {
|
|
478
|
+
if (this.matrixChoiceLayout && this.matrixRadioGrid && (!this.reviewMode || !this.showMatrixAnswers)) {
|
|
479
|
+
const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
|
|
480
|
+
const answeredRadioBtnRowIndexes: number[] = []
|
|
481
|
+
|
|
482
|
+
this.matrixRadioGrid.forEach((row, index) => {
|
|
483
|
+
if (row.value) {
|
|
484
|
+
selectedRadioButtonChoices.push(row.value)
|
|
485
|
+
if (!answeredRadioBtnRowIndexes.some(rowIndex => rowIndex === index)) {
|
|
486
|
+
answeredRadioBtnRowIndexes.push(index)
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
})
|
|
490
|
+
|
|
491
|
+
this.emitSelectedMatrixChoice(selectedRadioButtonChoices)
|
|
492
|
+
this.emitAnsweredMatrixRowIndex(answeredRadioBtnRowIndexes)
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
@Watch('showMatrixAnswers')
|
|
497
|
+
closeRows () {
|
|
498
|
+
if (this.showMatrixAnswers) {
|
|
499
|
+
this.expandedRowNumbers = []
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@Watch('selectedMatrixChoices')
|
|
504
|
+
selectedMatrixChoicesChange () {
|
|
505
|
+
if ((this.reviewMode || this.showMatrixAnswers) && this.question.type === 'Matrix Checkbox') {
|
|
506
|
+
const selectedCheckboxGrid = this.convertSelectedMatrixChoiceToCheckboxGrid()
|
|
507
|
+
this.matrixCheckboxGrid = selectedCheckboxGrid ? selectedCheckboxGrid : this.defaultCheckboxGrid
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
if ((this.reviewMode || this.showMatrixAnswers) && this.question.type === 'Matrix Radio Button') {
|
|
511
|
+
const selectedRadioBtnGrid = this.convertSelectedMatrixChoiceToRadioBtnGrid()
|
|
512
|
+
this.matrixRadioGrid = selectedRadioBtnGrid
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
</script>
|
|
518
|
+
|
|
519
|
+
<style lang="scss">
|
|
520
|
+
@import '../../../styles/colors';
|
|
521
|
+
@import '../../../styles/breakpoints';
|
|
522
|
+
|
|
523
|
+
.uikit-question-mobile-matrix-choices-container {
|
|
524
|
+
width: 100%;
|
|
525
|
+
max-width: 325px;
|
|
526
|
+
&:not(&--mobile) {
|
|
527
|
+
display: none
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
&__choices-container {
|
|
531
|
+
cursor: default;
|
|
532
|
+
position: relative;
|
|
533
|
+
outline: none;
|
|
534
|
+
transition: 0.1s width ease;
|
|
535
|
+
|
|
536
|
+
&::after {
|
|
537
|
+
content: '';
|
|
538
|
+
position: absolute;
|
|
539
|
+
top: -8px;
|
|
540
|
+
bottom: -8px;
|
|
541
|
+
left: -8px;
|
|
542
|
+
right: -8px;
|
|
543
|
+
border-radius: 11px;
|
|
544
|
+
pointer-events: none;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
&--incorrect {
|
|
548
|
+
&::after {
|
|
549
|
+
display: block;
|
|
550
|
+
border: 2px solid $pepper;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
&--dark::after {
|
|
554
|
+
border-color: $rosa;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
&--correct {
|
|
559
|
+
&::after {
|
|
560
|
+
display: block;
|
|
561
|
+
border: 2px solid $cadaverous;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
&--dark::after {
|
|
565
|
+
border-color: $jungle-green;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
&__row-container {
|
|
572
|
+
margin-bottom: 9px;
|
|
573
|
+
box-shadow: 0px 1px 4px 0px rgba(71, 89, 103, 0.30);
|
|
574
|
+
border: 0.5px solid ($pewter, 0.85);
|
|
575
|
+
border-radius: 5px;
|
|
576
|
+
|
|
577
|
+
&--dark {
|
|
578
|
+
border: 0.5px solid rgba($pewter, 0.85);
|
|
579
|
+
border-radius: 5px;
|
|
580
|
+
background: $brand-black;
|
|
581
|
+
box-shadow: 0px 1px 4px 0px $jet;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
&__row {
|
|
586
|
+
cursor: pointer;
|
|
587
|
+
padding: 12px 36px 12px 15px;
|
|
588
|
+
align-items: center;
|
|
589
|
+
align-content: flex-start;
|
|
590
|
+
flex-wrap: wrap;
|
|
591
|
+
border-radius: 5px;
|
|
592
|
+
border: 0.5px solid rgba($pewter, 0.85);
|
|
593
|
+
background: $white;
|
|
594
|
+
|
|
595
|
+
&--dark {
|
|
596
|
+
background: $brand-black;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
&--expanded {
|
|
600
|
+
border-radius: 5px 5px 0px 0px;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
&__row-label-correct-icon,
|
|
605
|
+
&__row-label-incorrect-icon {
|
|
606
|
+
position: absolute;
|
|
607
|
+
right: 0;
|
|
608
|
+
margin-right: 12px;
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
&__row-label-correct-icon {
|
|
612
|
+
color: $cadaverous;
|
|
613
|
+
|
|
614
|
+
&--dark {
|
|
615
|
+
color: $jungle-green;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
&__row-label-incorrect-icon {
|
|
620
|
+
color: $pepper;
|
|
621
|
+
|
|
622
|
+
&--dark {
|
|
623
|
+
color: $rosa;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
&__row-label {
|
|
628
|
+
color: $brand-black;
|
|
629
|
+
font-size: 16px;
|
|
630
|
+
font-style: normal;
|
|
631
|
+
font-weight: 600;
|
|
632
|
+
line-height: 23px;
|
|
633
|
+
letter-spacing: -0.1px;
|
|
634
|
+
|
|
635
|
+
&--dark {
|
|
636
|
+
color: $barely-background;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
&__toggle-row-icon {
|
|
641
|
+
margin-left: 8px;
|
|
642
|
+
color: $brand-blue;
|
|
643
|
+
|
|
644
|
+
&--up {
|
|
645
|
+
transform: rotate(180deg);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
&--dark {
|
|
649
|
+
color: $banana-bread;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
&__selected-choice-labels-container {
|
|
654
|
+
display: flex;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
&__selected-choice-labels {
|
|
658
|
+
color: $ash;
|
|
659
|
+
font-size: 14px;
|
|
660
|
+
font-weight: 500;
|
|
661
|
+
height: 19px;
|
|
662
|
+
margin-right: 4px;
|
|
663
|
+
|
|
664
|
+
&--dark {
|
|
665
|
+
color: $fog;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
&__choice {
|
|
670
|
+
background: $white;
|
|
671
|
+
display: flex;
|
|
672
|
+
padding: 11px 15px 12px 15px;
|
|
673
|
+
align-items: flex-start;
|
|
674
|
+
gap: 12px;
|
|
675
|
+
align-self: stretch;
|
|
676
|
+
border: 0.5px solid rgba($pewter, 0.85);
|
|
677
|
+
border-top: none;
|
|
678
|
+
color: $brand-black;
|
|
679
|
+
font-size: 16px;
|
|
680
|
+
font-style: normal;
|
|
681
|
+
font-weight: 500;
|
|
682
|
+
line-height: 23px;
|
|
683
|
+
letter-spacing: -0.1px;
|
|
684
|
+
|
|
685
|
+
&:last-child {
|
|
686
|
+
border-radius: 0px 0px 5px 5px;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
&--dark {
|
|
690
|
+
background: $brand-black;
|
|
691
|
+
color: $barely-background;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.uikit-checkbox--disabled {
|
|
695
|
+
background: transparent;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
&__checkbox-label {
|
|
700
|
+
&--distractor {
|
|
701
|
+
text-decoration: line-through;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
&__radio-btns {
|
|
706
|
+
width: 100%;
|
|
707
|
+
max-width: 345px;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
</style>
|