-
Notifications
You must be signed in to change notification settings - Fork 634
/
LearnerExerciseReport.vue
190 lines (176 loc) · 5.29 KB
/
LearnerExerciseReport.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<template>
<MultiPaneLayout ref="multiPaneLayout">
<div slot="header">
<h1 class="learner-name">
{{ learner.name }}
</h1>
<p class="exercise-detail-section">
<ContentIcon
class="exercise-detail-icons"
:kind="ContentNodeKinds.EXERCISE"
:showTooltip="false"
/>
{{ exercise.title }}
<CoachContentLabel
class="exercise-detail-icons"
:value="exercise.num_coach_contents || 0"
:isTopic="false"
/>
</p>
<HeaderTable>
<HeaderTableRow>
<template slot="key">
{{ coachStrings.$tr('masteryModelLabel') }}
</template>
<template slot="value">
<MasteryModel />
</template>
</HeaderTableRow>
<HeaderTableRow>
<template slot="key">
{{ coachStrings.$tr('statusLabel') }}
</template>
<template slot="value">
<StatusSimple :status="status" />
</template>
</HeaderTableRow>
</HeaderTable>
</div>
<template v-if="attemptLogs.length > 0">
<AttemptLogList
slot="aside"
:attemptLogs="attemptLogs"
:selectedQuestionNumber="attemptLogIndex"
@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="currentAttemptLog.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 AttemptLogList from 'kolibri.coreVue.components.AttemptLogList';
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';
export default {
name: 'LearnerExerciseReport',
components: {
ContentRenderer,
AttemptLogList,
InteractionList,
KCheckbox,
MultiPaneLayout,
CoachContentLabel,
},
mixins: [commonCoach, themeMixin],
$trs: {},
data() {
return {
showCorrectAnswer: false,
};
},
computed: {
...mapGetters('exerciseDetail', [
'currentAttemptLog',
'currentInteraction',
'currentInteractionHistory',
'attemptLogs',
'attemptLogIndex',
]),
...mapGetters('classSummary', ['getContentStatusObjForLearner']),
...mapState('classSummary', ['learnerMap']),
...mapState('exerciseDetail', ['attemptId', 'exercise', 'interactionIndex', 'learnerId']),
status() {
return this.getContentStatusObjForLearner(this.exercise.content_id, this.learnerId).status;
},
learner() {
return this.learnerMap[this.learnerId];
},
// 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(attemptLogIndex) {
this.showCorrectAnswer = false;
this.$emit('navigate', {
exerciseId: this.exercise.content_id,
learnerId: this.learnerId,
interactionIndex: 0,
attemptId: this.attemptLogs[attemptLogIndex].id,
});
this.$refs.multiPaneLayout.scrollMainToTop();
},
navigateToNewInteraction(interactionIndex) {
this.$emit('navigate', {
exerciseId: this.exercise.content_id,
learnerId: this.learnerId,
interactionIndex,
attemptId: this.attemptId,
});
},
toggleShowCorrectAnswer() {
this.showCorrectAnswer = !this.showCorrectAnswer;
this.$forceUpdate();
},
},
};
</script>
<style lang="scss" scoped>
.exercise-section {
padding: 16px;
h3 {
margin-top: 0;
}
}
.learner-name {
margin-bottom: 0;
}
.exercise-detail-section {
display: inline-block;
margin-top: 0;
}
.exercise-detail-icons {
position: relative;
top: -2px;
}
</style>