Prechádzať zdrojové kódy

练习-显示答案:判断题,填空题,简答题

Michael Wang 6 rokov pred
rodič
commit
f6e81e4259

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

@@ -15,6 +15,12 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
+      <span v-if="question.rightAnswer">
+        &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
+      </span>
+      <div v-if="question.rightAnswer && isShowAnswer">
+        正确答案:<div>{{{'true': '正确', 'false' : '错误'}[question.rightAnswer]}}</div>
+      </div>
     </div>
   </div>
 </template>
@@ -26,9 +32,11 @@ const { mapMutations } = createNamespacedHelpers("examingHomeModule");
 
 export default {
   name: "BooleanQuestionView",
-  // data() {
-  //   // return { studentAnswer: this.examQuestion.studentAnswer };
-  // },
+  data() {
+    return {
+      isShowAnswer: false
+    };
+  },
   props: {
     question: Object,
     examQuestion: Object
@@ -66,6 +74,9 @@ export default {
           studentAnswer
         });
       }
+    },
+    showAnswer() {
+      this.isShowAnswer = !this.isShowAnswer;
     }
   },
   watch: {

+ 33 - 2
src/features/OnlineExam/Examing/FillBlankQuestionView.vue

@@ -10,6 +10,12 @@
     </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="resetAnswer">重置答案</i-button>
+      <span v-if="question.rightAnswer">
+        &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
+      </span>
+      <div v-if="question.rightAnswer && isShowAnswer">
+        正确答案:<div v-html="rightAnswerTransform" class="right-answer-section"></div>
+      </div>
     </div>
   </div>
 </template>
@@ -25,7 +31,6 @@ const { mapMutations } = createNamespacedHelpers("examingHomeModule");
  * 3. 输入框失去焦点,提交答案
  * 4. 切换页面,this.studentAnswer从examQuestion获得数据
  *
- * FIXME: question没有更新。。。。
  * */
 
 export default {
@@ -33,7 +38,8 @@ export default {
   data() {
     return {
       studentAnswer: "",
-      questionBody: ""
+      questionBody: "",
+      isShowAnswer: false
     };
   },
   props: {
@@ -90,6 +96,9 @@ export default {
       });
       this.examQuestion.studentAnswer = null;
       this.prepareData();
+    },
+    showAnswer() {
+      this.isShowAnswer = !this.isShowAnswer;
     }
   },
   watch: {
@@ -120,6 +129,22 @@ export default {
   computed: {
     isSyncState() {
       return this.examQuestion.order == this.$route.params.order;
+    },
+    rightAnswerTransform() {
+      // if (
+      //   this.question.rightAnswer &&
+      //   !this.question.rightAnswer.join("").includes("##")
+      // ) {
+      //   return this.question.rightAnswer;
+      // }
+      return (
+        this.question.rightAnswer &&
+        this.question.rightAnswer
+          .join("")
+          .split("##")
+          .map((v, i) => `${i + 1}、${v}<br>`)
+          .join("")
+      );
     }
   },
   components: {
@@ -161,3 +186,9 @@ export default {
   padding-right: 10px;
 }
 </style>
+
+<style>
+div.right-answer-section > p {
+  display: inline;
+}
+</style>

+ 15 - 2
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -9,6 +9,12 @@
       </div>
     <div class="reset">
       <i-button type="warning" size="large" @click="studentAnswer=null">重置答案</i-button>
+            <span v-if="question.rightAnswer">
+        &nbsp;&nbsp;&nbsp;<i-button type="info" size="large" @click="showAnswer">显示答案</i-button>
+      </span>
+      <div v-if="question.rightAnswer && isShowAnswer">
+        正确答案:<div v-html="rightAnswerTransform"></div>
+      </div>
     </div>
   </div>
 </template>
@@ -22,7 +28,8 @@ export default {
   name: "TextQuestionView",
   data() {
     return {
-      studentAnswer: this.examQuestion.studentAnswer
+      studentAnswer: this.examQuestion.studentAnswer,
+      isShowAnswer: false
     };
   },
   props: {
@@ -30,7 +37,10 @@ export default {
     examQuestion: Object
   },
   methods: {
-    ...mapMutations(["updateExamQuestion"])
+    ...mapMutations(["updateExamQuestion"]),
+    showAnswer() {
+      this.isShowAnswer = !this.isShowAnswer;
+    }
   },
   watch: {
     examQuestion() {
@@ -56,6 +66,9 @@ export default {
   computed: {
     isSyncState() {
       return this.examQuestion.order == this.$route.params.order;
+    },
+    rightAnswerTransform() {
+      return this.question.rightAnswer.join("");
     }
   },
   components: {