Przeglądaj źródła

练习过程显示答案

Michael Wang 6 lat temu
rodzic
commit
39fbf1ad6d

+ 6 - 3
src/features/OnlineExam/Examing/BooleanQuestionView.vue

@@ -15,10 +15,10 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
-      <span v-if="question.rightAnswer">
+      <span v-if="examShouldShowAnswer()">
         &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
       </span>
-      <div v-if="question.rightAnswer && isShowAnswer">
+      <div v-if="examShouldShowAnswer() && isShowAnswer">
         正确答案:<div>{{{'true': '正确', 'false' : '错误'}[question.rightAnswer]}}</div>
       </div>
     </div>
@@ -28,7 +28,9 @@
 <script>
 import QuestionBody from "./QuestionBody";
 import { createNamespacedHelpers } from "vuex";
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
+const { mapMutations, mapGetters } = createNamespacedHelpers(
+  "examingHomeModule"
+);
 
 export default {
   name: "BooleanQuestionView",
@@ -49,6 +51,7 @@ export default {
   },
   methods: {
     ...mapMutations(["updateExamQuestion"]),
+    ...mapGetters(["examShouldShowAnswer"]),
     keyup(e) {
       // console.log(e);
       // console.log(document.activeElement.type);

+ 1 - 0
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -164,6 +164,7 @@ export default {
             `/PRACTICE_TYPE`
         )).data;
         this.practiceType = practiceType; // IN_PRACTICE NO_ANSWER
+        exam.practiceType = practiceType;
       }
 
       // init subNumber

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

@@ -10,10 +10,10 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="resetAnswer">重置答案</i-button>
-      <span v-if="question.rightAnswer">
+      <span v-if="examShouldShowAnswer()">
         &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
       </span>
-      <div v-if="question.rightAnswer && isShowAnswer">
+      <div v-if="examShouldShowAnswer() && isShowAnswer">
         正确答案:<div v-html="rightAnswerTransform" class="right-answer-section"></div>
       </div>
     </div>
@@ -23,7 +23,9 @@
 <script>
 import QuestionBody from "./QuestionBody";
 import { createNamespacedHelpers } from "vuex";
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
+const { mapMutations, mapGetters } = createNamespacedHelpers(
+  "examingHomeModule"
+);
 
 /**
  * 1. 进入页面,this.studentAnswer从examQuestion.studentAnswer获得数据
@@ -51,6 +53,7 @@ export default {
   },
   methods: {
     ...mapMutations(["updateExamQuestion"]),
+    ...mapGetters(["examShouldShowAnswer"]),
     prepareData() {
       const questionNumber = this.question.body.split(/_{5,}/).length - 1;
 

+ 6 - 3
src/features/OnlineExam/Examing/MultipleQuestionView.vue

@@ -12,10 +12,10 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
-      <span v-if="question.rightAnswer">
+      <span v-if="examShouldShowAnswer()">
         &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
       </span>
-      <div v-if="question.rightAnswer && isShowAnswer">
+      <div v-if="examShouldShowAnswer() && isShowAnswer">
         正确答案:<div>{{rightAnswerTransform}}</div>
       </div>
     </div>
@@ -25,7 +25,9 @@
 <script>
 import QuestionBody from "./QuestionBody";
 import { createNamespacedHelpers } from "vuex";
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
+const { mapMutations, mapGetters } = createNamespacedHelpers(
+  "examingHomeModule"
+);
 
 const optionName = "ABCDEF".split("");
 export default {
@@ -53,6 +55,7 @@ export default {
   },
   methods: {
     ...mapMutations(["updateExamQuestion"]),
+    ...mapGetters(["examShouldShowAnswer"]),
     keyup(e) {
       if (
         ["BODY", "A", "BUTTON", "DIV"].includes(

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

@@ -60,7 +60,7 @@ export default {
       const currentExamQuestion = this.examQuestion; // 避免以后执行时,this.examQuestion换掉了
       const res = await this.$http.get(
         "/api/ecs_oe_student/examQuestion/getQuestionContent?questionId=" +
-          this.examQuestion.questionId
+          currentExamQuestion.questionId
       );
 
       if (res.data === undefined) {

+ 6 - 3
src/features/OnlineExam/Examing/SingleQuestionView.vue

@@ -12,10 +12,10 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
-      <span v-if="question.rightAnswer">
+      <span v-if="examShouldShowAnswer()">
         &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
       </span>
-      <div v-if="question.rightAnswer && isShowAnswer">
+      <div v-if="examShouldShowAnswer() && isShowAnswer">
         正确答案:<div>{{rightAnswerTransform}}</div>
       </div>
     </div>
@@ -25,7 +25,9 @@
 <script>
 import QuestionBody from "./QuestionBody";
 import { createNamespacedHelpers } from "vuex";
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
+const { mapMutations, mapGetters } = createNamespacedHelpers(
+  "examingHomeModule"
+);
 
 const optionName = ["A", "B", "C", "D", "E", "F"];
 export default {
@@ -53,6 +55,7 @@ export default {
   },
   methods: {
     ...mapMutations(["updateExamQuestion"]),
+    ...mapGetters(["examShouldShowAnswer"]),
     keyup(e) {
       if (
         ["BODY", "A", "BUTTON", "DIV"].includes(

+ 6 - 3
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -9,10 +9,10 @@
       </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="studentAnswer=null">重置答案</i-button>
-            <span v-if="question.rightAnswer">
+      <span v-if="examShouldShowAnswer()">
         &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
       </span>
-      <div v-if="question.rightAnswer && isShowAnswer">
+      <div v-if="examShouldShowAnswer() && isShowAnswer">
         正确答案:<div v-html="rightAnswerTransform"></div>
       </div>
     </div>
@@ -22,7 +22,9 @@
 <script>
 import QuestionBody from "./QuestionBody";
 import { createNamespacedHelpers } from "vuex";
-const { mapMutations } = createNamespacedHelpers("examingHomeModule");
+const { mapMutations, mapGetters } = createNamespacedHelpers(
+  "examingHomeModule"
+);
 
 export default {
   name: "TextQuestionView",
@@ -38,6 +40,7 @@ export default {
   },
   methods: {
     ...mapMutations(["updateExamQuestion"]),
+    ...mapGetters(["examShouldShowAnswer"]),
     showAnswer() {
       this.isShowAnswer = !this.isShowAnswer;
     }

+ 8 - 1
src/store.js

@@ -81,7 +81,14 @@ const examingHomeModule = {
     }
   },
   actions: {},
-  getters: {}
+  getters: {
+    examShouldShowAnswer(state) {
+      if (state.exam && state.exam.practiceType === "IN_PRACTICE") {
+        return true;
+      }
+      return false;
+    }
+  }
 };
 
 const userStr = window.localStorage.getItem("user-for-reload");