Просмотр исходного кода

初步完成计算分数改造

谢杰标 2 лет назад
Родитель
Сommit
3163f775ab

+ 137 - 0
common/methodTool.js

@@ -500,4 +500,141 @@ export default {
     window.location.href = externalLink;
     // #endif
   },
+  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 {
+      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,
+    };
+  },
 };

+ 30 - 446
pages2/bank/questionBank.vue

@@ -1205,191 +1205,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false);
       uni.navigateBack({
         delta: 1,
       });
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      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);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选只能得部分分数
-                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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      //交卷
-      this.$api
-        .examRecordEdit({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
-          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),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-            this.entryType == "daily" && this.dailyExam();
-          }
-        });
-
-      //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          orderGoodsId: this.orderGoodsId,
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          examId: this.id,
-          goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: this.doMode,
-        })
-        .then((res) => {});
     },
     /**
      * 立即交卷
@@ -1404,113 +1223,25 @@ export default {
      */
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        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 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;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (checkboxScore <= 0) {
-                //0分
-              } else {
-                //部分分
-                // number++;
-                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 {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             orderGoodsId: this.orderGoodsId,
             examId: this.id,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            doQuestionIds: doQuestionIds.join(","),
-            rightQuestionNum: number,
+            doQuestionIds,
+            rightQuestionNum,
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
             status: 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {
             if (res.data.code == 200) {
@@ -1592,7 +1323,7 @@ export default {
           this.examData = res.data.data || {};
           this.id = this.examData.examId;
           if (!this.examData.questionList.length) {
-            return this.noListTip()
+            return this.noListTip();
           }
           this.dataAnlyze(this.examData.questionList || []);
         } else {
@@ -1629,7 +1360,7 @@ export default {
         from: 1,
       }).then((res) => {
         if (res.data.code == 500) {
-          return this.noListTip('你已完成所有题目')
+          return this.noListTip("你已完成所有题目");
         }
         let data = res.data.data;
         if (this.doMode == 3) {
@@ -1637,7 +1368,7 @@ export default {
           data = data.questionList;
         }
         if (!data.length) {
-          return this.noListTip()
+          return this.noListTip();
         }
         this.allTimes = data[0].answerTime * 60;
         this.lastTime = data[0].answerTime && data[0].answerTime * 60;
@@ -2107,179 +1838,34 @@ export default {
     /**
      * 交卷
      */
-    submit() {
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       //交卷
       this.$api
         .examRecordEdit({
-          // courseId: this.courseId,
           examId: this.id,
           goodsId: this.goodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
           orderGoodsId: this.orderGoodsId,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
+          status: 1, // 1是交卷 2是中途离开
           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),
-          // type: ''
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
             this.entryType == "daily" && this.dailyExam();
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 1000,
               icon: "none",
             });
-
             setTimeout(() => {
               uni.redirectTo({
                 url:
@@ -2308,17 +1894,15 @@ export default {
         });
 
       //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: this.doMode,
-        })
-        .then((res) => {});
+      this.$api.examWrongRecord({
+        examId: this.id,
+        goodsId: this.goodsId,
+        orderGoodsId: this.orderGoodsId,
+        questionIds: form.questionIds,
+        recordId: this.recordId,
+        type: 1, // 题库试卷传1
+        doMode: this.doMode,
+      });
     },
     // 每日一练试卷打卡
     dailyExam() {

+ 57 - 396
pages2/bank/questionBankContinue.vue

@@ -6,11 +6,7 @@
       :statusBar="true"
       :title="examData.examName"
     ></uni-nav-bar>
-    <swiper
-      class="swiper"
-      :current="current"
-      @change="swiperChange"
-    >
+    <swiper class="swiper" :current="current" @change="swiperChange">
       <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
         <view class="pageContent">
           <view class="pad_8 titBox">
@@ -217,12 +213,15 @@
                   :key="index"
                   class="lisSty"
                 >
-                <!-- right: index == bank.ques || index == bank.ans,
+                  <!-- right: index == bank.ques || index == bank.ans,
                       wrong: index == bank.ques && bank.ques != bank.ans, -->
                   <text
                     :class="{
-                      right: index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
-                      wrong: index == (bank.ques == 1 ? 0 : 1) && bank.ques != bank.ans,
+                      right:
+                        index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
+                      wrong:
+                        index == (bank.ques == 1 ? 0 : 1) &&
+                        bank.ques != bank.ans,
                     }"
                     class="activeTI"
                     >{{ ast[index] }}</text
@@ -564,7 +563,7 @@
                       :key="childindex"
                       class="lisSty"
                     >
-                    <!-- right:
+                      <!-- right:
                             childindex == bank.ques[ansIndex] ||
                             childindex == bank.ans[ansIndex],
                           wrong:
@@ -573,11 +572,13 @@
                       <text
                         :class="{
                           right:
-                            bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
-                            childindex != bank.ans[ansIndex]),
+                            bankType == 1 &&
+                            (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
+                              childindex != bank.ans[ansIndex]),
                           wrong:
-                            bankType == 1 && (childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
-                            bank.ques[ansIndex] != bank.ans[ansIndex]),
+                            bankType == 1 &&
+                            childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
+                            bank.ques[ansIndex] != bank.ans[ansIndex],
                         }"
                         class="activeTI"
                         >{{ ast[childindex] }}</text
@@ -597,8 +598,16 @@
                 </view>
                 <view v-if="bank.ques[ansIndex]">
                   <view class="pad_8 answer">
-                    <view>题目答案:{{ ast[bank.ans[ansIndex] == 1 ? 0 : 1] }}</view>
-                    <view>我的答案:{{ ast[bank.ques[ansIndex] == 1 ? 0 : 1] || "" }}</view>
+                    <view
+                      >题目答案:{{
+                        ast[bank.ans[ansIndex] == 1 ? 0 : 1]
+                      }}</view
+                    >
+                    <view
+                      >我的答案:{{
+                        ast[bank.ques[ansIndex] == 1 ? 0 : 1] || ""
+                      }}</view
+                    >
                   </view>
                   <view class="pad_8 answerInfos">
                     <view class="answerTitle">答案解析</view>
@@ -1032,7 +1041,7 @@ export default {
         let json = JSON.parse(res.data.data.historyExamJson);
         this.examData = res.data.data;
         this.questionList = json;
-        this.getCollectInfo(this.current)
+        this.getCollectInfo(this.current);
       });
     },
 
@@ -1060,78 +1069,32 @@ export default {
      * @param {Object} e单选点击
      */
     radioSelect(optionsId, bindex) {
-      console.log('单选');
+      console.log("单选");
       if (this.questionList[bindex].ques) return;
       this.$set(this.questionList[bindex], "ques", optionsId);
       this.isDoOver();
     },
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        this.questionList.length &&
-          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.ques &&
-                item.ques.every((quesItem, quesIndex) => {
-                  return item.ques[quesIndex] == item.ans[quesIndex];
-                });
-
-              if (isRight) {
-                score += item.score;
-                number++;
-              }
-              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 {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
             examId: this.id,
-            doQuestionIds: doQuestionIds.join(""),
+            doQuestionIds,
             goodsId: this.goodsId,
             orderGoodsId: this.orderGoodsId,
             recordId: this.recordId,
-            rightQuestionNum: number,
+            rightQuestionNum,
             status: 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1172,162 +1135,30 @@ export default {
     /**
      * 提交数据
      */
-    submit() {
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let allScore = 0;
-      let passScore = 0;
-      let doQuestionNum = 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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            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++;
-            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);
-
-            //没选错
-            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;
-              doWrongQuestionIds.push(item.questionId);
-            } else {
-              //部分分
-              // number++;
-              // doWrongQuestionIds.push(item.questionId)
-              lessQuestionNum++;
-              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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            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;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       this.$api
         .examRecordEdit({
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          totalScore: allScore,
           recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 2000,
               icon: "none",
             });
-
             setTimeout(() => {
               uni.redirectTo({
                 url:
@@ -1347,7 +1178,7 @@ export default {
         .examWrongRecord({
           examId: this.id,
           goodsId: this.goodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           orderGoodsId: this.orderGoodsId,
           type: 1, // 题库试卷传1
@@ -1416,14 +1247,22 @@ export default {
 
     judgeSelect(index, bindex) {
       if (this.questionList[bindex].ques) return;
-      this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
-      console.log('this.questionList[bindex]', this.questionList[bindex].ques, this.questionList[bindex])
+      this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
+      console.log(
+        "this.questionList[bindex]",
+        this.questionList[bindex].ques,
+        this.questionList[bindex]
+      );
       this.isDoOver();
     },
 
     judgeSelectChild(ansindex, childindex, bindex) {
       if (this.questionList[bindex].ques[ansindex]) return;
-      this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
+      this.$set(
+        this.questionList[bindex].ques,
+        ansindex,
+        childindex == 0 ? "1" : "0"
+      );
       this.isDoOver();
     },
 
@@ -1433,188 +1272,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false)
       uni.navigateBack({
         delta: 1,
       });
-      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);
-
-            //没选错
-            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) {
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 5) {
-          if (item.ques && (item.ques.imageList || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      //交卷
-      this.$api
-        .examRecordEdit({
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
-          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),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-          }
-        });
-
-      //错题集id提交(客观题)
-      this.$api
-        .examWrongRecord({
-          moduleExamId: this.moduleId || 0,
-          chapterExamId: this.chapterId || 0,
-          examId: this.id,
-          goodsId: this.goodsId,
-          orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
-          recordId: this.recordId,
-          type: 1, // 题库试卷传1
-          doMode: 1, // 做题模式 1章卷 2随机练习
-        })
-        .then((res) => {});
     },
 
     openFooterTab() {
@@ -1629,7 +1290,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
-      this.getCollectInfo(this.current)
+      this.getCollectInfo(this.current);
     },
 
     deleteImg(imgIndex, bankIndex) {
@@ -1753,7 +1414,7 @@ export default {
             },
             success: (result) => {
               // if (result.statusCode === 200) {
-                resolve(ossToken.dir);
+              resolve(ossToken.dir);
               // } else {
               //   uni.showToast({
               //     title: "上传失败",

+ 42 - 188
pages2/bank/questionBankExplainDetail.vue

@@ -10,11 +10,7 @@
         active-color="#007AFF"
       ></u-tabs>
     </view>
-    <swiper
-      class="swiper"
-      :current="current"
-      @change="swiperChange"
-    >
+    <swiper class="swiper" :current="current" @change="swiperChange">
       <swiper-item v-for="(bank, bankIndex) in questionList" :key="bankIndex">
         <view class="pageContent">
           <view class="pad_8 titBox">
@@ -222,8 +218,11 @@
                 >
                   <text
                     :class="{
-                      right: index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
-                      wrong: index == (bank.ques == 1 ? 0 : 1) && bank.ques != bank.ans,
+                      right:
+                        index == (bank.ques == 1 ? 0 : 1) || index != bank.ans,
+                      wrong:
+                        index == (bank.ques == 1 ? 0 : 1) &&
+                        bank.ques != bank.ans,
                     }"
                     class="activeTI"
                     >{{ ast[index] }}</text
@@ -244,7 +243,9 @@
             <view v-if="bank.ques">
               <view class="pad_8 answer">
                 <view>题目答案:{{ ast[bank.ans == 1 ? 0 : 1] }}</view>
-                <view v-if="!explain">我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view>
+                <view v-if="!explain"
+                  >我的答案:{{ ast[bank.ques == 1 ? 0 : 1] }}</view
+                >
               </view>
               <view class="pad_8 answerInfos">
                 <view class="answerTitle">答案解析</view>
@@ -565,7 +566,7 @@
                       <text
                         :class="{
                           right:
-                           childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
+                            childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) ||
                             childindex != bank.ans[ansIndex],
                           wrong:
                             childindex == (bank.ques[ansIndex] == 1 ? 0 : 1) &&
@@ -590,9 +591,15 @@
                 </view>
                 <view v-if="bank.ques[ansIndex]">
                   <view class="pad_8 answer">
-                    <view>题目答案:{{ ast[bank.ans[ansIndex] == 1 ? 0 : 1] }}</view>
+                    <view
+                      >题目答案:{{
+                        ast[bank.ans[ansIndex] == 1 ? 0 : 1]
+                      }}</view
+                    >
                     <view v-if="!explain"
-                      >我的答案:{{ ast[bank.ques[ansIndex] == 1 ? 0 : 1] }}</view
+                      >我的答案:{{
+                        ast[bank.ques[ansIndex] == 1 ? 0 : 1]
+                      }}</view
                     >
                   </view>
                   <view class="pad_8 answerInfos">
@@ -1192,63 +1199,24 @@ export default {
     },
     examRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        this.questionList.length &&
-          this.questionList.forEach((item, index) => {
-            if (item.type == 1) {
-              if (item.ques == item.ans) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 2) {
-              let isRight =
-                item.ques &&
-                item.ques.every((quesItem, quesIndex) => {
-                  return item.ques[quesIndex] == item.ans[quesIndex];
-                });
-
-              if (isRight) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques && item.ques.length) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 3) {
-              if (item.ques == item.ans) {
-                score += item.score;
-                number++;
-              }
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            } else if (item == 4) {
-              if (item.ques.length) {
-                doQuestionNum++;
-              }
-            } else if (item.type == 5) {
-              if (item.ques) {
-                doQuestionNum++;
-              }
-            }
-          });
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .examRecordEdit({
             examId: this.id,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            rightQuestionNum: number,
+            rightQuestionNum,
+            doQuestionIds,
             status: 0,
             moduleExamId: this.moduleId || 0,
             chapterExamId: this.chapterId || 0,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1288,142 +1256,24 @@ export default {
     /**
      * 提交数据
      */
-    submit() {
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let allScore = 0;
-      let passScore = 0;
-      let doWrongQuestionIds = []; //错题和未做题id(客观题)
-      let doQuestionIds = []; //做过的题目id
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          if (item.ques == item.ans) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            //错误
-            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++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            let checkboxScore = item.score; //获取单题总分数
-            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) {
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选扣一部分
-                if (item.ques) {
-                  if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
-                    checkboxScore = item.partScore;
-                  }
-                } else {
-                  checkboxScore = 0;
-                }
-              });
-            }
-
-            if (checkboxScore <= 0) {
-              //0分
-              item.scoreResult = 0;
-              doWrongQuestionIds.push(item.questionId);
-            } else {
-              //部分分
-              number++;
-              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) {
-            score += item.score;
-            number++;
-            rightQuestionIds.push(item.questionId);
-          } else {
-            doWrongQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        } else if (item.type == 4) {
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-          }
-        } else if (item.type == 5) {
-          if (item.ques) {
-            doQuestionNum++;
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       this.$api
         .examRecordEdit({
           examId: this.id,
           goodsId: this.goodsId,
-          reportStatus: reportStatus,
-          totalScore: allScore,
           recordId: this.recordId,
-          rightQuestionNum: number,
           status: 1,
           moduleExamId: this.moduleId || 0,
           chapterExamId: this.chapterId || 0,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form,
         })
         .then((res) => {
           this.isSubmit = true;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 2000,
@@ -1477,12 +1327,16 @@ export default {
 
     judgeSelect(index, bindex) {
       if (this.questionList[bindex].ques) return;
-      this.$set(this.questionList[bindex], "ques", index == 0 ? '1' : '0');
+      this.$set(this.questionList[bindex], "ques", index == 0 ? "1" : "0");
     },
 
     judgeSelectChild(ansindex, childindex, bindex) {
       if (this.questionList[bindex].ques[ansindex]) return;
-      this.$set(this.questionList[bindex].ques, ansindex, childindex == 0 ? '1' : '0');
+      this.$set(
+        this.questionList[bindex].ques,
+        ansindex,
+        childindex == 0 ? "1" : "0"
+      );
     },
 
     openFooterTab() {
@@ -1497,7 +1351,7 @@ export default {
 
     swiperChange(e) {
       this.current = e.detail.current;
-      this.getCollectInfo(this.current)
+      this.getCollectInfo(this.current);
     },
 
     deleteImg(imgIndex, bankIndex) {
@@ -1620,7 +1474,7 @@ export default {
             },
             success: (result) => {
               // if (result.statusCode === 200) {
-                resolve(ossToken.dir);
+              resolve(ossToken.dir);
               // } else {
               //   uni.showToast({
               //     title: "上传失败",

+ 4 - 4
pages2/bank/question_report.vue

@@ -62,7 +62,7 @@
             <!-- {{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}% -->
           </view>
           <view>正确率</view>
-          <view>不含简答/案例题</view>
+          <view>不含主观题</view>
         </view>
         <view class="right">
           <view class="flex up">
@@ -140,7 +140,7 @@
         >
         <view
           class="btnACs"
-          v-if="doMode != 3 && (entryType != 'random' || nextExamId)"
+          v-if="doMode != 3 && (entryType == 'daily' || nextExamId)"
           @click="backBank"
           >继续做题</view
         >
@@ -246,7 +246,7 @@ export default {
       bankNum: 5, // 随机练习的题目数量
       examName: "", // 试卷名称
       doMode: "",
-      courseType:''
+      courseType: "",
     };
   },
   onUnload() {},
@@ -268,7 +268,7 @@ export default {
     this.chapterId = option.chapterId || 0;
     this.goodsId = option.goodsId || "";
     this.doMode = option.doMode;
-    this.courseType = option.courseType
+    this.courseType = option.courseType;
     this.examWrongRecordWrongNum();
     this.bankExamNextExam();
     // await this.bankExam();

+ 3 - 391
pages2/class/questionBank.vue

@@ -1686,135 +1686,6 @@ export default {
         return;
       }
       this.submit("leaveNow");
-      return;
-      let score = 0; //计算总分
-      let reportStatus = 0;
-      let number = 0;
-      let doQuestionIds = []; //做过的题目id
-      let doQuestionNum = 0; //做过的题目数量
-      let passScore = 0;
-      let allScore = 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++;
-          } else {
-            item.scoreResult = 0;
-          }
-
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else if (item.type == 2) {
-          let isRight =
-            item.ques &&
-            item.ques.every((quesItem, quesIndex) => {
-              return item.ques[quesIndex] == item.ans[quesIndex];
-            });
-
-          if (isRight) {
-            //全对
-            item.scoreResult = item.score;
-            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;
-                }
-              });
-
-            //没选错
-            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) {
-              item.scoreResult = 0;
-            } else {
-              item.scoreResult = checkboxScore;
-            }
-
-            score += checkboxScore;
-          }
-
-          if (item.ques && item.ques.length) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else if (item.type == 3) {
-          if (item.ques == item.ans) {
-            item.scoreResult = item.score;
-            score += item.score;
-            number++;
-          } else {
-            item.scoreResult = 0;
-          }
-          if (item.ques) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-          allScore += item.score;
-        } else {
-          allScore += item.score;
-        }
-      });
-
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      this.$api
-        .bankRecordEdit({
-          moduleId: this.moduleId || 0,
-          chapterId: this.chapterId || 0,
-          sectionId: this.sectionId || 0,
-          gradeId: this.gradeId,
-          courseId: this.courseId,
-          orderGoodsId: this.orderGoodsId,
-          goodsId: this.goodsId,
-          examId: this.id,
-          recordId: this.recordId,
-          reportStatus: reportStatus,
-          rightQuestionNum: number,
-          doQuestionNum: doQuestionNum,
-          status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          performance: score,
-          totalScore: allScore,
-          type: this.examType,
-          // examTime: parseInt(this.allTimes),
-          // doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          // historyExamJson: JSON.stringify(this.questionList)
-        })
-        .then((res) => {});
     },
     /**
      * 立即交卷
@@ -1830,118 +1701,6 @@ export default {
     examRecordEdit() {
       if (!this.isSubmit) {
         this.submit("leave");
-        return;
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let reportStatus = 0;
-        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++;
-            }
-          } else if (item.type == 2) {
-            let isRight =
-              item.ques &&
-              item.ques.every((quesItem, quesIndex) => {
-                return item.ques[quesIndex] == item.ans[quesIndex];
-              });
-
-            if (isRight) {
-              score += item.score;
-              number++;
-            } else {
-              let hasPart = false;
-              let checkboxScore = 1; //获取单题总分数
-              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) => {
-                  //漏选扣一部分
-                  if (item.ques) {
-                    if (item.ques.indexOf(item.ans[quesIndex]) == -1) {
-                      checkboxScore += item.partScore;
-                      hasPart = true;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (!hasPart) {
-                item.scoreResult = 0;
-              } else {
-                lessQuestionNum++;
-                item.scoreResult = checkboxScore;
-                score += checkboxScore;
-                // number++;
-              }
-            }
-
-            if (item.ques && item.ques.length) {
-              doQuestionNum++;
-            }
-          } else if (item.type == 3) {
-            if (item.ques == item.ans) {
-              score += item.score;
-              number++;
-            }
-
-            if (item.ques) {
-              doQuestionNum++;
-            }
-          } else if (item == 4) {
-            if (item.ques.length) {
-              doQuestionNum++;
-            }
-          } else if (item.type == 5) {
-            if (item.ques) {
-              doQuestionNum++;
-            }
-          }
-        });
-
-        if (score >= 60) {
-          reportStatus = 1;
-        }
-
-        this.$api
-          .bankRecordEdit({
-            moduleId: this.moduleId || 0,
-            chapterId: this.chapterId || 0,
-            sectionId: this.sectionId || 0,
-            gradeId: this.gradeId,
-            courseId: this.courseId,
-            orderGoodsId: this.orderGoodsId,
-            goodsId: this.goodsId,
-            examId: this.id,
-            recordId: this.recordId,
-            lessQuestionNum: lessQuestionNum,
-            performance: score,
-            reportStatus: reportStatus,
-            status: 1,
-            type: this.examType,
-            // historyExamJson: JSON.stringify(this.questionList)
-          })
-          .then((res) => {});
       }
     },
 
@@ -2487,146 +2246,7 @@ export default {
      * 交卷
      */
     submit(typesubmit) {
-      console.log("交卷", typesubmit);
-      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);
-
-            //没选错
-            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++;
-              // doWrongQuestionIds.push(item.questionId);
-              lessQuestionNum++;
-              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.$method.calculateScore(this.questionList);
       clearInterval(this.timer);
       //交卷
       this.$api
@@ -2638,21 +2258,13 @@ export default {
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
           courseId: this.courseId,
-          rightQuestionNum: number,
-          lessQuestionNum: lessQuestionNum,
           status: 1,
-          doQuestionIds: doQuestionIds.join(","),
-          rightQuestionIds: rightQuestionIds.join(","),
-          doQuestionNum: doQuestionNum,
-          performance: score,
-          totalScore: allScore,
           type: this.examType,
           examTime: parseInt(this.allTimes),
           doTime: parseInt(this.allTimes) - parseInt(this.lastTime),
-          historyExamJson: JSON.stringify(this.questionList),
+          ...form
         })
         .then((res) => {
           this.isSubmit = true;
@@ -2705,7 +2317,7 @@ export default {
           examId: this.id,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          questionIds: doWrongQuestionIds,
+          questionIds: form.questionIds,
           recordId: this.recordId,
           type: 2, // 视频课程的传2
           doMode: this.doMode,

+ 17 - 431
pages5/examBank/index.vue

@@ -1199,191 +1199,10 @@ export default {
     leaveNow() {
       this.needBack = false;
       this.isSubmit = true;
+      this.submit(false);
       uni.navigateBack({
         delta: 1,
       });
-      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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        // passScore = item.passScore
-        if (item.type == 1) {
-          //正确
-
-          console.log(item.ques, item.ans);
-          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);
-
-            //没选错
-            if (checkboxScore) {
-              checkboxScore = 0;
-              item.ans.forEach((ans, quesIndex) => {
-                //漏选只能得部分分数
-                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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于60分及格
-      if (score >= 60) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
-      if (this.subscribeId) {
-        this.mockSubscribeEdit();
-      }
-
-      //交卷
-      this.$api
-        .mockRecordEdit({
-          examId: this.examId,
-          reportStatus: reportStatus,
-          recordId: this.recordId,
-          rightQuestionNum: number,
-          eachExamId: this.eachExamId,
-          status: 1,
-          lessQuestionNum: lessQuestionNum,
-          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),
-        })
-        .then((res) => {
-          this.isSubmit = true;
-          if (res.data.code == 200) {
-          }
-        });
-
-      //错题集id提交(客观题)
-      if (doWrongQuestionIds.length) {
-        this.$api
-          .mockWrongRecord({
-            eachExamId: this.eachExamId,
-            examId: this.examId,
-            questionIds: doWrongQuestionIds,
-            recordId: this.recordId,
-            doMode: this.doMode,
-          })
-          .then((res) => {});
-      }
     },
     /**
      * 立即交卷
@@ -1399,115 +1218,26 @@ export default {
      */
     mockRecordEdit() {
       if (!this.isSubmit) {
-        let number = 0;
-        let score = 0;
-        let doQuestionNum = 0;
-        let doQuestionIds = []; //做过的题目id
-        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 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;
-                    }
-                  } else {
-                    checkboxScore = 0;
-                  }
-                });
-              }
-
-              if (checkboxScore <= 0) {
-                //0分
-              } else {
-                //部分分
-                // number++;
-                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);
-            }
-          }
-        });
-
         if (this.subscribeId) {
           this.mockSubscribeEdit();
         }
-
+        let {
+          doQuestionNum,
+          doQuestionIds,
+          rightQuestionNum,
+          historyExamJson,
+        } = this.$method.calculateScore(this.questionList);
         this.$api
           .mockRecordEdit({
             examId: this.examId,
             eachExamId: this.eachExamId,
             goodsId: this.goodsId,
             recordId: this.recordId,
-            doQuestionIds: doQuestionIds.join(","),
-            rightQuestionNum: number,
+            doQuestionIds,
+            rightQuestionNum,
             status: 1,
-            doQuestionNum: doQuestionNum,
-            historyExamJson: JSON.stringify(this.questionList),
+            doQuestionNum,
+            historyExamJson,
           })
           .then((res) => {});
       }
@@ -1978,147 +1708,8 @@ export default {
     /**
      * 交卷
      */
-    submit() {
-      console.log("itme--", 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 lessQuestionNum = 0;
-      let rightQuestionIds = []; //做对的题目id
-      this.questionList.forEach((item, index) => {
-        passScore = item.passScore;
-        if (item.type == 1) {
-          //正确
-          if (item.ques == item.ans) {
-            console.log("sfsofhusdho");
-            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.length || item.ques.text)) {
-            doQuestionNum++;
-            doQuestionIds.push(item.questionId);
-          }
-        }
-      });
-
-      //大于及格
-      if (score >= passScore) {
-        reportStatus = 1;
-      } else {
-        reportStatus = 0;
-      }
-
+    submit(isShowTip = true) {
+      let form = this.$method.calculateScore(this.questionList);
       if (this.subscribeId) {
         this.mockSubscribeEdit();
       }
@@ -2128,23 +1719,18 @@ export default {
         .mockRecordEdit({
           examId: this.examId,
           eachExamId: this.eachExamId,
-          reportStatus: reportStatus,
           recordId: this.recordId,
-          rightQuestionNum: number,
           status: 1,
-          lessQuestionNum: lessQuestionNum,
-          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;
           if (res.data.code == 200) {
+            if (!isShowTip) {
+              return;
+            }
             uni.showToast({
               title: "交卷成功",
               duration: 1000,