Skip to content

Commit 0f1407e

Browse files
exercise reports list
1 parent 3f4ab3b commit 0f1407e

File tree

5 files changed

+113
-21
lines changed

5 files changed

+113
-21
lines changed

src/layouts/LayoutClassroomStudent.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
<h1 v-text="classroom.name"></h1>
1414
<v-divider></v-divider>
15-
<p v-text="classroom.description"></p> <!-- TODO: multiline -->
15+
<p
16+
class="mt-5"
17+
v-text="classroom.description"
18+
></p> <!-- TODO: multiline -->
1619

1720
<v-tabs>
1821
<v-tab

src/layouts/LayoutClassroomTeacher.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212

1313
<h1 v-text="classroom.name"></h1>
1414
<v-divider></v-divider>
15-
<p v-text="classroom.description"></p> <!-- TODO: multiline -->
15+
<p
16+
class="mt-5"
17+
v-text="classroom.description"
18+
></p> <!-- TODO: multiline -->
1619

1720
<v-tabs>
1821
<v-tab

src/store/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Vuex from 'vuex'
33
import { account } from './account'
44
import { classroom } from './classroom'
55
import { readingExercise } from './reading-exercises'
6+
import { readingReport } from './reading-reports'
67

78
Vue.use(Vuex)
89

@@ -20,6 +21,7 @@ export default new Vuex.Store({
2021
modules: {
2122
account,
2223
classroom,
23-
readingExercise
24+
readingExercise,
25+
readingReport
2426
}
2527
})

src/store/reading-reports.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Api } from '@/api'
2+
import { Classroom, ReadingExerciseReport } from '@/interfaces/classroom'
3+
import { ReadingExercise } from '@/interfaces/reading-exercise'
4+
import { User } from '@/interfaces/user'
5+
import { Module } from 'vuex'
6+
import { RootState } from './index'
7+
8+
declare interface ReadingReportState {
9+
reports: ReadingExerciseReport[];
10+
currentReport?: ReadingExerciseReport;
11+
}
12+
13+
export const readingReport: Module<ReadingReportState, RootState> = {
14+
namespaced: true,
15+
16+
state: {
17+
reports: [],
18+
currentReport: undefined
19+
},
20+
21+
mutations: {
22+
SET_REPORTS (state, reports) {
23+
state.reports = reports
24+
},
25+
26+
SET_CURRENT_REPORT (state, exerciseID: ReadingExercise['identifier']) {
27+
state.currentReport = state.reports.find(report => report.exercise === exerciseID)
28+
}
29+
},
30+
31+
actions: {
32+
async getReports (
33+
{ commit },
34+
{ classroomPk, studentPk }: { classroomPk: Classroom['pk'], studentPk: User['pk'] }
35+
): Promise<void> {
36+
const data = await Api.classroom.getStudentReport(classroomPk, studentPk)
37+
commit('SET_REPORTS', data)
38+
}
39+
}
40+
}

src/views/classroom/ClassroomExercisesReadingStudent.vue

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,52 @@
11
<template>
22
<div>
3-
<p v-if="exercises.length === 0">
3+
<v-progress-circular
4+
v-if="loading"
5+
indeterminate
6+
color="primary"
7+
></v-progress-circular>
8+
9+
<p v-else-if="reports.length === 0">
410
This classroom don't have any reading exercises. Perhaps your teacher forgot to add them?
511
</p>
612

713
<div v-else>
8-
<p>Click on an exercise to start doing.</p>
9-
1014
<v-simple-table>
1115
<thead>
1216
<tr>
13-
<td>Exercise</td>
14-
<td>Passage 1</td>
15-
<td>Passage 2</td>
16-
<td>Passage 3</td>
17-
<td>Total</td>
18-
<td>Band score</td>
17+
<th>Exercise</th>
18+
<th>Passage 1</th>
19+
<th>Passage 2</th>
20+
<th>Passage 3</th>
21+
<th>Total</th>
22+
<th>Band score</th>
23+
<th></th>
1924
</tr>
2025
</thead>
2126
<tbody>
2227
<tr
23-
v-for="exercise of exercises"
24-
:key="exercise.pk"
28+
v-for="report of reports"
29+
:key="report.pk"
2530
>
26-
<td>{{ exercise.identifier }}</td>
31+
<td>{{ report.exercise }}</td>
32+
<template v-if="!report.submitted">
33+
<td colspan="5">
34+
Not submitted
35+
</td>
36+
<td class="text-center">
37+
Start
38+
</td>
39+
</template>
40+
<template v-else>
41+
<td>{{ report.passage_1_total }}</td>
42+
<td>{{ report.passage_2_total }}</td>
43+
<td>{{ report.passage_3_total }}</td>
44+
<td>{{ report.total }}</td>
45+
<td>{{ report.band_score }}</td>
46+
<td class="text-center">
47+
Detail
48+
</td>
49+
</template>
2750
</tr>
2851
</tbody>
2952
</v-simple-table>
@@ -32,24 +55,45 @@
3255
</template>
3356

3457
<script lang="ts">
35-
import { Classroom } from '@/interfaces/classroom'
36-
import { ClassroomReadingExercise } from '@/interfaces/reading-exercise'
58+
import { Classroom, ReadingExerciseReport } from '@/interfaces/classroom'
59+
import { User } from '@/interfaces/user'
60+
import { unexpectedExc } from '@/utils'
3761
import { Vue, Component } from 'vue-property-decorator'
3862
import { mapState } from 'vuex'
3963
4064
@Component({
4165
computed: {
66+
...mapState('account', {
67+
user: 'loggedInUser'
68+
}),
4269
...mapState('classroom', {
4370
classroom: 'currentClassroom'
44-
})
71+
}),
72+
...mapState('readingReport', [
73+
'reports'
74+
])
4575
}
4676
})
4777
export default class ClassroomExercisesReadingStudent extends Vue {
78+
user!: User
4879
classroom!: Classroom
80+
reports!: ReadingExerciseReport[]
81+
82+
loading = false
83+
84+
created (): void {
85+
this.loading = true
86+
87+
const payload = {
88+
classroomPk: this.classroom.pk,
89+
studentPk: this.user.pk
90+
}
4991
50-
get exercises (): ClassroomReadingExercise[] {
51-
if (this.classroom === undefined) return []
52-
return this.classroom.reading_exercises
92+
this.$store.dispatch('readingReport/getReports', payload)
93+
.catch(unexpectedExc)
94+
.finally(() => {
95+
this.loading = false
96+
})
5397
}
5498
}
5599
</script>

0 commit comments

Comments
 (0)