Tang 2 жил өмнө
parent
commit
5cf542587a

+ 158 - 20
src/mixin/index.js

@@ -1,26 +1,164 @@
 export default {
 
-    data() {
-  
+  data() {
+
+    return {
+
+    }
+
+  },
+
+  methods: {
+    calculateScore(data) {
+      let score = 0; //计算总分
+      let totalScore = 0; //总分
+      let doWrongQuestionIds = []; //做错题id(案例题简答不算在内)
+      let doQuestionIds = []; //做过的题目id
+      let lessQuestionNum = 0; //多选题少选
+      let rightQuestionIds = []; //做对的题目id
+      let totalQuestionNum = 0; //排除主观题的总条数(简单题)
+      data.forEach((item) => {
+        console.log("答案--", item.ans, "选择--", item.ques);
+
+        totalScore += item.score * (item.type == 4 ? item.jsonStr.length : 1);
+
+        if (
+          item.type < 4 ||
+          (item.type == 4 && !item.jsonStr.some((e) => e.type == 5))
+        ) {
+          totalQuestionNum++;
+        }
+
+        if (item.type == 1 || item.type == 3) {
+          //正确
+          if (item.ques == item.ans) {
+            item.scoreResult = item.score;
+            score += item.score;
+            rightQuestionIds.push(item.questionId);
+          } else {
+            //错误
+            item.scoreResult = 0;
+            if (item.ques) {
+              doWrongQuestionIds.push(item.questionId);
+            }
+          }
+          if (item.ques) {
+            doQuestionIds.push(item.questionId);
+          }
+        } else if (item.type == 2) {
+          let isRight =
+            item.ans &&
+            item.ans.every((quesItem, quesIndex) => {
+              if (item.ques) {
+                return item.ques[quesIndex] == item.ans[quesIndex];
+              } else {
+                return false;
+              }
+            });
+
+          if (isRight) {
+            score += item.score;
+            item.scoreResult = item.score;
+            rightQuestionIds.push(item.questionId);
+          } else {
+            let hasPart = false;
+            let checkboxScore = 1; //获取单题总分数
+            item.ques &&
+              item.ques.forEach((ques, quesIndex) => {
+                //选错一个全扣
+                if (item.ques) {
+                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
+                    checkboxScore = 0;
+                  }
+                } else {
+                  checkboxScore = 0;
+                }
+              });
+
+            //没选错
+            if (checkboxScore) {
+              checkboxScore = 0;
+              item.ans.forEach((ans, quesIndex) => {
+                //漏选扣一部分,对n题给n X partScore 分
+                if (item.ques) {
+                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
+                    checkboxScore += item.partScore;
+                    hasPart = true;
+                  }
+                } else {
+                  checkboxScore = 0;
+                }
+              });
+            }
+
+            if (!hasPart) {
+              //0分
+              item.scoreResult = 0;
+              if (item.ques) {
+                doWrongQuestionIds.push(item.questionId);
+              }
+            } else {
+              //部分分
+              lessQuestionNum++;
+              item.scoreResult = checkboxScore;
+              score += checkboxScore;
+            }
+          }
+          if (item.ques && item.ques.length) {
+            doQuestionIds.push(item.questionId);
+          }
+        } else if (item.type == 4) {
+          let len = item.ans.length;
+          let questionScore = 0;
+          if (item.ques && item.ques.length) {
+            item.ques.forEach((ele, idx) => {
+              if (
+                ele == item.ans[idx] ||
+                (item.jsonStr[idx].type == 2 &&
+                  ele.toString() == item.ans[idx].toString())
+              ) {
+                len--;
+                questionScore += item.score;
+              }
+            });
+            score += questionScore;
+            item.scoreResult = questionScore;
+            len == 0 && rightQuestionIds.push(item.questionId);
+            doQuestionIds.push(item.questionId);
+          }
+        } else if (item.type == 5) {
+          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
+            doQuestionIds.push(item.questionId);
+          }
+        }
+      });
       return {
-  
-      }
-  
-    },
-  
-    methods: {
-      
-      go(path) {
-        this.$router.push({
-          path,
-        });
-      },
+        reportStatus: score >= (data[0].passScore || totalScore * 0.6) ? 1 : 0,
+        lessQuestionNum,
+        performance: score,
+        totalScore,
+        doQuestionNum: doQuestionIds.length,
+        doQuestionIds: doQuestionIds.join(","),
+        rightQuestionIds: rightQuestionIds.join(","),
+        rightQuestionNum: rightQuestionIds.length,
+        historyExamJson: JSON.stringify(data),
+        questionIds: doWrongQuestionIds,
+        totalQuestionNum,
+      };
     },
 
