Ver código fonte

fix: 修复eval题目数量无法显示bug

yhd12345 3 anos atrás
pai
commit
d4b41ab0b4
2 arquivos alterados com 42 adições e 18 exclusões
  1. 5 0
      src/api/eval.js
  2. 37 18
      src/views/EvalPage/studentExamDetails.vue

+ 5 - 0
src/api/eval.js

@@ -40,6 +40,10 @@ function getExamQuestions(examId) {
   return axios.get(`${prefix}/exam/${examId}/questions`);
 }
 
+function getExamCodeQuestions(examId){
+  return axios.get(`${prefix}/exam/${examId}/codeQuestions`);
+}
+
 function getSamplePaper() {
   return axios.get(`${prefix}/exam/sample`);
 }
@@ -122,6 +126,7 @@ const evalAPIs = {
   getStudentEvalExamsByCourseId,
   createEvalExam,
   getExamQuestions,
+  getExamCodeQuestions,
   getSamplePaper,
   getQuestionInfo,
   setExamPaperFromSample,

+ 37 - 18
src/views/EvalPage/studentExamDetails.vue

@@ -50,7 +50,7 @@
             </el-button>
           </div>
         </template>
-        <el-row>评测ID: {{ examInfo.examId }}</el-row>
+        <el-row>评测ID: {{ examId }}</el-row>
         <el-row>
           <el-col :span="12">
             所属课程: {{ courseInfo.name }}
@@ -117,7 +117,7 @@ export default {
       examCodeQuestionsNum: 0,
       inviteCode: "",
       examList: [],
-      totalNum: 0
+      totalNum: 0,
     };
   },
 
@@ -159,12 +159,41 @@ export default {
         this.examInfo.skills = this.examInfo.skills.toString();
         this.courseInfo = this.examInfo.course;
       });
+
+      this.$apis.getExamQuestions(this.examId).then(({data}) => {
+        if(!!data.data.result) {
+          this.examQuestionsNum = Object.keys(
+              data.data.result.questionAndScore
+          ).length;
+        }
+        this.$apis.getExamCodeQuestions(this.examId).then(({data}) => {
+          this.examCodeQuestionsNum = data.data.result.length;
+        });
+      });
+    },
+
+    getExamState() {
+      const curUserId = this.$store.state.user.id;
+      let userLists = [];
+      this.$apis.getExamJoinedUsers(this.examId).then(({data}) =>{
+        userLists = data.data.result;
+        if(!!userLists){
+          userLists.forEach((item) => {
+            if(item.id === curUserId) {
+              this.isJoined = true;
+            }
+          });
+        }
+      });
+
+      this.$apis.getExamSubmitRecordsByUserId(this.examId).then(({data}) => {
+        this.isFinished = !!data.data.result.find((val) => !val.message);
+      });
     },
 
     onJoinExam() {
       if (this.examInfo.isPublic) {
-        const examId = this.examInfo.examId ?? 0;
-        this.$apis.joinPublicExam(examId).then(() => {
+        this.$apis.joinPublicExam(this.examId).then(() => {
           this.isJoined = true;
           console.log(this.examInfo);
           ElMessage({
@@ -179,9 +208,8 @@ export default {
     },
 
     joinExamByInviteCode() {
-      const examId = this.examInfo.examId ?? 0;
       const inviteCode = this.inviteCode;
-      this.$apis.joinExamByInviteCode(inviteCode, examId)
+      this.$apis.joinExamByInviteCode(inviteCode, this.examId)
           .then(() => {
             this.inputInviteCode = false;
             this.isJoined = true;
@@ -199,12 +227,12 @@ export default {
     },
 
     onStartExam() {
-      const examId = this.examInfo.examId?.toString();
+      const examId = this.examId?.toString();
       const url = "https://eval.seec.seecoder.cn/exam/" + examId + "/before-exam";
       window.open(url + "?id_token=" + this.$store.state.user.token);
     },
     onOpenResult() {
-      const examId = this.examInfo.examId?.toString() ?? "";
+      const examId = this.examId?.toString() ?? "";
       const url = "https://eval.seec.seecoder.cn/student/result/" + examId;
       window.open(url + "?id_token=" + this.$store.state.user.token);
     },
@@ -216,16 +244,7 @@ export default {
   },
 
   mounted() {
-    this.$apis.getExamJoinedUsers(this.examId).then(({data}) =>{
-      let curUserId = this.$store.state.user.id;
-      let userLists = data.data.result;
-      userLists.forEach((item) => {
-        if(item.id === curUserId) this.isJoined = true;
-      });
-    });
-    this.$apis.getExamSubmitRecordsByUserId(this.examId).then(({data}) => {
-      this.isFinished = !!data.data.result.find((val) => !val.message);
-    });
+    this.getExamState();
   },