@pocketprep/ui-kit 3.4.89 → 3.5.0
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 +14834 -16036
- package/dist/@pocketprep/ui-kit.js.map +1 -1
- package/dist/@pocketprep/ui-kit.umd.cjs +12 -12
- package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/lib/components/Bundles/BundleSearch.vue +41 -11
- package/lib/components/Pagination/QuestionReviewPagination.vue +21 -19
- package/lib/components/Quiz/Question/ChoicesContainer.vue +95 -129
- package/lib/components/Quiz/Question/DropdownExplanation.vue +39 -53
- package/lib/components/Quiz/Question/Explanation.vue +47 -57
- package/lib/components/Quiz/Question/MatrixChoicesContainer.vue +211 -224
- package/lib/components/Quiz/Question/MatrixRadioGroup.vue +5 -4
- package/lib/components/Quiz/Question/MobileMatrixChoicesContainer.vue +321 -319
- package/lib/components/Quiz/Question/MobileMatrixRadioGroup.vue +7 -6
- package/lib/components/Quiz/Question/PassageAndImage.vue +32 -43
- package/lib/components/Quiz/Question/PassageAndImageDropdown.vue +32 -43
- package/lib/components/Quiz/Question/Paywall.vue +28 -39
- package/lib/components/Quiz/Question/QuestionContext.vue +23 -31
- package/lib/components/Quiz/Question/StatsSummary.vue +10 -20
- package/lib/components/Quiz/Question/Summary.vue +54 -64
- package/lib/components/Quiz/Question/composables.ts +71 -0
- package/lib/components/Quiz/Question/injectionSymbols.ts +69 -0
- package/lib/components/Quiz/Question.vue +788 -988
- package/lib/components/Quiz/QuizContainer.vue +36 -34
- package/lib/components/Quiz/question.d.ts +4 -4
- package/lib/directives.ts +27 -22
- package/lib/styles/_breakpoints.scss +6 -12
- package/package.json +4 -4
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
8
|
v-dark="isDarkMode"
|
|
9
|
-
v-breakpoint
|
|
9
|
+
v-breakpoint="breakpointsWithEl"
|
|
10
10
|
class="uikit-question-matrix-choices-container__columns"
|
|
11
11
|
>
|
|
12
12
|
<div
|
|
13
13
|
v-dark="isDarkMode"
|
|
14
|
-
v-breakpoint
|
|
14
|
+
v-breakpoint="breakpointsWithEl"
|
|
15
15
|
class="uikit-question-matrix-choices-container__column-row-header"
|
|
16
16
|
:class="{
|
|
17
17
|
'uikit-question-matrix-choices-container__column-row-header--two-columns':
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
v-for="(columnLabel, index) in matrixColumnLabels"
|
|
35
35
|
:key="index"
|
|
36
36
|
v-dark="isDarkMode"
|
|
37
|
-
v-breakpoint
|
|
37
|
+
v-breakpoint="breakpointsWithEl"
|
|
38
38
|
v-html="columnLabel"
|
|
39
39
|
/>
|
|
40
40
|
</div>
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
(showMatrixAnswers || reviewMode) && isTeachGroupReview,
|
|
51
51
|
}"
|
|
52
52
|
v-dark="isDarkMode"
|
|
53
|
-
v-breakpoint
|
|
53
|
+
v-breakpoint="breakpointsWithEl"
|
|
54
54
|
>
|
|
55
55
|
<div
|
|
56
56
|
class="uikit-question-matrix-choices-container__choices"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
numberOfMatrixColumnLabels === 2,
|
|
62
62
|
}"
|
|
63
63
|
v-dark="isDarkMode"
|
|
64
|
-
v-breakpoint
|
|
64
|
+
v-breakpoint="breakpointsWithEl"
|
|
65
65
|
v-for="(rowLabel, rowIndex) in matrixRowLabels"
|
|
66
66
|
:key="rowIndex"
|
|
67
67
|
>
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
question.type === 'Matrix Radio Button' && numberOfMatrixColumnLabels === 2,
|
|
77
77
|
}"
|
|
78
78
|
v-dark="isDarkMode"
|
|
79
|
-
v-breakpoint
|
|
79
|
+
v-breakpoint="breakpointsWithEl"
|
|
80
80
|
v-html="rowLabel"
|
|
81
81
|
/>
|
|
82
82
|
<template
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
v-for="(columnLabel, columnIndex) in matrixColumnLabels"
|
|
104
104
|
:key="columnIndex"
|
|
105
105
|
v-dark="isDarkMode"
|
|
106
|
-
v-breakpoint
|
|
106
|
+
v-breakpoint="breakpointsWithEl"
|
|
107
107
|
>
|
|
108
108
|
<Checkbox
|
|
109
109
|
v-if="(showMatrixAnswers || reviewMode) &&
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
:checkbox-styles="checkboxContainerStyling(rowIndex, columnIndex)"
|
|
116
116
|
/>
|
|
117
117
|
<div
|
|
118
|
-
v-else
|
|
118
|
+
v-else
|
|
119
119
|
class="uikit-question-matrix-choices-container__clickable-checkbox"
|
|
120
120
|
:class="{
|
|
121
121
|
'uikit-question-matrix-choices-container__clickable-checkbox--review':
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
checkboxClicked(rowIndex, columnIndex)"
|
|
127
127
|
>
|
|
128
128
|
<Checkbox
|
|
129
|
-
:model-value="matrixCheckboxGrid[rowIndex][columnIndex]"
|
|
129
|
+
:model-value="matrixCheckboxGrid[rowIndex]?.[columnIndex] || false"
|
|
130
130
|
:is-dark-mode="isDarkMode"
|
|
131
131
|
:disabled="showMatrixAnswers || reviewMode"
|
|
132
132
|
:checkbox-styles="checkboxContainerStyling(rowIndex, columnIndex)"
|
|
@@ -163,7 +163,6 @@
|
|
|
163
163
|
:is-dark-mode="isDarkMode"
|
|
164
164
|
:disabled="false"
|
|
165
165
|
:question-el="questionEl"
|
|
166
|
-
:breakpoints="breakpoints"
|
|
167
166
|
@update:modelValue="updateRadioRowSelection(rowIndex, $event)"
|
|
168
167
|
>
|
|
169
168
|
<template #optionIcon="{ optionIcon }">
|
|
@@ -189,272 +188,260 @@
|
|
|
189
188
|
</div>
|
|
190
189
|
</template>
|
|
191
190
|
|
|
192
|
-
<script lang="ts">
|
|
193
|
-
import { Component, Vue, Prop, Emit, Watch } from 'vue-facing-decorator'
|
|
191
|
+
<script setup lang="ts">
|
|
194
192
|
import Icon from '../../Icons/Icon.vue'
|
|
195
|
-
import PocketButton from '../../Buttons/Button.vue'
|
|
196
193
|
import Checkbox from '../../Forms/Checkbox.vue'
|
|
197
194
|
import MatrixRadioGroup from './MatrixRadioGroup.vue'
|
|
198
|
-
import { dark, breakpoint } from '../../../directives'
|
|
199
|
-
import
|
|
200
|
-
import type {
|
|
195
|
+
import { dark as vDark, breakpoint as vBreakpoint } from '../../../directives'
|
|
196
|
+
import { useQuestionContext } from './composables'
|
|
197
|
+
import type { IRadioOptions, TMatrixChoiceKey } from './../question'
|
|
201
198
|
import BrandColors from '../../../pocketprep-export.module.scss'
|
|
199
|
+
import { ref, computed, onMounted, watch } from 'vue'
|
|
200
|
+
|
|
201
|
+
const emit = defineEmits<{
|
|
202
|
+
'emitSelectedMatrixChoice': [matrixChoiceKeys: TMatrixChoiceKey[]]
|
|
203
|
+
}>()
|
|
204
|
+
|
|
205
|
+
const {
|
|
206
|
+
// questionEl is used by the breakpoint directive
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
208
|
+
questionEl,
|
|
209
|
+
question,
|
|
210
|
+
isMatrixQuestionCorrect,
|
|
211
|
+
reviewMode,
|
|
212
|
+
isDarkMode,
|
|
213
|
+
breakpointsWithEl,
|
|
214
|
+
showMatrixAnswers,
|
|
215
|
+
matrixAnswerKeys,
|
|
216
|
+
selectedMatrixChoices,
|
|
217
|
+
isTeachGroupReview,
|
|
218
|
+
} = useQuestionContext()
|
|
219
|
+
|
|
220
|
+
const matrixCheckboxGrid = ref<boolean[][] | undefined>(undefined)
|
|
221
|
+
const matrixRadioGrid = ref<IRadioOptions[] | undefined>(undefined)
|
|
222
|
+
const brandColors = BrandColors
|
|
223
|
+
|
|
224
|
+
const defaultCheckboxGrid = computed(() => {
|
|
225
|
+
return matrixChoiceLayout.value?.map(row => {
|
|
226
|
+
const choiceRow = row.map(() => false)
|
|
227
|
+
return choiceRow
|
|
228
|
+
})
|
|
229
|
+
})
|
|
202
230
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
}
|
|
210
|
-
directives: {
|
|
211
|
-
dark,
|
|
212
|
-
breakpoint,
|
|
213
|
-
},
|
|
231
|
+
const defaultRadioButtonGrid = computed(() => {
|
|
232
|
+
return matrixChoiceLayout.value?.map(row => {
|
|
233
|
+
return {
|
|
234
|
+
choices: row as TMatrixChoiceKey[],
|
|
235
|
+
value: null as TMatrixChoiceKey | null,
|
|
236
|
+
}
|
|
237
|
+
})
|
|
214
238
|
})
|
|
215
|
-
export default class MatrixChoicesContainer extends Vue {
|
|
216
|
-
@Prop({ default: false }) reviewMode!: boolean
|
|
217
|
-
@Prop({ default: false }) isDarkMode!: boolean
|
|
218
|
-
@Prop({ default: null }) questionEl!: Element | null
|
|
219
|
-
@Prop({ default: {
|
|
220
|
-
'mobile': 767,
|
|
221
|
-
'tablet-portrait': 1023,
|
|
222
|
-
'tablet-landscape': 1439,
|
|
223
|
-
} }) breakpoints!: TBreakPointsObject
|
|
224
|
-
@Prop() question!: Study.Class.QuestionJSON
|
|
225
|
-
@Prop() matrixChoiceLayout!: string[][]
|
|
226
|
-
@Prop({ default: false }) showMatrixAnswers!: boolean
|
|
227
|
-
@Prop({ default: false }) isUnanswered!: boolean
|
|
228
|
-
@Prop({ default: false }) isMatrixQuestionCorrect!: boolean
|
|
229
|
-
@Prop() matrixAnswerKeys!: TMatrixChoiceKey[]
|
|
230
|
-
@Prop() matrixDistractorKeys!: TMatrixChoiceKey[]
|
|
231
|
-
@Prop() selectedMatrixChoices!: TMatrixChoiceKey[]
|
|
232
|
-
@Prop({ default: false }) isTeachGroupReview!: boolean
|
|
233
|
-
|
|
234
|
-
matrixCheckboxGrid: boolean[][] | undefined = undefined
|
|
235
|
-
matrixRadioGrid: IRadioOptions[] | undefined = undefined
|
|
236
|
-
columnIndex = 0
|
|
237
|
-
rowIndex = 0
|
|
238
|
-
brandColors = BrandColors
|
|
239
|
-
|
|
240
|
-
get defaultCheckboxGrid () {
|
|
241
|
-
return this.matrixChoiceLayout?.map(row => {
|
|
242
|
-
const choiceRow = row.map(() => false)
|
|
243
|
-
return choiceRow
|
|
244
|
-
})
|
|
245
|
-
}
|
|
246
239
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
choices: row as TMatrixChoiceKey[],
|
|
251
|
-
value: null as TMatrixChoiceKey | null,
|
|
252
|
-
}
|
|
253
|
-
})
|
|
254
|
-
}
|
|
240
|
+
const matrixChoiceLayout = computed(() => {
|
|
241
|
+
return question.value.matrixChoiceLayout
|
|
242
|
+
})
|
|
255
243
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
244
|
+
const matrixRowLabels = computed(() => {
|
|
245
|
+
return question.value.matrixLabels?.rows
|
|
246
|
+
})
|
|
259
247
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
248
|
+
const matrixColumnLabels = computed(() => {
|
|
249
|
+
return question.value.matrixLabels?.columns
|
|
250
|
+
})
|
|
263
251
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
252
|
+
const numberOfMatrixColumnLabels = computed(() => {
|
|
253
|
+
return question.value.matrixLabels?.columns.length || 0
|
|
254
|
+
})
|
|
267
255
|
|
|
268
|
-
|
|
269
|
-
|
|
256
|
+
const matrixColumnLabelsForRows = computed(() => {
|
|
257
|
+
return question.value.matrixLabels?.columnLabelForRows
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
onMounted(() => {
|
|
261
|
+
if (question.value.type === 'Matrix Checkbox') {
|
|
262
|
+
matrixCheckboxGrid.value = convertSelectedMatrixChoiceToCheckboxGrid()
|
|
270
263
|
}
|
|
264
|
+
|
|
265
|
+
if (question.value.type === 'Matrix Radio Button') {
|
|
266
|
+
matrixRadioGrid.value = convertSelectedMatrixChoiceToRadioBtnGrid()
|
|
267
|
+
}
|
|
268
|
+
})
|
|
271
269
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
270
|
+
const convertSelectedMatrixChoiceToCheckboxGrid = () => {
|
|
271
|
+
const checkboxGrid = defaultCheckboxGrid.value
|
|
272
|
+
selectedMatrixChoices.value.forEach(choice => {
|
|
273
|
+
const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
|
|
274
|
+
const colIndex = Number(choice.split('_').pop()) - 1
|
|
275
|
+
const row = checkboxGrid && checkboxGrid[rowIndex]
|
|
276
|
+
if (row) {
|
|
277
|
+
row[colIndex] = true
|
|
275
278
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
+
})
|
|
280
|
+
return checkboxGrid
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const convertSelectedMatrixChoiceToRadioBtnGrid = () => {
|
|
284
|
+
const radioBtnGrid = defaultRadioButtonGrid.value
|
|
285
|
+
selectedMatrixChoices.value.forEach(choice => {
|
|
286
|
+
const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
|
|
287
|
+
const row = radioBtnGrid && radioBtnGrid[rowIndex]
|
|
288
|
+
if (row) {
|
|
289
|
+
row.value = choice
|
|
279
290
|
}
|
|
280
|
-
}
|
|
291
|
+
})
|
|
292
|
+
return radioBtnGrid
|
|
293
|
+
}
|
|
281
294
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
const rowIndex = Number(choice.substring(1, choice.indexOf('_'))) - 1
|
|
286
|
-
const colIndex = Number(choice.split('_').pop()) - 1
|
|
287
|
-
if (checkboxGrid && checkboxGrid[rowIndex]) {
|
|
288
|
-
checkboxGrid[rowIndex][colIndex] = true
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
return checkboxGrid
|
|
292
|
-
}
|
|
295
|
+
const getRadioRowSelection = (rowIndex: number) => {
|
|
296
|
+
return matrixRadioGrid.value?.[rowIndex]?.value
|
|
297
|
+
}
|
|
293
298
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (radioBtnGrid && radioBtnGrid[rowIndex]) {
|
|
299
|
-
radioBtnGrid[rowIndex].value = choice
|
|
300
|
-
}
|
|
301
|
-
})
|
|
302
|
-
return radioBtnGrid
|
|
303
|
-
}
|
|
299
|
+
const getRadioRowChoices = (rowIndex: number) => {
|
|
300
|
+
const choices = matrixRadioGrid.value?.[rowIndex]?.choices
|
|
301
|
+
return choices
|
|
302
|
+
}
|
|
304
303
|
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
const updateRadioRowSelection = (rowIndex: number, choiceKey: TMatrixChoiceKey | null) => {
|
|
305
|
+
const row = matrixRadioGrid.value?.[rowIndex]
|
|
306
|
+
if (row) {
|
|
307
|
+
row.value = choiceKey
|
|
307
308
|
}
|
|
309
|
+
}
|
|
308
310
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
311
|
+
const selectedChoiceKey = (rowIndex: number, colIndex: number) => {
|
|
312
|
+
const row = rowIndex += 1
|
|
313
|
+
const column = colIndex += 1
|
|
314
|
+
if (selectedMatrixChoices && matrixAnswerKeys) {
|
|
315
|
+
const matrixSelectedChoiceKey = selectedMatrixChoices.value.find((choice) => {
|
|
316
|
+
const substring = choice.substring(1)
|
|
317
|
+
return substring === `${row}_${column}`
|
|
318
|
+
})
|
|
319
|
+
return matrixSelectedChoiceKey
|
|
312
320
|
}
|
|
321
|
+
return undefined
|
|
322
|
+
}
|
|
313
323
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
324
|
+
const correctlySelectedChoice = (rowIndex: number, colIndex: number) => {
|
|
325
|
+
if (selectedMatrixChoices.value && matrixAnswerKeys.value) {
|
|
326
|
+
const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
|
|
327
|
+
if (selectedChoice && selectedChoice.startsWith('a') && matrixAnswerKeys.value.includes(selectedChoice)) {
|
|
328
|
+
return true
|
|
318
329
|
}
|
|
319
330
|
}
|
|
331
|
+
return false
|
|
332
|
+
}
|
|
320
333
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
|
|
326
|
-
const substring = choice.substring(1)
|
|
327
|
-
return substring === `${row}_${column}`
|
|
328
|
-
})
|
|
329
|
-
return matrixSelectedChoiceKey
|
|
334
|
+
const incorrectlySelectedChoice = (rowIndex: number, colIndex: number) => {
|
|
335
|
+
if (selectedMatrixChoices.value && matrixAnswerKeys.value) {
|
|
336
|
+
const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
|
|
337
|
+
if (selectedChoice && selectedChoice.startsWith('d')) {
|
|
338
|
+
return true
|
|
330
339
|
}
|
|
331
|
-
return undefined
|
|
332
340
|
}
|
|
341
|
+
return false
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const correctAnswerButNotSelected = (rowIndex: number, colIndex: number) => {
|
|
345
|
+
const selectedChoice = selectedChoiceKey(rowIndex, colIndex)
|
|
346
|
+
const answerKey = matrixAnswerKeys.value.find(choice => choice === `a${rowIndex + 1}_${colIndex + 1}`)
|
|
347
|
+
return answerKey && !selectedChoice
|
|
348
|
+
}
|
|
333
349
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
|
|
337
|
-
if (selectedChoice && selectedChoice.startsWith('a') && this.matrixAnswerKeys.includes(selectedChoice)) {
|
|
338
|
-
return true
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return false
|
|
342
|
-
}
|
|
350
|
+
const checkboxContainerStyling = (rowIndex: number, columnIndex: number) => {
|
|
351
|
+
const isReviewMode = showMatrixAnswers.value || reviewMode
|
|
343
352
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}
|
|
353
|
+
// check box is correctlySelected
|
|
354
|
+
if (isReviewMode && correctlySelectedChoice(rowIndex, columnIndex)) {
|
|
355
|
+
const borderColor = isDarkMode ? brandColors.jungleGreen : brandColors.cadaverous
|
|
356
|
+
return {
|
|
357
|
+
borderColor: `${borderColor} !important`,
|
|
358
|
+
background: `${borderColor} !important`,
|
|
350
359
|
}
|
|
351
|
-
return false
|
|
352
360
|
}
|
|
353
|
-
|
|
354
|
-
correctAnswerButNotSelected (rowIndex: number, colIndex: number) {
|
|
355
|
-
const selectedChoice = this.selectedChoiceKey(rowIndex, colIndex)
|
|
356
|
-
const answerKey = this.matrixAnswerKeys.find(choice => choice === `a${rowIndex + 1}_${colIndex + 1}`)
|
|
357
|
-
return answerKey && !selectedChoice
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
checkboxContainerStyling (rowIndex: number, columnIndex: number) {
|
|
361
|
-
const isReviewMode = this.showMatrixAnswers || this.reviewMode
|
|
362
|
-
const incorrectlySelectedChoice = this.incorrectlySelectedChoice(rowIndex, columnIndex)
|
|
363
|
-
|
|
364
|
-
// check box is correctlySelected
|
|
365
|
-
if (isReviewMode && this.correctlySelectedChoice(rowIndex, columnIndex)) {
|
|
366
|
-
const borderColor = this.isDarkMode ? this.brandColors.jungleGreen : this.brandColors.cadaverous
|
|
367
|
-
return {
|
|
368
|
-
borderColor: `${borderColor} !important`,
|
|
369
|
-
background: `${borderColor} !important`,
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
361
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
if (isReviewMode && this.correctAnswerButNotSelected(rowIndex, columnIndex)) {
|
|
381
|
-
return {
|
|
382
|
-
background: 'transparent !important',
|
|
383
|
-
border: `1px solid ${this.brandColors.slate} !important`,
|
|
384
|
-
}
|
|
362
|
+
if (isReviewMode && incorrectlySelectedChoice(rowIndex, columnIndex)) {
|
|
363
|
+
return {
|
|
364
|
+
background: `${brandColors.steel} !important`,
|
|
365
|
+
border: `1px solid ${brandColors.steel} !important`,
|
|
385
366
|
}
|
|
386
367
|
}
|
|
387
368
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
return {
|
|
393
|
-
color: `${color} !important`,
|
|
394
|
-
}
|
|
369
|
+
if (isReviewMode && correctAnswerButNotSelected(rowIndex, columnIndex)) {
|
|
370
|
+
return {
|
|
371
|
+
background: 'transparent !important',
|
|
372
|
+
border: `1px solid ${brandColors.slate} !important`,
|
|
395
373
|
}
|
|
396
374
|
}
|
|
375
|
+
}
|
|
397
376
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
377
|
+
const checkboxCheckStyling = (rowIndex: number, columnIndex: number) => {
|
|
378
|
+
const isReviewMode = showMatrixAnswers.value || reviewMode
|
|
379
|
+
if (isReviewMode && correctAnswerButNotSelected(rowIndex, columnIndex)) {
|
|
380
|
+
const color = isDarkMode ? brandColors.jungleGreen : brandColors.cadaverous
|
|
381
|
+
return {
|
|
382
|
+
color: `${color} !important`,
|
|
401
383
|
}
|
|
402
384
|
}
|
|
385
|
+
}
|
|
403
386
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
387
|
+
const checkboxClicked = (rowIndex: number, columnIndex: number) => {
|
|
388
|
+
const row = matrixCheckboxGrid.value?.[rowIndex]
|
|
389
|
+
if (row) {
|
|
390
|
+
row[columnIndex] = !row[columnIndex]
|
|
407
391
|
}
|
|
392
|
+
}
|
|
408
393
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
394
|
+
const emitSelectedMatrixChoice = (matrixChoiceKeys: TMatrixChoiceKey[]) => {
|
|
395
|
+
emit('emitSelectedMatrixChoice', matrixChoiceKeys)
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
watch(matrixCheckboxGrid, () => {
|
|
399
|
+
if (matrixChoiceLayout.value && matrixCheckboxGrid.value) {
|
|
400
|
+
const selectedCheckboxChoices: TMatrixChoiceKey[] = []
|
|
401
|
+
|
|
402
|
+
matrixCheckboxGrid.value?.forEach((row, rowIndex) => {
|
|
403
|
+
row.forEach((choice, choiceIndex) => {
|
|
404
|
+
if (
|
|
405
|
+
choice &&
|
|
406
|
+
matrixChoiceLayout.value?.[rowIndex] &&
|
|
407
|
+
matrixChoiceLayout.value?.[rowIndex]?.[choiceIndex]
|
|
408
|
+
) {
|
|
409
|
+
const choiceKey = matrixChoiceLayout.value?.[rowIndex]?.[choiceIndex] as TMatrixChoiceKey | null
|
|
410
|
+
if (choiceKey) {
|
|
422
411
|
selectedCheckboxChoices.push(choiceKey)
|
|
423
412
|
}
|
|
424
|
-
}
|
|
425
|
-
})
|
|
426
|
-
|
|
427
|
-
|
|
413
|
+
}
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
emitSelectedMatrixChoice(selectedCheckboxChoices)
|
|
428
417
|
}
|
|
418
|
+
}, { deep: true })
|
|
429
419
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
|
|
420
|
+
watch(matrixRadioGrid, () => {
|
|
421
|
+
if (matrixChoiceLayout.value && matrixRadioGrid.value) {
|
|
422
|
+
const selectedRadioButtonChoices: TMatrixChoiceKey[] = []
|
|
434
423
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}
|
|
424
|
+
matrixRadioGrid.value?.forEach((row, rowIndex) => {
|
|
425
|
+
const choiceKey = row.value
|
|
426
|
+
if (choiceKey && matrixChoiceLayout.value?.[rowIndex]) {
|
|
427
|
+
selectedRadioButtonChoices.push(choiceKey)
|
|
428
|
+
}
|
|
429
|
+
})
|
|
430
|
+
emitSelectedMatrixChoice(selectedRadioButtonChoices)
|
|
443
431
|
}
|
|
432
|
+
}, { deep: true })
|
|
444
433
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
}
|
|
434
|
+
watch(selectedMatrixChoices, () => {
|
|
435
|
+
if ((reviewMode || showMatrixAnswers.value) && question.value.type === 'Matrix Checkbox') {
|
|
436
|
+
const selectedCheckboxGrid = convertSelectedMatrixChoiceToCheckboxGrid()
|
|
437
|
+
matrixCheckboxGrid.value = selectedCheckboxGrid ? selectedCheckboxGrid : defaultCheckboxGrid.value
|
|
438
|
+
}
|
|
451
439
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
440
|
+
if ((reviewMode || showMatrixAnswers.value) && question.value.type === 'Matrix Radio Button') {
|
|
441
|
+
const selectedRadioBtnGrid = convertSelectedMatrixChoiceToRadioBtnGrid()
|
|
442
|
+
matrixRadioGrid.value = selectedRadioBtnGrid
|
|
456
443
|
}
|
|
457
|
-
}
|
|
444
|
+
})
|
|
458
445
|
|
|
459
446
|
</script>
|
|
460
447
|
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import RadioButton from '../../Forms/RadioButton.vue'
|
|
3
3
|
import { dark as vDark } from '../../../directives'
|
|
4
|
+
import type { TMatrixChoiceKey } from '../question'
|
|
4
5
|
|
|
5
6
|
defineProps<{
|
|
6
7
|
isDarkMode: boolean
|
|
7
|
-
choices
|
|
8
|
+
choices?: TMatrixChoiceKey[]
|
|
8
9
|
labels?: string[]
|
|
9
10
|
showAnswers: boolean
|
|
10
11
|
disabled: boolean
|
|
11
12
|
}>()
|
|
12
13
|
|
|
13
|
-
const selectedChoice = defineModel<
|
|
14
|
+
const selectedChoice = defineModel<TMatrixChoiceKey | null>({ default: null })
|
|
14
15
|
|
|
15
|
-
const selectChoice = (choiceKey:
|
|
16
|
+
const selectChoice = (choiceKey: TMatrixChoiceKey) => {
|
|
16
17
|
selectedChoice.value = choiceKey
|
|
17
18
|
}
|
|
18
19
|
</script>
|
|
19
20
|
|
|
20
21
|
<template>
|
|
21
22
|
<ul
|
|
22
|
-
v-if="choices.length"
|
|
23
|
+
v-if="choices && choices.length"
|
|
23
24
|
class="uikit-matrix-radio-group"
|
|
24
25
|
:class="{'uikit-matrix-radio-group--disabled': showAnswers}"
|
|
25
26
|
v-dark="isDarkMode"
|