Michael Wang 6 éve
szülő
commit
16185521e6

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

@@ -26,6 +26,9 @@ const { mapMutations } = createNamespacedHelpers("examingHomeModule");
 
 export default {
   name: "BooleanQuestionView",
+  data() {
+    return { studentAnswer: this.examQuestion.studentAnswer };
+  },
   props: {
     question: Object,
     examQuestion: Object
@@ -74,9 +77,12 @@ export default {
       }
     }
   },
-  computed: {
-    studentAnswer() {
-      return this.examQuestion.studentAnswer;
+  watch: {
+    examQuestion: function(examQuestion) {
+      this.studentAnswer = examQuestion.studentAnswer;
+    },
+    question(question) {
+      this.questionBody = question.body;
     }
   },
   components: {

+ 17 - 3
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -79,14 +79,28 @@ export default {
           this.$route.params.examRecordDataId
       );
 
-      const examQuestionList = await this.$http.get(
+      let examQuestionList = (await this.$http.get(
         "/api/ecs_oe_student/examQuestion/findExamQuestionList"
-      );
+      )).data;
+
+      // init subNumber
+      let questionId = null;
+      let i = 1;
+      examQuestionList = examQuestionList.map(eq => {
+        if (questionId == eq.questionId) {
+          eq.subNumber = i++;
+        } else {
+          i = 1;
+          questionId = eq.questionId;
+          eq.subNumber = i++;
+        }
+        return eq;
+      });
 
       this.updateExamState({
         exam: exam.data,
         paperStruct: paperStruct.data,
-        examQuestionList: examQuestionList.data
+        examQuestionList: examQuestionList
       });
     },
     updateQuestion: async function(next) {

+ 8 - 1
src/features/OnlineExam/Examing/FillBlankQuestionView.vue

@@ -99,7 +99,11 @@ export default {
       );
     },
     submitAnswer() {
-      const realAnswer = this.studentAnswer.replace(/##/g, "").trim() || null;
+      let realAnswer = null;
+      if (this.studentAnswer.replace(/##/g, "").trim()) {
+        // 如果有实际内容
+        realAnswer = this.studentAnswer;
+      }
       if (realAnswer !== this.examQuestion.studentAnswer) {
         this.answerQuestion(realAnswer);
       }
@@ -108,6 +112,9 @@ export default {
   watch: {
     examQuestion: function() {
       this.prepareData();
+    },
+    question(question) {
+      this.questionBody = question.body;
     }
   },
   components: {

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

@@ -43,8 +43,21 @@ export default {
       }
       let total = 0;
       for (var i = 0; i < section; i++) {
-        total += this.paperStruct.defaultPaper.questionGroupList[i]
-          .questionWrapperList.length;
+        // questionGroupList [
+        //   {
+        //     questionWrapperList [
+        //       questionUnitWrapperList [
+        //         question
+        //       ]
+        //     ]
+        //   }
+        // ]
+        total += this.paperStruct.defaultPaper.questionGroupList[
+          i
+        ].questionWrapperList.reduce((accumulator, questionWrapper) => {
+          // console.log(questionWrapper);
+          return accumulator + questionWrapper.questionUnitWrapperList.length;
+        }, 0);
       }
       // console.log(section, index, total + index);
       return this.examQuestionList[total + index];

+ 44 - 22
src/features/OnlineExam/Examing/QuestionView.vue

@@ -3,6 +3,10 @@
     <div class="sign-button">
       <Icon :type="examQuestion.isSign ? 'ios-star':'ios-star-outline'" :style="{color: '#ffcc00'}" class="star" @click="toggleSign" />
     </div>
+    <div v-if="parentQuestionBody" class="question-view">
+      <question-body :questionBody="parentQuestionBody" :examQuestionId="examQuestion.id" style="margin-bottom: 20px"></question-body>
+      <div class="hr" />
+    </div>
     <template v-if="question.questionType === 'SINGLE_CHOICE'">
       <single-question-view :question="question" :examQuestion="examQuestion" />
     </template>
@@ -18,13 +22,11 @@
     <template v-if="question.questionType === 'ESSAY'">
       <text-question-view :question="question" :examQuestion="examQuestion" />
     </template>
-    <template v-if="examQuestion.parentQuestion">
-      <nested-question-view :question="question" :examQuestion="examQuestion" />
-    </template>
   </div>
 </template>
 
 <script>
+import QuestionBody from "./QuestionBody";
 import SingleQuestionView from "./SingleQuestionView";
 import MultipleQuestionView from "./MultipleQuestionView";
 import BooleanQuestionView from "./BooleanQuestionView";
@@ -38,6 +40,7 @@ export default {
   name: "QuestionView",
   data() {
     return {
+      parentQuestionBody: null,
       question: null
     };
   },
@@ -74,19 +77,24 @@ export default {
               return "__" + parseInt(b) + "__";
             });
         }
+        // console.log(repQuestion);
       };
       const initQuestion = function(repQuestion) {
         if (
-          repQuestion.questionType === "SINGLE_ANSWER_QUESTION" ||
-          repQuestion.questionType === "MULTIPLE_ANSWER_QUESTION"
+          repQuestion.questionType === "SINGLE_CHOICE" ||
+          repQuestion.questionType === "MULTIPLE_CHOICE"
         ) {
-          for (var i = 0, imax = repQuestion.options.length; i < imax; i++) {
+          for (
+            var i = 0, imax = repQuestion.questionOptionList.length;
+            i < imax;
+            i++
+          ) {
             // repQuestion.options[i].content = $sce.trustAsHtml(
             //   repQuestion.options[i].content
             // );
           }
         }
-        if (repQuestion.questionType === "FILL_BLANK_QUESTION") {
+        if (repQuestion.questionType === "FILL_UP") {
           if (repQuestion.answer && repQuestion.answer.indexOf("##") > -1) {
             //优先使用##
             repQuestion.answerList = repQuestion.answer.split("##");
@@ -101,26 +109,35 @@ export default {
       //判断是否为套题
       if (question.body) {
         transferWellNumberAndTrustInBody(question);
-        for (var j = 0, jmax = question.subQuestionList.length; j < jmax; j++) {
-          initQuestion(question.subQuestionList[j]);
+        for (
+          var j = 0, jmax = question.questionUnitList.length;
+          j < jmax;
+          j++
+        ) {
+          initQuestion(question.questionUnitList[j]);
         }
         // 对子题进行排序
-        if (question.subQuestionList && question.subQuestionList.length > 0) {
-          question.subQuestionList.sort(function(a, b) {
-            if (a.quesNumber > b.quesNumber) {
-              return 1;
-            } else if (a.quesNumber < b.quesNumber) {
-              return -1;
-            } else {
-              return 0;
-            }
-          });
-        }
+        // if (question.questionUnitList && question.questionUnitList.length > 0) {
+        //   question.questionUnitList.sort(function(a, b) {
+        //     if (a.quesNumber > b.quesNumber) {
+        //       return 1;
+        //     } else if (a.quesNumber < b.quesNumber) {
+        //       return -1;
+        //     } else {
+        //       return 0;
+        //     }
+        //   });
+        // }
+        this.parentQuestionBody = question.body;
       } else {
-        initQuestion(question.questionUnitList[0]);
+        this.parentQuestionBody = null;
+        initQuestion(
+          question.questionUnitList[this.examQuestion.subNumber - 1]
+        );
       }
 
-      this.question = question.questionUnitList[0];
+      this.question =
+        question.questionUnitList[this.examQuestion.subNumber - 1];
     },
     async toggleSign() {
       await this.$http.post(
@@ -144,6 +161,7 @@ export default {
     }
   },
   components: {
+    QuestionBody,
     SingleQuestionView,
     MultipleQuestionView,
     BooleanQuestionView,
@@ -166,4 +184,8 @@ export default {
 .star:hover {
   cursor: pointer;
 }
+
+div.hr {
+  border-bottom: 1px dashed gray;
+}
 </style>

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

@@ -32,7 +32,6 @@ export default {
   methods: {
     ...mapMutations(["updateExamQuestion"]),
     async answerQuestion(reset) {
-      console.log(this.studentAnswer);
       if (reset === null) {
         this.studentAnswer = null;
       }