@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,131 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import RadioButton from '../../Forms/RadioButton.vue'
|
|
3
|
+
import { dark as vDark } from '../../../directives'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
isDarkMode: boolean
|
|
7
|
+
choices: string[]
|
|
8
|
+
labels: string[]
|
|
9
|
+
showAnswers: boolean
|
|
10
|
+
disabled: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
14
|
+
isDarkMode: false,
|
|
15
|
+
showAnswers: false,
|
|
16
|
+
disabled: false,
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const selectedChoice = defineModel<string>()
|
|
20
|
+
|
|
21
|
+
const selectChoice = (choiceKey: string) => {
|
|
22
|
+
selectedChoice.value = choiceKey
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const radioButtonColor = (choice: string) => {
|
|
26
|
+
if (props.showAnswers) {
|
|
27
|
+
if (choice === selectedChoice.value && selectedChoice.value?.startsWith('a')) {
|
|
28
|
+
return 'green'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (choice === selectedChoice.value && selectedChoice.value?.startsWith('d')) {
|
|
32
|
+
return 'gray'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (choice.startsWith('a')) {
|
|
36
|
+
return 'green'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return 'blue'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const stripText = (string?: string) => {
|
|
44
|
+
return string?.replace(/<[^\s>]+[^>]*>/gi, ' ').trim()
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<template>
|
|
49
|
+
<ul
|
|
50
|
+
v-if="choices.length"
|
|
51
|
+
class="uikit-mobile-matrix-radio-group"
|
|
52
|
+
v-dark="isDarkMode"
|
|
53
|
+
role="radiogroup"
|
|
54
|
+
>
|
|
55
|
+
<li
|
|
56
|
+
class="uikit-mobile-matrix-radio-group__option"
|
|
57
|
+
v-dark="isDarkMode"
|
|
58
|
+
role="radio"
|
|
59
|
+
v-for="(choice, index) in choices"
|
|
60
|
+
:key="choice"
|
|
61
|
+
>
|
|
62
|
+
<RadioButton
|
|
63
|
+
class="uikit-mobile-matrix-radio-group__radio-btn"
|
|
64
|
+
:selected="(choice === selectedChoice) || (showAnswers && choice.startsWith('a'))"
|
|
65
|
+
:disabled="disabled"
|
|
66
|
+
:isDarkMode="isDarkMode"
|
|
67
|
+
:color="radioButtonColor(choice)"
|
|
68
|
+
@click="!disabled && !showAnswers && selectChoice(choice)"
|
|
69
|
+
/>
|
|
70
|
+
<div
|
|
71
|
+
v-if="labels"
|
|
72
|
+
v-dark="props.isDarkMode"
|
|
73
|
+
class="uikit-mobile-matrix-radio-group__label"
|
|
74
|
+
:class="{
|
|
75
|
+
'uikit-mobile-matrix-radio-group__label--distractor':
|
|
76
|
+
showAnswers && choice?.startsWith('d')
|
|
77
|
+
}"
|
|
78
|
+
@click="!disabled && !showAnswers && selectChoice(choice)"
|
|
79
|
+
>
|
|
80
|
+
{{ stripText(labels[index]) }}
|
|
81
|
+
</div>
|
|
82
|
+
</li>
|
|
83
|
+
</ul>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<style lang="scss" scoped>
|
|
87
|
+
@import '../../../styles/breakpoints';
|
|
88
|
+
@import '../../../styles/colors';
|
|
89
|
+
|
|
90
|
+
.uikit-mobile-matrix-radio-group {
|
|
91
|
+
list-style: none;
|
|
92
|
+
margin: 0;
|
|
93
|
+
padding: 0;
|
|
94
|
+
display: block;
|
|
95
|
+
background: $white;
|
|
96
|
+
border-radius: 0px 0px 5px 5px;
|
|
97
|
+
|
|
98
|
+
&--dark {
|
|
99
|
+
background: $brand-black;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
&__option {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
padding-left: 15px;
|
|
106
|
+
height: 47px;
|
|
107
|
+
max-width: 325px;
|
|
108
|
+
border: 0.5px solid rgba($pewter, 0.85);
|
|
109
|
+
border-top: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
&__label {
|
|
114
|
+
display: block;
|
|
115
|
+
margin-left: 12px;
|
|
116
|
+
color: $brand-black;
|
|
117
|
+
font-size: 16px;
|
|
118
|
+
font-weight: 500;
|
|
119
|
+
line-height: 23px;
|
|
120
|
+
letter-spacing: -0.1px;
|
|
121
|
+
|
|
122
|
+
&--dark {
|
|
123
|
+
color: $barely-background;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
&--distractor {
|
|
127
|
+
text-decoration: line-through;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
</style>
|
|
@@ -4,17 +4,23 @@
|
|
|
4
4
|
class="uikit-question-stats-summary"
|
|
5
5
|
>
|
|
6
6
|
<div v-dark="isDarkMode" class="uikit-question-stats-summary__stats-summary-total">
|
|
7
|
-
<div class="uikit-question-stats-summary__stats-summary-value">
|
|
7
|
+
<div v-if="!isMatrixQuestion" class="uikit-question-stats-summary__stats-summary-value">
|
|
8
8
|
{{ choiceScores.totalAnswered }}
|
|
9
9
|
</div>
|
|
10
|
+
<div v-else class="uikit-question-stats-summary__stats-summary-value">
|
|
11
|
+
{{ matrixChoiceScores.totalAnswered }}
|
|
12
|
+
</div>
|
|
10
13
|
<div v-dark="isDarkMode" class="uikit-question-stats-summary__stats-summary-label">
|
|
11
14
|
Studiers Answered
|
|
12
15
|
</div>
|
|
13
16
|
</div>
|
|
14
17
|
<div v-dark="isDarkMode" class="uikit-question-stats-summary__stats-summary-correct">
|
|
15
|
-
<div class="uikit-question-stats-summary__stats-summary-value">
|
|
18
|
+
<div v-if="!isMatrixQuestion" class="uikit-question-stats-summary__stats-summary-value">
|
|
16
19
|
{{ Math.round((choiceScores.answeredCorrectly / choiceScores.totalAnswered) * 100) }}%
|
|
17
20
|
</div>
|
|
21
|
+
<div v-else class="uikit-question-stats-summary__stats-summary-value">
|
|
22
|
+
{{ Math.round((matrixChoiceScores.answeredCorrectly / matrixChoiceScores.totalAnswered) * 100) }}%
|
|
23
|
+
</div>
|
|
18
24
|
<div v-dark="isDarkMode" class="uikit-question-stats-summary__stats-summary-label">
|
|
19
25
|
Answered Correctly
|
|
20
26
|
</div>
|
|
@@ -26,7 +32,7 @@
|
|
|
26
32
|
import { Component, Vue, Prop } from 'vue-facing-decorator'
|
|
27
33
|
import type { Study } from '@pocketprep/types'
|
|
28
34
|
import { dark, breakpoint } from '../../../directives'
|
|
29
|
-
import type { TChoiceScores } from './../question'
|
|
35
|
+
import type { TChoiceScores, TMatrixChoiceScores } from './../question'
|
|
30
36
|
|
|
31
37
|
|
|
32
38
|
@Component({
|
|
@@ -39,6 +45,8 @@ export default class StatsSummary extends Vue {
|
|
|
39
45
|
@Prop({ default: null }) globalMetrics!: Study.Class.GlobalQuestionMetricJSON | null
|
|
40
46
|
@Prop() choiceScores!: TChoiceScores
|
|
41
47
|
@Prop({ default: false }) isDarkMode!: boolean
|
|
48
|
+
@Prop({ default: false }) isMatrixQuestion!: boolean
|
|
49
|
+
@Prop() matrixChoiceScores!: TMatrixChoiceScores
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
</script>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
class="uikit-question-summary"
|
|
7
7
|
>
|
|
8
8
|
<div class="uikit-question-summary__summary-title">
|
|
9
|
-
{{
|
|
9
|
+
{{ isQuestionCorrect ? 'Correct': isUnanswered ? 'Unanswered' : 'Incorrect' }}
|
|
10
10
|
</div>
|
|
11
11
|
<PocketButton
|
|
12
12
|
v-breakpoint:questionEl="breakpoints"
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
</div>
|
|
98
98
|
</div>
|
|
99
99
|
<Icon
|
|
100
|
-
v-if="
|
|
100
|
+
v-if="isQuestionCorrect"
|
|
101
101
|
v-dark="isDarkMode"
|
|
102
102
|
type="correct"
|
|
103
103
|
class="uikit-question-summary__summary-correct-icon"
|
|
@@ -139,9 +139,11 @@ export default class Summary extends Vue {
|
|
|
139
139
|
@Prop({ default: undefined }) reference!: string | undefined
|
|
140
140
|
@Prop({ default: false }) hideReferences!: boolean
|
|
141
141
|
@Prop({ default: false }) isCorrect!: boolean
|
|
142
|
+
@Prop({ default: false }) isMatrixQuestionCorrect!: boolean
|
|
142
143
|
@Prop({ default: false }) isUnanswered!: boolean
|
|
143
144
|
@Prop({ default: false }) reviewMode!: boolean
|
|
144
145
|
@Prop({ default: false }) isDarkMode!: boolean
|
|
146
|
+
@Prop({ default: false }) isMatrixQuestion!: boolean
|
|
145
147
|
@Prop({ default: null }) questionEl!: Element | null
|
|
146
148
|
@Prop({ default: {
|
|
147
149
|
'mobile': 767,
|
|
@@ -149,6 +151,10 @@ export default class Summary extends Vue {
|
|
|
149
151
|
'tablet-landscape': 1439,
|
|
150
152
|
} }) breakpoints!: TBreakPointsObject
|
|
151
153
|
|
|
154
|
+
get isQuestionCorrect () {
|
|
155
|
+
return (!this.isMatrixQuestion && this.isCorrect) || (this.isMatrixQuestion && this.isMatrixQuestionCorrect)
|
|
156
|
+
}
|
|
157
|
+
|
|
152
158
|
@Emit('toggleSummaryExplanation')
|
|
153
159
|
toggleSummaryExplanation () {
|
|
154
160
|
return
|
|
@@ -186,6 +192,7 @@ export default class Summary extends Vue {
|
|
|
186
192
|
display: inline-block;
|
|
187
193
|
}
|
|
188
194
|
|
|
195
|
+
|
|
189
196
|
&__summary-title {
|
|
190
197
|
font-weight: 600;
|
|
191
198
|
font-size: 15.5px;
|