|
|
@@ -41,7 +41,11 @@
|
|
|
<script lang="ts">
|
|
|
import Vue from 'vue'
|
|
|
import PageHeader from '@/views/components/PageHeader.vue'
|
|
|
-import { getAllExamList } from '@/api/exam'
|
|
|
+import {
|
|
|
+ getAllExamList,
|
|
|
+ getExamCodeQuestions,
|
|
|
+ getExamQuestions
|
|
|
+} from '@/api/exam'
|
|
|
import { ExamSerializer } from '@/api/types'
|
|
|
import StudentExamInfoCard from '@/views/student/components/StudentExamInfoCard.vue'
|
|
|
import { getExamSubmitRecordsByUserId } from '@/api/record'
|
|
|
@@ -76,7 +80,8 @@ export default Vue.extend({
|
|
|
inviteCode: '',
|
|
|
joinSuccess: false,
|
|
|
joinFailed: false,
|
|
|
- fetching: false
|
|
|
+ fetching: false,
|
|
|
+ examQuestionsNum: 0
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -105,10 +110,22 @@ 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 }) => {
|
|
|
//若用户提交次数大于等于考试允许次数 则设定为已完成
|
|
|
console.log(data.result)
|
|
|
- if (data.result.length >= exam.examCount) {
|
|
|
+ console.log(exam.examCount)
|
|
|
+ console.log(that.examQuestionsNum)
|
|
|
+ if (
|
|
|
+ data.result.length / that.examQuestionsNum >=
|
|
|
+ exam.examCount
|
|
|
+ ) {
|
|
|
that.$set(exam, 'isFinished', true)
|
|
|
} else {
|
|
|
that.$set(exam, 'isFinished', false)
|