Browse Source

未完成不能提交

y595705120 3 months ago
parent
commit
523c06ca26
1 changed files with 21 additions and 2 deletions
  1. 21 2
      src/containers/center/exam/indexTest.vue

+ 21 - 2
src/containers/center/exam/indexTest.vue

@@ -95,7 +95,7 @@
                 <h3 class="p5">单项选择题</h3>
                 <el-row :gutter="24" class="ml20">
                   <el-col :span="3" v-for="(item,index) in info.answers" :key="index" class="select-item" v-if="item.type==2">
-                    <el-button :class="'b-grid '+getStyle(index)" @click="gotoQuestion(index)" >
+                    <el-button :class="'b-grid '+getStyle(index)" @click="gotoQuestion(index)" :id="'select-'+index" >
                        {{index+1}}
                        <span class="red">
                         {{isMarked(index)}}
@@ -318,6 +318,12 @@ export default {
     },
     submitPaper() {
       let that = this
+      let ufinish= this.getUnFinishExamTest()
+      if( ufinish  >-1 ) {
+        this.$message.error(`第${+ufinish+1}题还未完成,不能提交`, 2);
+        document.getElementById( `select-${ufinish}`).click()
+        return;
+      }
       MessageBox({
         title: "确认交卷",
         message: "是否确认交卷",
@@ -332,7 +338,6 @@ export default {
             done();
             instance.confirmButtonLoading = false;
             that.dialogVisible = true;
-
           } else{
             done();
           }
@@ -340,6 +345,20 @@ export default {
         }
       })
     },
+    getUnFinishExamTest(){
+      for( let i in this.questionList){
+        let item = this.questionList[i];
+        if(item.type!= 4){
+          if( !getSelect(item.answer) ) return i;
+        }else{
+          for( let j in item.child){
+            if(!item.child[j] || !item.child[j].answerId) return i;
+            if( !getSelect(item.answer) ) return i;
+          }
+        }
+      }
+      return -1
+    },
     dosubmit( cb ) {
       let param = { examId: this.info.examId, result: { }};
       for( let i in this.questionList){