|
|
@@ -45,7 +45,7 @@
|
|
|
<script lang="ts">
|
|
|
import Vue from 'vue'
|
|
|
import PageHeader from '@/views/components/PageHeader.vue'
|
|
|
-import { getExamsByStudentId } from '@/api/exam'
|
|
|
+import { getExamQuestions, getExamsByStudentId } from '@/api/exam'
|
|
|
import { ExamSerializer, ExamState } from '@/api/types'
|
|
|
import StudentExamInfoCard from '@/views/student/components/StudentExamInfoCard.vue'
|
|
|
import { getExamSubmitRecordsByUserId } from '@/api/record'
|
|
|
@@ -78,7 +78,8 @@ export default Vue.extend({
|
|
|
}
|
|
|
],
|
|
|
examList: [] as Array<ExamSerializer>,
|
|
|
- fetching: false
|
|
|
+ fetching: false,
|
|
|
+ examQuestionsNum: 0
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -109,8 +110,18 @@ export default Vue.extend({
|
|
|
const that = this
|
|
|
this.examList.forEach(function(exam) {
|
|
|
if (exam.examId) {
|
|
|
+ getExamQuestions(exam.examId)
|
|
|
+ .then(({ data }) => {
|
|
|
+ that.examQuestionsNum = Object.keys(
|
|
|
+ data.result.questionAndScore
|
|
|
+ ).length
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
getExamSubmitRecordsByUserId(exam.examId).then(({ data }) => {
|
|
|
- if (data.result.length >= exam.examCount) {
|
|
|
+ if (
|
|
|
+ data.result.length / that.examQuestionsNum >=
|
|
|
+ exam.examCount
|
|
|
+ ) {
|
|
|
that.$set(exam, 'isFinished', true)
|
|
|
}
|
|
|
// if (data.result.find((val) => !val.message)) {
|