-
Notifications
You must be signed in to change notification settings - Fork 630
/
QuestionLearnersReport.vue
168 lines (154 loc) · 4.35 KB
/
QuestionLearnersReport.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<template>
<MultiPaneLayout ref="multiPaneLayout">
<div slot="header">
<h1 class="title item-detail-section">
<ContentIcon
class="item-detail-icons"
:kind="kind"
:showTooltip="false"
/>
{{ title }}
<CoachContentLabel
class="item-detail-icons"
:value="exercise.num_coach_contents || 0"
:isTopic="false"
/>
</h1>
</div>
<template v-if="learners.length > 0">
<QuestionDetailLearnerList
slot="aside"
:learners="learners"
:selectedLearnerNumber="learnerIndex"
@select="navigateToNewAttempt($event)"
/>
<div slot="main" class="exercise-section" :style="{ backgroundColor: $coreBgLight }">
<KCheckbox
:label="coachStrings.$tr('showCorrectAnswerLabel')"
:checked="showCorrectAnswer"
@change="toggleShowCorrectAnswer"
/>
<InteractionList
v-if="!showCorrectAnswer"
:interactions="currentInteractionHistory"
:selectedInteractionIndex="interactionIndex"
@select="navigateToNewInteraction($event)"
/>
<ContentRenderer
v-if="currentInteraction"
:itemId="currentLearner.item"
:assessment="true"
:allowHints="false"
:kind="exercise.kind"
:files="exercise.files"
:available="exercise.available"
:answerState="answerState"
:showCorrectAnswer="showCorrectAnswer"
:interactive="false"
:extraFields="exercise.extra_fields"
/>
</div>
</template>
</MultiPaneLayout>
</template>
<script>
import { mapGetters, mapState } from 'vuex';
import themeMixin from 'kolibri.coreVue.mixins.themeMixin';
import ContentRenderer from 'kolibri.coreVue.components.ContentRenderer';
import InteractionList from 'kolibri.coreVue.components.InteractionList';
import KCheckbox from 'kolibri.coreVue.components.KCheckbox';
import MultiPaneLayout from 'kolibri.coreVue.components.MultiPaneLayout';
import CoachContentLabel from 'kolibri.coreVue.components.CoachContentLabel';
import commonCoach from '../common';
import QuestionDetailLearnerList from './QuestionDetailLearnerList';
export default {
name: 'QuestionLearnersReport',
components: {
ContentRenderer,
QuestionDetailLearnerList,
InteractionList,
KCheckbox,
MultiPaneLayout,
CoachContentLabel,
},
mixins: [commonCoach, themeMixin],
$trs: {},
data() {
return {
showCorrectAnswer: false,
};
},
computed: {
...mapState('questionDetail', [
'exercise',
'interactionIndex',
'learnerId',
'questionNumber',
'questionId',
'title',
]),
...mapGetters('questionDetail', [
'currentLearner',
'currentInteraction',
'currentInteractionHistory',
'learners',
'learnerIndex',
'kind',
]),
// Do not pass in answerState if showCorrectAnswer is set to true
// answerState has a precedence over showCorrectAnswer
answerState() {
if (
!this.showCorrectAnswer &&
this.currentInteraction &&
this.currentInteraction.type === 'answer'
) {
return this.currentInteraction.answer;
}
return null;
},
},
methods: {
navigateToNewAttempt(learnerIndex) {
this.showCorrectAnswer = false;
const learnerId = this.learners[learnerIndex].id;
this.$emit('navigate', {
questionId: this.questionId,
learnerId,
interactionIndex: 0,
});
this.$refs.multiPaneLayout.scrollMainToTop();
},
navigateToNewInteraction(interactionIndex) {
this.$emit('navigate', {
questionId: this.questionId,
learnerId: this.learnerId,
interactionIndex,
});
},
toggleShowCorrectAnswer() {
this.showCorrectAnswer = !this.showCorrectAnswer;
this.$forceUpdate();
},
},
};
</script>
<style lang="scss" scoped>
.exercise-section {
padding: 16px;
h3 {
margin-top: 0;
}
}
.title {
margin-bottom: 0;
}
.item-detail-section {
display: inline-block;
margin-top: 0;
}
.item-detail-icons {
position: relative;
top: -2px;
}
</style>