feat(exam): 添加学生考试历史结果查看功能
- 新增接口获取指定学生的历史考试结果列表 - 数据库层新增根据学生ID查询历史考试记录的查询方法 - 服务层新增获取学生历史考试结果列表的实现 - 前端api新增调用学生考试历史接口的方法 - 学生详情页增加考试历史记录图表展示板块 - 新增考试历史折线图组件,展示正确词数和错误词数的时间变化 - 使用echarts实现折线图并支持点击显示详情 - 更新项目依赖,新增echarts库用于图表展示
This commit is contained in:
@@ -6,19 +6,27 @@
|
||||
</el-header>
|
||||
|
||||
<el-main class="p-4">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6" v-loading="loading">
|
||||
<div class="text-lg font-semibold mb-4">学生详情</div>
|
||||
<template v-if="detail">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="ID">{{ detail.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="姓名">{{ detail.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班级">{{ detail.className }}</el-descriptions-item>
|
||||
<el-descriptions-item label="年级">{{ detail.gradeName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-empty description="暂无数据" />
|
||||
</template>
|
||||
<div class="grid grid-cols-1 lg:grid-cols-1 gap-6"
|
||||
v-loading="loading">
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||
<div class="text-lg font-semibold mb-4">学生详情</div>
|
||||
<template v-if="detail">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="ID">{{ detail.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="姓名">{{ detail.name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="班级">{{ detail.className }}</el-descriptions-item>
|
||||
<el-descriptions-item label="年级">{{ detail.gradeName }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-empty description="请从班级页跳转" />
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
||||
<div class="text-md font-semibold mb-3">学生考试记录</div>
|
||||
<ExamHistoryChart :data="history" />
|
||||
</div>
|
||||
</div>
|
||||
</el-main>
|
||||
|
||||
@@ -31,10 +39,13 @@ import Header from '@/layouts/components/Header.vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { getStudentDetail } from '@/api/student'
|
||||
import { getStudentExamHistory } from '@/api/exam'
|
||||
import ExamHistoryChart from '@/layouts/components/student/ExamHistoryChart.vue'
|
||||
|
||||
const loading = ref(false)
|
||||
const detail = ref(null)
|
||||
const route = useRoute()
|
||||
const history = ref([])
|
||||
|
||||
async function fetchDetail() {
|
||||
const id = route.params.id
|
||||
@@ -49,7 +60,18 @@ async function fetchDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchExamHistory() {
|
||||
const id = route.params.id
|
||||
if (!id) return
|
||||
const res = await getStudentExamHistory(id)
|
||||
const d = res.data
|
||||
history.value = Array.isArray(d?.data) ? d.data.slice().sort((a, b) => {
|
||||
return new Date(a.startDate).getTime() - new Date(b.startDate).getTime()
|
||||
}) : []
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchDetail()
|
||||
fetchExamHistory()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user