소스 검색

修复判断题; 填空题; 简答题

Michael Wang 6 년 전
부모
커밋
43c922fa81

+ 1 - 1
src/features/OnlineExam/Examing/BooleanQuestionView.vue

@@ -3,7 +3,7 @@
     <question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
     <div class="ops">
       <div class="stu-answer">{{studentAnswer}}</div>
-      <div class="score">({{question.questionScore}}分)</div>
+      <div class="score">({{examQuestion.questionScore}}分)</div>
     </div>
     <div @click="() => answerQuestion('正确')">
       <input type="radio" name="question" value="正确" :checked="studentAnswer === '正确'" />

+ 15 - 6
src/features/OnlineExam/Examing/FillBlankQuestionView.vue

@@ -2,14 +2,14 @@
   <div class="question-view">
     <question-body :questionBody="questionBody" :examQuestionId="examQuestion.id"></question-body>
     <div class="ops">
-      <div class="score">({{question.questionScore}}分)</div>
+      <div class="score">({{examQuestion.questionScore}}分)</div>
     </div>
     <div v-for="(option, index) in studentAnswer.split('##')" :key="examQuestion.id + index" class="option">
       <span class="question-options">{{index+1}}. </span>
       <input type="text" name="question" class="input-answer" :value="option" @input="inputAnswer" @blur="submitAnswer" />
     </div>
       <div class="reset">
-        <i-button type="warning" size="large" @click="() => answerQuestion(examQuestion.id, null)">重置答案</i-button>
+        <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
       </div>
     </div>
 </template>
@@ -67,11 +67,20 @@ export default {
           "</span>"
       );
     },
