Explorar el Código

fix: 调用新接口判断是否参与考试

weijin hace 4 años
padre
commit
48cd6e2c7f

+ 9 - 0
src/api/record.ts

@@ -12,6 +12,15 @@ export const getExamQuestionSubmitRecord = (examId: ID, questionId: ID) => {
     `${RECORD_MODULE}?examId=${examId}&questionId=${questionId}`
   )
 }
+/**
+ * 获得某一考试某个用户的提交记录
+ * @param examId
+ */
+export const getExamSubmitRecordsByUserId = (examId: ID) => {
+  return axios.get<ReceivedData<Array<ExamQuestionSubmitRecord>>>(
+    `${RECORD_MODULE}/all?examId=${examId}`
+  )
+}
 /**
  * 获得考试所有题目的提交记录
  * @param examId

+ 2 - 2
src/views/components/ExamQuestionsInfo.vue

@@ -55,7 +55,7 @@
 import Vue, { PropType } from 'vue'
 import { TeacherQuestionSerializer, OptionSerializer, ID } from '@/api/types'
 import MarkdownText from '@/views/exam/components/MarkdownText.vue'
-import { getExamSubmitRecords } from '@/api/record'
+import { getExamSubmitRecordsByUserId } from '@/api/record'
 
 export default Vue.extend({
   name: 'ExamQuestionsInfo',
@@ -95,7 +95,7 @@ export default Vue.extend({
     },
     async fetchAnswers() {
       const examId = this.$route.params.examId
-      getExamSubmitRecords(examId).then(({ data }) => {
+      getExamSubmitRecordsByUserId(examId).then(({ data }) => {
         let records = data.result
         if (records && records.length > 0) {
           this.submitAnswers = new Map()

+ 3 - 3
src/views/exam/ExamPane.vue

@@ -251,7 +251,7 @@ import { objectiveJudge } from '@/api/judge'
 import dayjs from 'dayjs'
 import { TIME_FORMAT } from '@/utils/common'
 import { mapGetters, mapMutations } from 'vuex'
-import { getExamSubmitRecords } from '@/api/record'
+import { getExamSubmitRecordsByUserId } from '@/api/record'
 
 export default Vue.extend({
   name: 'ExamPane',
@@ -404,7 +404,7 @@ export default Vue.extend({
       this.examId = this.$route.params.examId
 
       // 提交过客观题,说明已经交卷
-      getExamSubmitRecords(this.examId).then(({ data }) => {
+      getExamSubmitRecordsByUserId(this.examId).then(({ data }) => {
         if (data.result.find((val) => !val.message)) {
           this.reenter = true
           setTimeout(() => {
@@ -471,7 +471,7 @@ export default Vue.extend({
                   this.fetchQuestionStem(0)
                 }
 
-                getExamSubmitRecords(this.examId).then(({ data }) => {
+                getExamSubmitRecordsByUserId(this.examId).then(({ data }) => {
                   if (data.result.find((val) => val.message)) {
                     // 提交过代码题,表示已经做完客观题
                     this.currentQuestionIndex = this.codeQuestionStartIndex

+ 1 - 1
src/views/student/components/StudentExamInfoCard.vue

@@ -42,7 +42,7 @@
           color="primary"
           class="mx-2"
         >
-          <template>已经加入</template>
+          <template>等待加入</template>
         </v-btn>
         <v-btn
           v-if="examInfo.isJoined && state === '进行中'"