Skip to content

Commit de511d2

Browse files
report result
1 parent d51b422 commit de511d2

File tree

10 files changed

+233
-90
lines changed

10 files changed

+233
-90
lines changed

src/api/classroom.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Vue from 'vue'
2-
import { ClassroomListRes, ClassroomDetailRes, ClassroomCreateReq, AddStudentReq, RemoveStudentReq, AddReadingExercisesReq, RemoveReadingExercisesReq, ReadingExerciseReportRes } from '@/interfaces/api/classroom'
2+
import { ClassroomListRes, ClassroomDetailRes, ClassroomCreateReq, AddStudentReq, RemoveStudentReq, AddReadingExercisesReq, RemoveReadingExercisesReq, ReadingExerciseReportRes, GetStudentReportReq } from '@/interfaces/api/classroom'
33
import { Classroom } from '@/interfaces/classroom'
44
import { endpoints, replacePk } from './endpoints'
5-
import { User } from '@/interfaces/user'
65

76
export const classroom = {
87
async list (): Promise<ClassroomListRes> {
@@ -41,13 +40,9 @@ export const classroom = {
4140
await Vue.axios.post(endpoint, payload)
4241
},
4342

44-
async getStudentReport (classroomPk: Classroom['pk'], studentPk: User['pk']): Promise<ReadingExerciseReportRes[]> {
43+
async getStudentReport (classroomPk: Classroom['pk'], params: GetStudentReportReq): Promise<ReadingExerciseReportRes[]> {
4544
const endpoint = replacePk(endpoints.classroom.studentReadingReport, classroomPk)
46-
const res = await Vue.axios.get(endpoint, {
47-
params: {
48-
student: studentPk
49-
}
50-
})
45+
const res = await Vue.axios.get(endpoint, { params })
5146
return res.data
5247
}
5348
}

src/interfaces/api/classroom.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ export declare interface RemoveReadingExercisesReq {
3131
}
3232

3333
export declare interface ReadingExerciseReportRes extends ReadingExerciseReport {}
34+
35+
export declare interface GetStudentReportReq {
36+
student_pk: number;
37+
exercise_pk?: number;
38+
show_detail?: boolean;
39+
}

src/interfaces/classroom.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ export declare interface Classroom {
1212
}
1313

1414

15+
declare interface _ReadingExercise {
16+
pk: number;
17+
url: string;
18+
identifier: string;
19+
}
20+
1521
export declare interface ReadingSubmissionResult {
1622
question_number: number;
1723
submitted_answer: string;
1824
possible_answers: string[];
1925
is_correct: boolean;
2026
}
2127

22-
declare interface _ReadingExercise {
23-
pk: number;
24-
url: string;
25-
identifier: string;
26-
}
27-
2828
export declare interface ReadingExerciseReport {
2929
exercise: _ReadingExercise;
3030
passage_1_total: number;
@@ -33,7 +33,7 @@ export declare interface ReadingExerciseReport {
3333
total: number;
3434
band_score: number;
3535
submitted: boolean;
36-
passage_1_detail: ReadingSubmissionResult[];
37-
passage_2_detail: ReadingSubmissionResult[];
38-
passage_3_detail: ReadingSubmissionResult[];
36+
passage_1_detail?: ReadingSubmissionResult[];
37+
passage_2_detail?: ReadingSubmissionResult[];
38+
passage_3_detail?: ReadingSubmissionResult[];
3939
}

src/router/index.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import ReadingExerciseDetail from '../views/reading-exercise/ReadingExerciseDeta
2121
import ReadingExerciseCreate from '../views/reading-exercise/ReadingExerciseCreate.vue'
2222
import ReadingExerciseUpdate from '../views/reading-exercise/ReadingExerciseUpdate.vue'
2323
import ReadingExerciseEditAnswers from '../views/reading-exercise/ReadingExerciseEditAnswers.vue'
24-
import ReadingExerciseSubmit from '../views/reading-exercise/ReadingExerciseSubmit.vue'
24+
import ReadingExerciseSubmit from '../views/classroom/ReadingExerciseSubmit.vue'
25+
import ReadingExerciseSubmitResult from '../views/classroom/ReadingExerciseSubmitResult.vue'
2526

2627
import { castToNumber, prefixWith } from './utils'
2728

@@ -56,7 +57,7 @@ const routes: Array<RouteConfig> = [
5657
path: '/:pk/overview',
5758
name: 'ClassroomOverview',
5859
component: ClassroomOverview,
59-
props: castToNumber('pk'),
60+
props: castToNumber(['pk']),
6061
meta: {
6162
teacherLayout: LayoutClassroomTeacher,
6263
studentLayout: LayoutClassroomStudent
@@ -66,7 +67,7 @@ const routes: Array<RouteConfig> = [
6667
path: '/:pk/students',
6768
name: 'ClassroomStudents',
6869
component: ClassroomStudents,
69-
props: castToNumber('pk'),
70+
props: castToNumber(['pk']),
7071
meta: {
7172
teacherLayout: LayoutClassroomTeacher,
7273
studentLayout: LayoutClassroomStudent
@@ -76,17 +77,29 @@ const routes: Array<RouteConfig> = [
7677
path: '/:pk/reading-exercises',
7778
name: 'ClassroomExercisesReading',
7879
component: ClassroomExercisesReading,
79-
props: castToNumber('pk'),
80+
props: castToNumber(['pk']),
8081
meta: {
8182
teacherLayout: LayoutClassroomTeacher,
8283
studentLayout: LayoutClassroomStudent
8384
}
8485
},
86+
{
87+
path: '/:pk/reading-exercises/:exercisePk/submit',
88+
name: 'ReadingExerciseSubmit',
89+
component: ReadingExerciseSubmit,
90+
props: castToNumber(['pk', 'exercisePk'])
91+
},
92+
{
93+
path: '/:pk/reading-exercises/:exercisePk/result',
94+
name: 'ReadingExerciseSubmitResult',
95+
component: ReadingExerciseSubmitResult,
96+
props: castToNumber(['pk', 'exercisePk'])
97+
},
8598
{
8699
path: '/:pk/listening-exercises',
87100
name: 'ClassroomExercisesListening',
88101
component: ClassroomExercisesListening,
89-
props: castToNumber('pk'),
102+
props: castToNumber(['pk']),
90103
meta: {
91104
teacherLayout: LayoutClassroomTeacher,
92105
studentLayout: LayoutClassroomStudent
@@ -108,25 +121,19 @@ const routes: Array<RouteConfig> = [
108121
path: '/:pk/update',
109122
name: 'ReadingExerciseUpdate',
110123
component: ReadingExerciseUpdate,
111-
props: castToNumber('pk')
124+
props: castToNumber(['pk'])
112125
},
113126
{
114127
path: '/:pk/edit-answers',
115128
name: 'ReadingExerciseEditAnswers',
116129
component: ReadingExerciseEditAnswers,
117-
props: castToNumber('pk')
118-
},
119-
{
120-
path: '/:pk/submit',
121-
name: 'ReadingExerciseSubmit',
122-
component: ReadingExerciseSubmit,
123-
props: castToNumber('pk')
130+
props: castToNumber(['pk'])
124131
},
125132
{
126133
path: '/:pk',
127134
name: 'ReadingExerciseDetail',
128135
component: ReadingExerciseDetail,
129-
props: castToNumber('pk')
136+
props: castToNumber(['pk'])
130137
}
131138
]),
132139
{

src/router/utils.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ export function prefixWith (prefix: string, routeConfigs: Array<RouteConfig>): A
77
})
88
}
99

10-
export function castToNumber (prop: string): RoutePropsFunction {
10+
export function castToNumber (args: string[]): RoutePropsFunction {
1111
function _castToNumber (route: Route) {
12-
const propVal = route.params[prop]
13-
const propValCasted = parseInt(propVal)
14-
const props = { [prop]: propValCasted }
12+
const props = {}
13+
for (const prop of args) {
14+
const propVal = route.params[prop]
15+
const propValCasted = parseInt(propVal)
16+
// @ts-expect-error don't care
17+
props[prop] = propValCasted
18+
}
1519
return props
1620
}
1721
return _castToNumber

src/store/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ 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'
76

87
Vue.use(Vuex)
98

@@ -21,7 +20,6 @@ export default new Vuex.Store({
2120
modules: {
2221
account,
2322
classroom,
24-
readingExercise,
25-
readingReport
23+
readingExercise
2624
}
2725
})

src/store/reading-reports.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/views/classroom/ClassroomExercisesReadingStudent.vue

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
<router-link
3838
:to="{
3939
name: 'ReadingExerciseSubmit',
40-
params: { pk: report.exercise.pk }
40+
params: {
41+
pk: classroom.pk,
42+
exercisePk: report.exercise.pk
43+
}
4144
}"
4245
>
4346
Start
@@ -51,7 +54,17 @@
5154
<td>{{ report.total }}</td>
5255
<td>{{ report.band_score }}</td>
5356
<td class="text-center">
54-
Detail
57+
<router-link
58+
:to="{
59+
name: 'ReadingExerciseSubmitResult',
60+
params: {
61+
pk: classroom.pk,
62+
exercisePk: report.exercise.pk
63+
}
64+
}"
65+
>
66+
Detail
67+
</router-link>
5568
</td>
5669
</template>
5770
</tr>
@@ -62,6 +75,8 @@
6275
</template>
6376

6477
<script lang="ts">
78+
import { Api } from '@/api'
79+
import { GetStudentReportReq } from '@/interfaces/api/classroom'
6580
import { Classroom, ReadingExerciseReport } from '@/interfaces/classroom'
6681
import { User } from '@/interfaces/user'
6782
import { unexpectedExc } from '@/utils'
@@ -75,28 +90,28 @@ import { mapState } from 'vuex'
7590
}),
7691
...mapState('classroom', {
7792
classroom: 'currentClassroom'
78-
}),
79-
...mapState('readingReport', [
80-
'reports'
81-
])
93+
})
8294
}
8395
})
8496
export default class ClassroomExercisesReadingStudent extends Vue {
8597
user!: User
8698
classroom!: Classroom
87-
reports!: ReadingExerciseReport[]
99+
reports: ReadingExerciseReport[] = []
88100
89101
loading = false
90102
91103
created (): void {
92104
this.loading = true
93105
94-
const payload = {
95-
classroomPk: this.classroom.pk,
96-
studentPk: this.user.pk
106+
const params: GetStudentReportReq = {
107+
student_pk: this.user.pk,
108+
show_detail: false
97109
}
98110
99-
this.$store.dispatch('readingReport/getReports', payload)
111+
Api.classroom.getStudentReport(this.classroom.pk, params)
112+
.then(data => {
113+
this.reports = data
114+
})
100115
.catch(unexpectedExc)
101116
.finally(() => {
102117
this.loading = false

src/views/reading-exercise/ReadingExerciseSubmit.vue renamed to src/views/classroom/ReadingExerciseSubmit.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ import { mapState } from 'vuex'
126126
})
127127
export default class ReadingExerciseSubmit extends Vue {
128128
@Prop(Number) readonly pk!: number
129+
@Prop(Number) readonly exercisePk!: number
129130
130131
async created (): Promise<void> {
131132
await this.setQuestions()
@@ -143,7 +144,7 @@ export default class ReadingExerciseSubmit extends Vue {
143144
this.loading = true
144145
145146
try {
146-
await this.$store.dispatch('readingExercise/detail', this.pk)
147+
await this.$store.dispatch('readingExercise/detail', this.exercisePk)
147148
await this.$store.dispatch('readingExercise/getQuestions')
148149
} catch (error) {
149150
unexpectedExc(error)
@@ -220,6 +221,13 @@ export default class ReadingExerciseSubmit extends Vue {
220221
.finally(() => {
221222
this.confirmSubmit = false
222223
this.loadingSubmit = false
224+
this.$router.push({
225+
name: 'ReadingExerciseSubmitResult',
226+
params: {
227+
pk: this.pk.toString(),
228+
exercisePk: this.exercisePk.toString()
229+
}
230+
})
223231
})
224232
}
225233
}

0 commit comments

Comments
 (0)