Browse Source

修改了选项中开放回答的验证

Mask96 4 years ago
parent
commit
de19ed3095
1 changed files with 27 additions and 9 deletions
  1. 27 9
      src/components/WebQn.vue

+ 27 - 9
src/components/WebQn.vue

@@ -632,13 +632,31 @@ export default {
           alert(`最少需选中${this.currentQuestion.minOptions}项`);
           return;
         }
-        for (let index in this.selectedOpenList) {
-          if (
-            this.selectedOpenList[index].selectedIndex &&
-            !this.selectedOpenList[index].selectedValue
-          ) {
-            alert("请填写开放性选项答案");
-            return;
+
+        // 判断选择题中的开放回答是否填写
+        let optionList = this.questionaire.questions[this.questionHEAD].options;
+        for (let selIndex in selectionIds) {
+          for (let optIndex in optionList) {
+            if (
+              selectionIds[selIndex] == optionList[optIndex].id &&
+              optionList[optIndex].open
+            ) {
+              // selectionIds[selIndex] 是选中的开放性答案的id,判断其有没有对应填写的开放回答
+              let isPass = false;
+              for (let oIndex in this.selectedOpenList) {
+                if (
+                  this.selectedOpenList[oIndex].selectedId ==
+                    selectionIds[selIndex] &&
+                  this.selectedOpenList[oIndex].selectedValue
+                ) {
+                  isPass = true;
+                }
+              }
+              if (!isPass) {
+                alert("请填写开放性选项答案");
+                return;
+              }
+            }
           }
         }
 
@@ -854,7 +872,7 @@ export default {
 .select-open-dialog {
   width: 50%;
 }
-.select-open-dialog textarea{
-    height: 100px;
+.select-open-dialog textarea {
+  height: 100px;
 }
 </style>