Parcourir la source

判断题增加删除小题时,删除答案中不存在的选项

dusenyao il y a 11 mois
Parent
commit
f717b9e0f8

+ 11 - 0
src/views/exercise_questions/create/components/exercises/JudgeQuestion.vue

@@ -195,6 +195,17 @@ export default {
         });
       },
     },
+    'data.option_list': {
+      handler(val) {
+        if (!val) return;
+        // 删除答案中不存在的选项
+        this.data.answer.answer_list.forEach((item, i) => {
+          if (!val.find((li) => li.mark === item.mark)) {
+            this.data.answer.answer_list.splice(i, 1);
+          }
+        });
+      },
+    },
   },
   methods: {
     addOption() {

+ 13 - 0
src/views/exercise_questions/create/components/exercises/ListenJudgeQuestion.vue

@@ -201,6 +201,19 @@ export default {
       },
     },
   },
+  watch: {
+    'data.option_list': {
+      handler(val) {
+        if (!val) return;
+        // 删除答案中不存在的选项
+        this.data.answer.answer_list.forEach((item, i) => {
+          if (!val.find((li) => li.mark === item.mark)) {
+            this.data.answer.answer_list.splice(i, 1);
+          }
+        });
+      },
+    },
+  },
   methods: {
     addOption() {
       this.data.option_list.push(getOption());