فهرست منبع

feat: word导入只查看错误试题

zhangjie 1 ماه پیش
والد
کامیت
83893c817d
1فایلهای تغییر یافته به همراه46 افزوده شده و 15 حذف شده
  1. 46 15
      src/modules/question/components/QuestionImportEdit.vue

+ 46 - 15
src/modules/question/components/QuestionImportEdit.vue

@@ -186,7 +186,11 @@
                   </span>
                   <span> 题</span>
                 </p>
-                <el-checkbox>仅查看识别有误试题</el-checkbox>
+                <el-checkbox
+                  v-model="onlyErrorQuestion"
+                  @change="onlyErrorQuestionChange"
+                  >仅查看识别有误试题</el-checkbox
+                >
               </div>
               <div class="qe-part-head-menu">
                 <el-tabs
@@ -194,7 +198,11 @@
                   @tab-click="filterQuestionTypeChange"
                 >
                   <el-tab-pane
-                    :label="`全部(${questionStatData.total})`"
+                    :label="`全部(${
+                      onlyErrorQuestion
+                        ? questionStatData.errorCount
+                        : questionStatData.total
+                    })`"
                     name="all"
                   ></el-tab-pane>
                   <el-tab-pane
@@ -379,6 +387,7 @@ export default {
       uploadUrl: `${QUESTION_API}/word/parse/struct`,
       showIframeDialog: false,
       // question types
+      onlyErrorQuestion: false,
       questionStatData: {
         total: 0,
         successCount: 0,
@@ -459,7 +468,11 @@ export default {
       );
       const questionTypeStat = {};
       this.paperData.forEach((detail) => {
-        detail.questions.forEach((question) => {
+        let questions = detail.questions;
+        if (this.onlyErrorQuestion) {
+          questions = questions.filter((v) => v.questionExceptions.length);
+        }
+        questions.forEach((question) => {
           const { questionType } = question;
           if (questionTypeStat[questionType]) {
             questionTypeStat[questionType]++;
@@ -485,6 +498,11 @@ export default {
         qtypes,
       };
     },
+    onlyErrorQuestionChange() {
+      this.parseQuestionStatData();
+      this.filterQuestionTypeChange({ name: this.filterQuestionType });
+      this.questionKey = randomCode();
+    },
     inHasIgnore(indexes) {
       return this.ignoreRepeatExceptionIndexArr.includes(indexes.toString());
     },
@@ -570,30 +588,43 @@ export default {
       });
     },
     filterQuestionTypeChange(val) {
-      console.log(val);
       this.filterQuestionType = val.name;
 
-      const filterQuestionType =
-        this.filterQuestionType === "all" ? "" : this.filterQuestionType;
-      if (!filterQuestionType) {
-        this.filterPaperData = this.paperData;
+      const onlyErrorValidater = (question) => {
+        if (this.onlyErrorQuestion) {
+          return Boolean(question.questionExceptions.length);
+        }
+        return true;
+      };
+
+      if (this.filterQuestionType === "all") {
+        this.filterPaperData = !this.onlyErrorQuestion
+          ? this.paperData
+          : this.paperData
+              .map((detail) => {
+                return {
+                  ...detail,
+                  questions: detail.questions.filter((question) =>
+                    onlyErrorValidater(question)
+                  ),
+                };
+              })
+              .filter((detail) => detail.questions.length);
         return;
       }
 
       this.filterPaperData = this.paperData
-        .filter((detail) => {
-          return detail.questions.some(
-            (question) => question.questionType == filterQuestionType
-          );
-        })
         .map((detail) => {
           return {
             ...detail,
             questions: detail.questions.filter(
-              (question) => question.questionType == filterQuestionType
+              (question) =>
+                question.questionType === this.filterQuestionType &&
+                onlyErrorValidater(question)
             ),
           };
-        });
+        })
+        .filter((detail) => detail.questions.length);
     },
     getRichTextIndexList() {
       const richTextListDom = document.getElementById("qe-part-richtext-list");