-    async answerQuestion(examQuestionId, studentAnswer) {
-      await this.$http.put("/api/exam_question/" + examQuestionId, {
+    async answerQuestion(studentAnswer) {
+      await this.$http.post(
+        "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
+        [
+          {
+            order: this.examQuestion.order,
+            studentAnswer: studentAnswer
+          }
+        ]
+      );
+      this.updateExamQuestion({
+        order: this.$route.params.order,
         studentAnswer
       });
-      this.updateExamQuestion({ examQuestionId, studentAnswer });
     },
     inputAnswer: function() {
       const questionNumber = this.question.body.split(/_{5,}/).length - 1;
@@ -92,7 +101,7 @@ export default {
     submitAnswer() {
       const realAnswer = this.studentAnswer.replace(/##/g, "").trim() || null;
       if (realAnswer !== this.examQuestion.studentAnswer) {
-        this.answerQuestion(this.examQuestion.id, realAnswer);
+        this.answerQuestion(realAnswer);
       }
     }
   },

+ 1 - 1
src/features/OnlineExam/Examing/MultipleQuestionView.vue

@@ -3,7 +3,7 @@
     <question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
     <div class="ops">
       <div class="stu-answer"> {{studentAnswer}}</div>
-      <div class="score">({{question.questionScore}}分)</div>
+      <div class="score">({{examQuestion.questionScore}}分)</div>
     </div>
     <div v-for="(option, index) in question.questionOptionList" :key="option.id" class="option" @click="toggleAnswer(index)">
       <input type="checkbox" name="question" value="optionName[index]" :checked="studentAnswer && studentAnswer.includes(optionName[index])" />

+ 2 - 2
src/features/OnlineExam/Examing/QuestionView.vue

@@ -12,10 +12,10 @@
     <template v-if="question.questionType === 'TRUE_OR_FALSE'">
       <boolean-question-view :question="question" :examQuestion="examQuestion" />
     </template>
-    <template v-if="question.questionType === 'FILL_BLANK_QUESTION'">
+    <template v-if="question.questionType === 'FILL_UP'">
       <fill-blank-question-view :question="question" :examQuestion="examQuestion" />
     </template>
-    <template v-if="question.questionType === 'TEXT_ANSWER_QUESTION'">
+    <template v-if="question.questionType === 'ESSAY'">
       <text-question-view :question="question" :examQuestion="examQuestion" />
     </template>
     <template v-if="examQuestion.parentQuestion">

+ 30 - 12
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -2,19 +2,21 @@
   <div class="question-view">
     <question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
     <div class="ops">
-      <div class="score">({{question.questionScore}}分)</div>
+      <div class="score">({{examQuestion.questionScore}}分)</div>
     </div>
     <div class="option">
-      <textarea v-model="studentAnswer" class="stu-answer" type="text" />
+      <textarea v-model="studentAnswer" class="stu-answer" @blur="answerQuestion" type="text" />
       </div>
     <div class="reset">
-      <i-button type="warning" size="large" @click="resetQuestion(examQuestion.id)">重置答案</i-button>
+      <i-button type="warning" size="large" @click="() => this.answerQuestion(null)">重置答案</i-button>
     </div>
   </div>
 </template>
 
 <script>
 import QuestionBody from "./QuestionBody";
+import { createNamespacedHelpers } from "vuex";
+const { mapMutations } = createNamespacedHelpers("examingHomeModule");
 
 export default {
   name: "TextQuestionView",
@@ -28,18 +30,34 @@ export default {
     examQuestion: Object
   },
   methods: {
-    answerQuestion: function(examQuestionId) {
-      this.$http.put("/api/exam_question/" + examQuestionId, {
-        studentAnswer: this.studentAnswer
-      });
-    },
-    resetQuestion: function(examQuestionId) {
-      this.studentAnswer = null;
-      this.$http.put("/api/exam_question/" + examQuestionId, {
-        studentAnswer: null
+    ...mapMutations(["updateExamQuestion"]),
+    async answerQuestion(reset) {
+      console.log(this.studentAnswer);
+      if (reset === null) {
+        this.studentAnswer = null;
+      }
+      const order = this.examQuestion.order;
+      const studentAnswer = this.studentAnswer;
+      await this.$http.post(
+        "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
+        [
+          {
+            order: order,
+            studentAnswer: studentAnswer
+          }
+        ]
+      );
+      this.updateExamQuestion({
+        order: order,
+        studentAnswer: studentAnswer
       });
     }
   },
+  watch: {
+    examQuestion(cur, prev) {
+      this.studentAnswer = this.examQuestion.studentAnswer;
+    }
+  },
   components: {
     QuestionBody
   }

+ 21 - 13
src/features/OnlinePractice/OnlinePracticeHome.vue

@@ -7,9 +7,12 @@
 
     <div class="home">
 
-      选择考试批次:<Select v-model="examId" style="width:200px" @on-change="fetchList">
-        <Option v-for="item in examList" :value="item.id" :key="item.id">{{ item.name }}</Option>
-      </Select>
+      <div style="text-align: left; margin-bottom: 20px;">
+        选择考试批次:
+        <Select v-model="examId" style="width:200px" @on-change="fetchList">
+          <Option v-for="item in examList" :value="item.id" :key="item.id">{{ item.name }}</Option>
+        </Select>
+      </div>
 
       <i-table border :columns="columns" :data="courses"></i-table>
 
@@ -27,11 +30,7 @@ export default {
       columns: [
         {
           title: "课程",
-          key: "name"
-        },
-        {
-          title: "专业",
-          key: "specialtyName"
+          key: "courseName"
         },
         {
           title: "考试开放时间",
@@ -42,8 +41,16 @@ export default {
           }
         },
         {
-          title: "剩余考试次数",
-          key: "times"
+          title: "练习次数",
+          key: "practiceCount"
+        },
+        {
+          title: "最近正确率",
+          key: "recentObjectiveAccuracy"
+        },
+        {
+          title: "平均正确率",
+          key: "aveObjectiveAccuracy"
         },
         {
           title: "操作",
@@ -66,10 +73,11 @@ export default {
       );
 
       this.courses = res.data.map(c => ({
-        name: c.name,
-        specialtyName: c.specialtyName,
+        courseName: c.courseName,
         start2end: c.startTime + "<br> ~ <br>" + c.endTime,
-        times: c.allowExamCount,
+        practiceCount: c.practiceCount,
+        recentObjectiveAccuracy: c.recentObjectiveAccuracy + "%",
+        aveObjectiveAccuracy: c.aveObjectiveAccuracy + "%",
         operations: ""
       }));
     }