-    beforeDestroy() {
-      try {
-        this.$msgbox.close();
-      } catch (err) {}
+
+    go(path) {
+      this.$router.push({
+        path,
+      });
     },
-  
-  }
+  },
+
+  beforeDestroy() {
+    try {
+      this.$msgbox.close();
+    } catch (err) { }
+  },
+
+}

+ 14 - 277
src/pages/bank-exam/index.vue

@@ -1092,6 +1092,7 @@ import ToolBar from "@/components/toolbar/index";
 import CollectionBox from "@/components/common/CollectionBox.vue";
 import HeaderTabBox from "../../components/exam/HeaderTabBox.vue";
 import { mapMutations } from "vuex";
+import myMixins from "@/mixin"
 export default {
   name: "BankExplain",
   components: {
@@ -1101,6 +1102,7 @@ export default {
     CollectionBox,
     HeaderTabBox
   },
+  mixins:[myMixins],
   data() {
     return {
       recordId: 0,
@@ -1160,7 +1162,8 @@ export default {
       isSubmit: false,
       postTimer: null,
       number: "",
-      simulateExamId: ""
+      simulateExamId: "",
+      examData:{}
     };
   },
   async mounted() {
@@ -1365,8 +1368,8 @@ export default {
             });
             return;
           }
-          this.allTimes = res.data[0].answerTime * 60;
-          this.lastTime = res.data[0].answerTime && res.data[0].answerTime * 60;
+          this.allTimes = this.examData.answerTime * 60;
+          this.lastTime = this.examData.answerTime && this.examData.answerTime * 60;
 
           //考试时间到了自动交卷
           if (this.lastTime) {
@@ -1727,103 +1730,8 @@ export default {
     examRecordEdit() {
       clearInterval(this.postTimer);
       clearInterval(this.timer);
-      let number = 0;
-      let score = 0;
-      let doQuestionNum = 0;
-      let doQuestionIds = []; //做过的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        if (item.type == 1) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (!hasPart) {
-              //0分
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              score += checkboxScore;
-            }
-          }
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item == 4) {
-          if (item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
+      
+      let form = this.calculateScore(this.questionList)
 
       this.$request
         .examRecordEdit({
@@ -1831,14 +1739,10 @@ export default {
           goodsId: this.goodsId,
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionNum: number,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          lessQuestionNum: lessQuestionNum,
           status: 0,
-          doQuestionNum: doQuestionNum,
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {
           this.punchClock();
@@ -1857,6 +1761,7 @@ export default {
         }
         this.$request.bankExam(this.examId).then(res => {
           this.bankType = res.data.doType;
+          this.examData = res.data
           if (this.bankType == 2) {
             this.needBack = true;
           }
@@ -2453,6 +2358,7 @@ export default {
         return "";
       }
     },
+    
     /**
      * 交卷,跳转报告页
      */
@@ -2460,189 +2366,20 @@ export default {
       this.loading = true;
       clearInterval(this.timer);
       clearInterval(this.postTimer);
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0; //做对的题目数量
-      let doQuestionNum = 0; //做过的题目数量
-      let allScore = 0; //总分
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                console.log(
-                  "ques:",
-                  item.ques,
-                  item.ans,
-                  item.ques[quesIndex],
-                  item.ans[quesIndex],
-                  quesIndex
-                );
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-            item.scoreResult = item.score;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore, "checkboxScore1");
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-            console.log(checkboxScore, "checkboxScore2");
-
-            if (!hasPart) {
-              //0分
-              item.scoreResult = 0;
-              if (item.ques) {
-                doWrongQuestionIds.push(item.questionId);
-              }
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              // doWrongQuestionIds.push(item.questionId);
-              item.scoreResult = checkboxScore;
-              score += checkboxScore;
-              // rightQuestionIds.push(item.questionId)
-            }
-          }
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          allScore += item.score;
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      // setTimeout(() => {
-      //   let result = {
-      //     chapterId: this.chapterId,
-      //     moduleId: this.moduleId,
-      //     examId: this.examId,
-      //     recordId: this.recordId,
-      //   };
-
-      //   this.setExamResult(result);
-      //   this.$router.push({
-      //     path: "/bank-report/" + this.goodsId,
-      //   });
-      // }, 1000);
-      // return;
+      let form = this.calculateScore(this.questionList)
       //交卷 /exam/record/edit
       this.$request
         .examRecordEdit({
           examId: this.examId,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          lessQuestionNum: lessQuestionNum,
-          rightQuestionNum: number,
           status: 1,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {
           this.isSubmit = true;
@@ -2676,7 +2413,7 @@ export default {
           orderGoodsId: this.orderGoodsId,
           examId: this.examId,
           goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           type: 1,
           doMode: this.doMode,

+ 250 - 258
src/pages/course-exam/index.vue

@@ -1209,7 +1209,8 @@ export default {
       compareFaceData: 0, // 拍照匹配相似度
       collectList: [],
       doMode: 1,
-      simulateExamId: ""
+      simulateExamId: "",
+      examData:{}
     };
   },
   async mounted() {
@@ -1310,8 +1311,8 @@ export default {
             });
             return;
           }
-          this.allTimes = data[0].answerTime * 60;
-          this.lastTime = data[0].answerTime && data[0].answerTime * 60;
+          this.allTimes =this.examData.answerTime * 60;
+          this.lastTime = this.examData.answerTime && this.examData.answerTime * 60;
 
           data.forEach((item, index) => {
             if (typeof item.jsonStr == "string") {
@@ -1815,6 +1816,7 @@ export default {
     bankExam() {
       return this.$request.bankExam(this.examId).then(res => {
         this.bankType = res.data.doType;
+        this.examData = res.data
         if (this.bankType == 2) {
           this.needBack = true;
         }
@@ -2364,143 +2366,144 @@ export default {
         });
         return;
       }
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0; //做对的题目数量
-      let doQuestionNum = 0; //做过的题目数量
-      let allScore = 0; //总分
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-            item.scoreResult = item.score;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (!hasPart) {
-              //0分
-              item.scoreResult = 0;
-              if (item.ques) {
-                doWrongQuestionIds.push(item.questionId);
-              }
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              // doWrongQuestionIds.push(item.questionId);
-              item.scoreResult = checkboxScore;
-              score += checkboxScore;
-              // rightQuestionIds.push(item.questionId)
-            }
-          }
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          allScore += item.score;
-          if (item.ques && (item.ques.imageList || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于分及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
+      let form = this.calculateScore(this.questionList)
+      // let score = 0; //计算总分
+      // let reportStatus = 0;
+      // let number = 0; //做对的题目数量
+      // let doQuestionNum = 0; //做过的题目数量
+      // let allScore = 0; //总分
+      // let passScore = 0;
+      // let doWrongQuestionIds = []; //错题和未做题id(客观题)
+      // let doQuestionIds = []; //做过的题目id
+      // let rightQuestionIds = []; //做对的题目id
+      // let lessQuestionNum = 0;
+      // this.questionList.forEach((item, index) => {
+      //   passScore = item.passScore;
+      //   if (item.type == 1) {
+      //     //正确
+      //     if (item.ques == item.ans) {
+      //       item.scoreResult = item.score;
+      //       score += item.score;
+      //       number++;
+      //       rightQuestionIds.push(item.questionId);
+      //     } else {
+      //       //错误
+      //       item.scoreResult = 0;
+      //       if (item.ques) {
+      //         doWrongQuestionIds.push(item.questionId);
+      //       }
+      //     }
+      //     allScore += item.score;
+      //     if (item.ques) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 2) {
+      //     let isRight =
+      //       item.ans &&
+      //       item.ans.every((quesItem, quesIndex) => {
+      //         if (item.ques) {
+      //           return item.ques[quesIndex] == item.ans[quesIndex];
+      //         } else {
+      //           return false;
+      //         }
+      //       });
+
+      //     if (isRight) {
+      //       score += item.score;
+      //       number++;
+      //       item.scoreResult = item.score;
+      //       rightQuestionIds.push(item.questionId);
+      //     } else {
+      //       let hasPart = false;
+      //       let checkboxScore = 1; //获取单题总分数
+      //       item.ques &&
+      //         item.ques.forEach((ques, quesIndex) => {
+      //           //选错一个全扣
+      //           if (item.ques) {
+      //             if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
+      //               checkboxScore = 0;
+      //             }
+      //           } else {
+      //             checkboxScore = 0;
+      //           }
+      //         });
+
+      //       //没选错
+      //       if (checkboxScore) {
+      //         checkboxScore = 0;
+      //         item.ans.forEach((ans, quesIndex) => {
+      //           //漏选扣一部分,对n题给n X partScore 分
+      //           if (item.ques) {
+      //             if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
+      //               checkboxScore += item.partScore;
+      //               hasPart = true;
+      //             }
+      //           } else {
+      //             checkboxScore = 0;
+      //           }
+      //         });
+      //       }
+
+      //       if (!hasPart) {
+      //         //0分
+      //         item.scoreResult = 0;
+      //         if (item.ques) {
+      //           doWrongQuestionIds.push(item.questionId);
+      //         }
+      //       } else {
+      //         //部分分
+      //         // number++;
+      //         lessQuestionNum++;
+      //         // doWrongQuestionIds.push(item.questionId);
+      //         item.scoreResult = checkboxScore;
+      //         score += checkboxScore;
+      //         // rightQuestionIds.push(item.questionId)
+      //       }
+      //     }
+      //     allScore += item.score;
+      //     if (item.ques && item.ques.length) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 3) {
+      //     if (item.ques == item.ans) {
+      //       item.scoreResult = item.score;
+      //       score += item.score;
+      //       number++;
+      //       rightQuestionIds.push(item.questionId);
+      //     } else {
+      //       item.scoreResult = 0;
+      //       if (item.ques) {
+      //         doWrongQuestionIds.push(item.questionId);
+      //       }
+      //     }
+      //     allScore += item.score;
+      //     if (item.ques) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 4) {
+      //     allScore += item.score;
+      //     if (item.ques && item.ques.length) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 5) {
+      //     allScore += item.score;
+      //     if (item.ques && (item.ques.imageList || item.ques.text)) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   }
+      // });
+
+      // //大于分及格
+      // if (score >= passScore) {
+      //   reportStatus = 1;
+      // } else {
+      //   reportStatus = 0;
+      // }
 
       clearInterval(this.timer);
       //交卷 /bank/record/edit
@@ -2515,19 +2518,11 @@ export default {
           type: this.type, //题卷类型 1章卷 2节卷 3模块卷
           examId: this.examId,
           goodsId: this.goodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {
           this.isSubmit = true;
@@ -2539,12 +2534,12 @@ export default {
 
           setTimeout(() => {
             let result = {
-              rightQuestionNum: number,
-              doWrongQuestionNum: doWrongQuestionIds.length,
-              score: score,
-              totalScore: allScore,
-              reportStatus: reportStatus,
-              lessQuestionNum: lessQuestionNum
+              rightQuestionNum: form.rightQuestionNum,
+              doWrongQuestionNum: form.questionIds.length,
+              score: form.performance,
+              totalScore: form.totalScore,
+              reportStatus: form.reportStatus,
+              lessQuestionNum: form.lessQuestionNum
             };
 
             this.setExamResult(result);
@@ -2576,7 +2571,7 @@ export default {
           orderGoodsId: this.orderGoodsId,
           examId: this.examId,
           goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           type: 2, // 视频课程的传2
           doMode: this.doMode,
@@ -2610,103 +2605,104 @@ export default {
       }
       clearInterval(this.postTimer);
       clearInterval(this.timer);
-      let number = 0;
-      let score = 0;
-      let doQuestionNum = 0;
-      let doQuestionIds = []; //做过的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        if (item.type == 1) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (!hasPart) {
-              //0分
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              score += checkboxScore;
-            }
-          }
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item == 4) {
-          if (item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
+      let form = this.calculateScore(this.questionList)
+      // let number = 0;
+      // let score = 0;
+      // let doQuestionNum = 0;
+      // let doQuestionIds = []; //做过的题目id
+      // let lessQuestionNum = 0;
+      // this.questionList.forEach((item, index) => {
+      //   if (item.type == 1) {
+      //     if (item.ques == item.ans) {
+      //       score += item.score;
+      //       number++;
+      //     }
+
+      //     if (item.ques) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 2) {
+      //     let isRight =
+      //       item.ans &&
+      //       item.ans.every((quesItem, quesIndex) => {
+      //         if (item.ques) {
+      //           return item.ques[quesIndex] == item.ans[quesIndex];
+      //         } else {
+      //           return false;
+      //         }
+      //       });
+
+      //     if (isRight) {
+      //       score += item.score;
+      //       number++;
+      //     } else {
+      //       let hasPart = false;
+      //       let checkboxScore = 1; //获取单题总分数
+      //       item.ques &&
+      //         item.ques.forEach((ques, quesIndex) => {
+      //           //选错一个全扣
+      //           if (item.ques) {
+      //             if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
+      //               checkboxScore = 0;
+      //             }
+      //           } else {
+      //             checkboxScore = 0;
+      //           }
+      //         });
+      //       console.log(checkboxScore);
+
+      //       //没选错
+      //       if (checkboxScore) {
+      //         checkboxScore = 0;
+      //         item.ans.forEach((ans, quesIndex) => {
+      //           //漏选扣一部分,对n题给n X partScore 分
+      //           if (item.ques) {
+      //             if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
+      //               checkboxScore += item.partScore;
+      //               hasPart = true;
+      //             }
+      //           } else {
+      //             checkboxScore = 0;
+      //           }
+      //         });
+      //       }
+
+      //       if (!hasPart) {
+      //         //0分
+      //       } else {
+      //         //部分分
+      //         // number++;
+      //         lessQuestionNum++;
+      //         score += checkboxScore;
+      //       }
+      //     }
+      //     if (item.ques && item.ques.length) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 3) {
+      //     if (item.ques == item.ans) {
+      //       score += item.score;
+      //       number++;
+      //     }
+
+      //     if (item.ques) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item == 4) {
+      //     if (item.ques.length) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   } else if (item.type == 5) {
+      //     if (item.ques && (item.ques.imageList.length || item.ques.text)) {
+      //       doQuestionNum++;
+      //       doQuestionIds.push(item.questionId);
+      //     }
+      //   }
+      // });
 
       this.$request
         .bankRecordEdit({
@@ -2714,14 +2710,10 @@ export default {
           goodsId: this.goodsId,
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionNum: number,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          lessQuestionNum: lessQuestionNum,
           status: 0,
-          doQuestionNum: doQuestionNum,
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {});
     }

+ 14 - 425
src/pages/mock-exam/index.vue

@@ -1341,10 +1341,11 @@ export default {
         goodsId: this.goodsId,
         orderGoodsId: this.orderGoodsId,
         from: this.doMode == 3 ? 3 : ""
-      }).then(async data => {
+      }).then(async items => {
+        var data = items.data.questionList
         if (this.doMode == 3) {
-          this.simulateExamId = data.data.simulateExamId;
-          data = data.data.questionList;
+          this.simulateExamId = items.data.simulateExamId;
+          data = items.data.questionList;
         }
         if (!data.length) {
           this.$message({
@@ -1549,103 +1550,7 @@ export default {
     mockRecordEdit() {
       clearInterval(this.postTimer);
       clearInterval(this.timer);
-      let number = 0;
-      let score = 0;
-      let doQuestionNum = 0;
-      let doQuestionIds = []; //做过的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        if (item.type == 1) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (!hasPart) {
-              //0分
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              score += checkboxScore;
-            }
-          }
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item == 4) {
-          if (item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
+      let form = this.calculateScore(this.questionList)
 
       if (this.subscribeId) {
         this.mockSubscribeEdit();
@@ -1656,12 +1561,8 @@ export default {
           eachExamId: this.eachExamId,
           examId: this.examId,
           recordId: this.recordId,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
-          doQuestionNum: doQuestionNum,
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {});
     },
@@ -2235,186 +2136,26 @@ export default {
      * 交卷,跳转报告页
      */
     examSubmit() {
-      console.log(12313);
       this.loading = true;
       clearInterval(this.timer);
       clearInterval(this.postTimer);
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0; //做对的题目数量
-      let doQuestionNum = 0; //做过的题目数量
-      let allScore = 0; //总分
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      let lessQuestionNum = 0;
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-            item.scoreResult = item.score;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore, "checkboxScore1");
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-            console.log(checkboxScore, "checkboxScore2");
-
-            if (!hasPart) {
-              //0分
-              item.scoreResult = 0;
-              if (item.ques) {
-                doWrongQuestionIds.push(item.questionId);
-              }
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              // doWrongQuestionIds.push(item.questionId);
-              item.scoreResult = checkboxScore;
-              score += checkboxScore;
-              // rightQuestionIds.push(item.questionId)
-            }
-          }
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          allScore += item.score;
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
+      let form = this.calculateScore(this.questionList)
 
       if (this.subscribeId) {
         this.mockSubscribeEdit();
       }
-
-      // setTimeout(() => {
-      //   let result = {
-      //     chapterId: this.chapterId,
-      //     moduleId: this.moduleId,
-      //     examId: this.examId,
-      //     recordId: this.recordId,
-      //   };
-
-      //   this.setExamResult(result);
-      //   this.$router.push({
-      //     path: "/bank-report/" + this.goodsId,
-      //   });
-      // }, 1000);
-      // return;
       //交卷
       this.$request
         .mockRecordEdit({
           eachExamId: this.eachExamId,
           examId: this.examId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          lessQuestionNum: lessQuestionNum,
-          rightQuestionNum: number,
+          orderGoodsId:this.orderGoodsId,
+          goodsId:this.goodsId,
           status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {
           this.isSubmit = true;
@@ -2445,7 +2186,7 @@ export default {
         .mockWrongRecord({
           eachExamId: this.eachExamId,
           examId: this.examId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId
         })
         .then(res => {})
@@ -2458,180 +2199,28 @@ export default {
     leaveNow() {
       clearInterval(this.timer);
       clearInterval(this.postTimer);
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0; //做对的题目数量
-      let doQuestionNum = 0; //做过的题目数量
-      let allScore = 0; //总分
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      let lessQuestionNum = 0;
-      console.log(111);
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 2) {
-          let isRight =
-            item.ans &&
-            item.ans.every((quesItem, quesIndex) => {
-              if (item.ques) {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              } else {
-                return false;
-              }
-            });
-
-          if (isRight) {
-            score += item.score;
-            number++;
-            item.scoreResult = item.score;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let hasPart = false;
-            let checkboxScore = 1; //获取单题总分数
-            item.ques &&
-              item.ques.forEach((ques, quesIndex) => {
-                //选错一个全扣
-                if (item.ques) {
-                  if (item.ans.indexOf(item.ques[quesIndex]) == -1) {
-                    checkboxScore = 0;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            console.log(checkboxScore, "checkboxScore1");
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分,对n题给n X partScore 分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) != -1) {
-                    checkboxScore += item.partScore;
-                    hasPart = true;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-            console.log(checkboxScore, "checkboxScore2");
-
-            if (!hasPart) {
-              //0分
-              item.scoreResult = 0;
-              if (item.ques) {
-                doWrongQuestionIds.push(item.questionId);
-              }
-            } else {
-              //部分分
-              // number++;
-              lessQuestionNum++;
-              // doWrongQuestionIds.push(item.questionId);
-              item.scoreResult = checkboxScore;
-              score += checkboxScore;
-              // rightQuestionIds.push(item.questionId)
-            }
-          }
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            item.scoreResult = 0;
-            if (item.ques) {
-              doWrongQuestionIds.push(item.questionId);
-            }
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          allScore += item.score;
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          allScore += item.score;
-          if (item.ques && (item.ques.imageList.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+      let form = this.calculateScore(this.questionList)
       if (this.subscribeId) {
         this.mockSubscribeEdit();
       }
-
-      console.log(333);
       //交卷
       this.$request
         .mockRecordEdit({
           eachExamId: this.eachExamId,
           examId: this.examId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList)
+          ...form
         })
         .then(res => {});
-
-      console.log(222);
       //错题集id提交(客观题)
       this.$request
         .examWrongRecord({
           eachExamId: this.eachExamId,
           examId: this.examId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           doMode: this.doMode
         })

+ 14 - 14
src/pages/person-center/my-course/index.vue

@@ -1599,23 +1599,23 @@ export default {
         return;
       }
       //type:1章卷,2节卷,3模考卷,4习题
-      // if (!this.checkCanLearn()) {
-      //   return false;
-      // }
+      if (!this.checkCanLearn()) {
+        return false;
+      }
       // 学习次数
-      // if (!(await this.exceedLearnNum(courseLists, section))) {
-      //   return false;
-      // }
+      if (!(await this.exceedLearnNum(courseLists, section))) {
+        return false;
+      }
 
-      // // 学习顺序
+      // 学习顺序
 
-      // if (!(await this.orderTopTobottom(courseLists, section, type))) {
-      //   this.$message({
-      //     type: "warning",
-      //     message: "请学完视频课程再进行练习和测试",
-      //   });
-      //   return false;
-      // }
+      if (!(await this.orderTopTobottom(courseLists, section, type))) {
+        this.$message({
+          type: "warning",
+          message: "请学完视频课程再进行练习和测试",
+        });
+        return false;
+      }
       //有次数限制
       let num = await this.bankRecordDoNum(courseLists, section);
       // section.doNum

+ 60 - 59
src/pages/person-center/my-mock/index.vue

@@ -260,10 +260,10 @@
                       :key="index"
                       :label="
                         item.educationName +
-                        ':' +
-                        item.businessName +
-                        '-' +
-                        item.projectName
+                          ':' +
+                          item.businessName +
+                          '-' +
+                          item.projectName
                       "
                       :value="item.businessId"
                     >
@@ -427,7 +427,7 @@
                     :class="{
                       'note--blue': item.liveStatus == 1,
                       'note--green': item.liveStatus == 2,
-                      'note--gray': item.liveStatus == 3,
+                      'note--gray': item.liveStatus == 3
                     }"
                   >
                     <img
@@ -549,7 +549,7 @@ export default {
         pageSize: 10,
         businessId: "",
         majorId: "",
-        total: 0,
+        total: 0
       },
       examParam: {
         applyName: "",
@@ -557,14 +557,14 @@ export default {
         pageNum: 1,
         pageSize: 10,
         mockStatus: 0,
-        total: 0,
+        total: 0
       },
       liveParam: {
         applyName: "",
         dateRange: "",
         pageNum: 1,
         pageSize: 10,
-        total: 0,
+        total: 0
       },
       total: 1,
       title: 0,
@@ -579,7 +579,7 @@ export default {
       formData: {
         status: "0,1",
         pageNum: 1,
-        pageSize: 10,
+        pageSize: 10
       },
       player: null,
       date: "",
@@ -592,23 +592,23 @@ export default {
         {
           label: "模拟考试",
           count: 0,
-          name: "1",
+          name: "1"
         },
         {
           label: "考试预约",
           count: 0,
-          name: "2",
+          name: "2"
         },
         {
           label: "讲解直播",
           count: 0,
-          name: "3",
-        },
-      ],
+          name: "3"
+        }
+      ]
     };
   },
   computed: {
-    ...mapGetters(["sysTime"]),
+    ...mapGetters(["sysTime"])
   },
   async mounted() {
     this.nowTime = +this.$tools.timest();
@@ -634,7 +634,7 @@ export default {
       if (liveParam.dateRange && liveParam.dateRange[1]) {
         liveParam.endTime = liveParam.dateRange[1].toString().substr(0, 10);
       }
-      this.$request.mockApplyListApplyName(liveParam).then((res) => {
+      this.$request.mockApplyListApplyName(liveParam).then(res => {
         this.listLiveName = res.rows;
         this.liveParam.applyName = "";
         this.mockApplyListMockLive();
@@ -649,7 +649,7 @@ export default {
       if (examParam.dateRange && examParam.dateRange[1]) {
         examParam.endTime = examParam.dateRange[1].toString().substr(0, 10);
       }
-      this.$request.mockApplyListApplyName(examParam).then((res) => {
+      this.$request.mockApplyListApplyName(examParam).then(res => {
         this.listApplyName = res.rows;
         this.examParam.applyName = "";
         this.mockSubscribeListSubscribe();
@@ -664,8 +664,8 @@ export default {
         this.$router.push({
           path: "/living-room/" + item.liveUrl,
           query: {
-            sectionType: 2,
-          },
+            sectionType: 2
+          }
         });
       } else if (item.liveStatus == 1) {
         //未开播
@@ -695,7 +695,7 @@ export default {
     loadPlayer() {
       var self = this;
       const polyvPlayer = window.polyvPlayer;
-      self.$request.obtainpolyvvideosign(self.vid).then((res) => {
+      self.$request.obtainpolyvvideosign(self.vid).then(res => {
         self.player = polyvPlayer({
           wrap: "#player",
           width: "100%",
@@ -712,11 +712,11 @@ export default {
           watchStartTime: 0,
           ts: res.data.ts,
           sign: res.data.sign,
-          playsafe: function (vid, next) {
-            self.$request.obtainpolyvvideopcsign(vid).then((res) => {
+          playsafe: function(vid, next) {
+            self.$request.obtainpolyvvideopcsign(vid).then(res => {
               next(res.data);
             });
-          },
+          }
         });
       });
     },
@@ -736,8 +736,8 @@ export default {
           recordId: item.recordId,
           examId: item.examId,
           eachExamId: item.eachExamId,
-          subscribeId: item.subscribeId,
-        },
+          subscribeId: item.subscribeId
+        }
       });
     },
     doQuestion(item) {
@@ -745,13 +745,16 @@ export default {
         this.$message.warning("请等待所有科目考试结束后再进入刷题");
         return;
       }
-
+      console.log(item, "item");
       this.$router.push({
         path: "/mock-exam",
         query: {
           examId: item.examId,
           eachExamId: item.eachExamId,
-        },
+          subscribeId: item.subscribeId,
+          goodsId: item.goodsId,
+          orderGoodsId: item.orderGoodsId
+        }
       });
     },
     async reApply(item) {
@@ -764,8 +767,8 @@ export default {
       this.$router.push({
         path: "/living-room/" + item.liveUrl,
         query: {
-          sectionType: 2,
-        },
+          sectionType: 2
+        }
       });
     },
     goTest(item) {
@@ -814,8 +817,8 @@ export default {
               " " +
               item.applySiteEndTime
           ),
-          subscribeId: item.subscribeId,
-        },
+          subscribeId: item.subscribeId
+        }
       });
     },
     appoint(item) {
@@ -840,14 +843,14 @@ export default {
           mockMajorSubjectId: item.mockMajorSubjectId,
           eachExamId: item.eachExamId,
           goodsId: item.goodsId,
-          orderGoodsId: item.orderGoodsId,
+          orderGoodsId: item.orderGoodsId
           // applySiteExamTime:1653899220,
           // applySiteEndTime:"17:27:54",
           // applySiteStartTime:'16:27:54',
           // applyId:26,
           // mockMajorSubjectId:49
         })
-        .then((res) => {
+        .then(res => {
           if (res.code == 200) {
             this.showItem = item;
             this.subscribeId = res.data;
@@ -857,7 +860,7 @@ export default {
             this.$message.warning(err.msg);
           }
         })
-        .catch((err) => {
+        .catch(err => {
           this.$message.warning(err.msg);
         });
     },
@@ -880,7 +883,7 @@ export default {
       }
     },
     async businessChange(e) {
-      let projectObj = this.businesslist.find((item) => item.businessId == e);
+      let projectObj = this.businesslist.find(item => item.businessId == e);
 
       let projectId = "";
 
@@ -890,7 +893,7 @@ export default {
       await this.courseMajorList({
         businessId: this.appointParam.businessId,
         projectId: projectId,
-        status: 1,
+        status: 1
       });
       this.mockApplyListApply();
     },
@@ -905,42 +908,42 @@ export default {
         closeOnClickModal: false,
         closeOnPressEscape: false,
         distinguishCancelAndClose: false,
-        showClose: true,
+        showClose: true
       })
-        .then((_) => {
+        .then(_ => {
           this.mockSubscribeEdit();
         })
-        .catch((_) => {});
+        .catch(_ => {});
     },
 
     mockSubscribeEdit() {
       this.$request
         .mockSubscribeEdit({
           mockRemind: 1,
-          subscribeId: this.subscribeId,
+          subscribeId: this.subscribeId
         })
-        .then((res) => {
+        .then(res => {
           this.$message.success("开启成功");
         });
     },
     mockApplyListApplyBusiness() {
-      return new Promise((resolve) => {
-        this.$request.mockApplyListApplyBusiness().then(async (res) => {
+      return new Promise(resolve => {
+        this.$request.mockApplyListApplyBusiness().then(async res => {
           this.businesslist = res.rows;
           this.appointParam.businessId = this.businesslist[0].businessId;
           await this.courseMajorList({
             businessId: res.rows[0].businessId,
             projectId: res.rows[0].projectId,
-            status: 1,
+            status: 1
           });
           resolve();
         });
       });
     },
     courseMajorList(data) {
-      return new Promise((resolve) => {
+      return new Promise(resolve => {
         let self = this;
-        this.$request.courseMajorList(data).then((res) => {
+        this.$request.courseMajorList(data).then(res => {
           if (res.code == 200) {
             self.sList = res.rows;
             let allItem = { id: "", categoryName: "全部" };
@@ -1002,14 +1005,13 @@ export default {
 
       if (this.listApplyName.length) {
         examParam.applyName = this.listApplyName.find(
-          (item) => examParam.applyName == item.applyId
+          item => examParam.applyName == item.applyId
         )
-          ? this.listApplyName.find(
-              (item) => examParam.applyName == item.applyId
-            ).applyName
+          ? this.listApplyName.find(item => examParam.applyName == item.applyId)
+              .applyName
           : "";
       }
-      this.$request.mockSubscribeListSubscribe(examParam).then((res) => {
+      this.$request.mockSubscribeListSubscribe(examParam).then(res => {
         this.examList = res.rows;
         this.examParam.total = res.total;
       });
@@ -1029,7 +1031,7 @@ export default {
           .substr(0, 10);
       }
       this.setSystemTime();
-      this.$request.mockApplyListApply(appointParam).then((res) => {
+      this.$request.mockApplyListApply(appointParam).then(res => {
         this.mockList = res.rows;
         this.appointParam.total = res.total;
       });
@@ -1046,14 +1048,13 @@ export default {
 
       if (this.listLiveName.length) {
         liveParam.applyName = this.listLiveName.find(
-          (item) => liveParam.applyName == item.applyId
+          item => liveParam.applyName == item.applyId
         )
-          ? this.listLiveName.find(
-              (item) => liveParam.applyName == item.applyId
-            ).applyName
+          ? this.listLiveName.find(item => liveParam.applyName == item.applyId)
+              .applyName
           : "";
       }
-      this.$request.mockApplyListMockLive(liveParam).then((res) => {
+      this.$request.mockApplyListMockLive(liveParam).then(res => {
         this.liveList = res.rows;
         this.liveParam.total = res.total;
       });
@@ -1061,8 +1062,8 @@ export default {
     stateChange(state) {
       this.examParam.mockStatus = state;
       this.mockSubscribeListSubscribe();
-    },
-  },
+    }
+  }
 };
 </script>