xiejiebiao 2 years ago
parent
commit
d74b1a4f77
3 changed files with 235 additions and 524 deletions
  1. 14 156
      src/pages/course-exam/index.vue
  2. 202 356
      src/pages/home/index.vue
  3. 19 12
      src/pages/mock-exam/index.vue

+ 14 - 156
src/pages/course-exam/index.vue

@@ -839,7 +839,7 @@ export default {
     this.orderGoodsId = this.$route.query.orderGoodsId;
     await this.getGoodsDetail();
     await this.bankExam();
-    this.doMode == 1 ? this.goodsQuestionList() : this.simulationQuestionList();
+    this.goodsQuestionList();
   },
   beforeDestroy() {
     clearInterval(this.timer);
@@ -905,168 +905,27 @@ export default {
      * 请求题目列表
      */
     goodsQuestionList() {
-      this.$request
-        .goodsQuestionList({
-          examId: this.examId,
-        })
-        .then(async (res) => {
-          if (!res.data.length) {
-            this.$message({
-              type: "warning",
-              message: "该试卷暂无题目",
-            });
-            return;
-          }
-          this.allTimes = res.data[0].answerTime * 60;
-          this.lastTime = res.data[0].answerTime && res.data[0].answerTime * 60;
-
-          res.data.forEach((item, index) => {
-            if (typeof item.jsonStr == "string") {
-              item.jsonStr = JSON.parse(item.jsonStr);
-
-              if (item.type == 2) {
-                //多选
-                item.jsonStr.forEach((str) => {
-                  str.optionsId = "" + str.optionsId;
-                });
-                let arr = item.answerQuestion.split(",");
-                arr.forEach((a, i) => {
-                  arr[i] = "" + a;
-                });
-                item.ans = arr;
-                item.quesSelect = [];
-                item.analysisContent &&
-                  (item.analysisContent = item.analysisContent.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                item.content &&
-                  (item.content = item.content.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                return;
-              } else if (item.type == 5) {
-                //简答题
-                item.ansText = {
-                  text: "",
-                  imageList: [],
-                };
-                item.ques = {
-                  text: "",
-                  imageList: [],
-                };
-                item.analysisContent &&
-                  (item.analysisContent = item.analysisContent.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-                item.content &&
-                  (item.content = item.content.replace(
-                    /<img/gi,
-                    '<img style="max-width:100%;"'
-                  ));
-
-                return;
-              } else if (item.type == 4) {
-                //案例题
-                item.ques = [];
-                item.tabIndex = "0";
-                let ansArr = [];
-                item.jsonStr.forEach((json, index) => {
-                  if (json.type == 1) {
-                    ansArr[index] = json.answerQuestion;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 2) {
-                    json.optionsList.forEach((str) => {
-                      str.optionsId = "" + str.optionsId;
-                    });
-                    let arr = json.answerQuestion.split(",");
-                    arr.forEach((a, i) => {
-                      arr[i] = "" + a;
-                    });
-                    ansArr[index] = arr;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 3) {
-                    ansArr[index] = json.answerQuestion;
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  } else if (json.type == 5) {
-                    ansArr[index] = {
-                      text: "",
-                      imageList: [],
-                    };
-                    json.ansText = {
-                      text: "",
-                      imageList: [],
-                    };
-                    json.ques = {
-                      text: "",
-                      imageList: [],
-                    };
-                    json.content &&
-                      (json.content = json.content.replace(
-                        /<img/gi,
-                        '<img style="max-width:100%;"'
-                      ));
-                  }
-                });
-
-                item.ans = ansArr;
-                return;
-              }
-              item.analysisContent &&
-                (item.analysisContent = item.analysisContent.replace(
-                  /<img/gi,
-                  '<img style="max-width:100%;"'
-                ));
-              item.content &&
-                (item.content = item.content.replace(
-                  /<img/gi,
-                  '<img style="max-width:100%;"'
-                ));
-              item.ques = "";
-              item.ans = item.answerQuestion;
-            }
-          });
-
-          this.questionList = res.data;
-          this.lastCount = this.questionList.length;
-          this.getCollectInfo(this.current);
-          await this.examRecord();
-        });
-    },
-    simulationQuestionList() {
-      this.$request
-        .goodsRandomQuestionList({
+      this.$request[this.doMode==3?'goodsRandomQuestionList':'goodsQuestionList']({
           examId: this.examId,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
         })
-        .then(async (res) => {
-          let { questionList, simulateExamId } = res.data
-          if (!questionList.length) {
+        .then(async ({data}) => {
+          if(this.doMode==3){
+            this.simulateExamId = data.simulateExamId
+            data = data.questionList
+          }
+          if (!data.length) {
             this.$message({
               type: "warning",
               message: "该试卷暂无题目",
             });
             return;
           }
-          this.simulateExamId = simulateExamId
-          this.allTimes = questionList[0].answerTime * 60;
-          this.lastTime = questionList[0].answerTime && questionList[0].answerTime * 60;
-          questionList.forEach((item, index) => {
+          this.allTimes = data[0].answerTime * 60;
+          this.lastTime = data[0].answerTime && data[0].answerTime * 60;
+
+          data.forEach((item, index) => {
             if (typeof item.jsonStr == "string") {
               item.jsonStr = JSON.parse(item.jsonStr);
 
@@ -1186,7 +1045,8 @@ export default {
               item.ans = item.answerQuestion;
             }
           });
-          this.questionList = questionList;
+
+          this.questionList = data;
           this.lastCount = this.questionList.length;
           this.getCollectInfo(this.current);
           await this.examRecord();
@@ -1195,7 +1055,6 @@ export default {
     //拍照
     openPhoto() {
       this.$nextTick(() => {
-        console.log(window.navigator.mediaDevices);
         if (
           (window.navigator.mediaDevices &&
             window.navigator.mediaDevices.getUserMedia) ||
@@ -1558,7 +1417,6 @@ export default {
         if (this.bankType == 2) {
           this.needBack = true;
         }
-        console.log(res.data.simulateStatus, 'simulateStatus')
         this.doMode = res.data.simulateStatus ? 3 : 1;
         return Promise.resolve();
       });

File diff suppressed because it is too large
+ 202 - 356
src/pages/home/index.vue


+ 19 - 12
src/pages/mock-exam/index.vue

@@ -19,6 +19,7 @@
               <div class="left-box">
                 <Header-tab-box
                   :num="questionOverNum(true)"
+                  :allNum="questionList.length"
                   @prevQuestion="prevQuestion"
                   @nextQuestion="nextQuestion"
                 ></Header-tab-box>
@@ -1135,6 +1136,8 @@ export default {
       isAutoSubmit: false,
       examEndTime: 0,
       examStartTime: 0,
+      doMode:1,
+      simulateExamId:''
     };
   },
   async mounted() {
@@ -1284,7 +1287,7 @@ export default {
           questionId: this.questionList[current].questionId,
           goodsId: this.goodsId,
           orderGoodsId: this.orderGoodsId,
-          doMode: 1
+          doMode: this.doMode
         })
         .then((res) => {
           this.$set(this.collectList, current, res.data);
@@ -1320,12 +1323,18 @@ export default {
      * 请求题目列表
      */
     goodsQuestionList() {
-      this.$request
-        .goodsQuestionList({
+      console.log(99988,this.orderGoodsId)
+      this.$request[this.doMode==3?'goodsRandomQuestionList':'goodsQuestionList']({
           examId: this.examId,
+          goodsId: this.goodsId,
+          orderGoodsId: this.orderGoodsId,
         })
-        .then(async (res) => {
-          if (!res.data.length) {
+        .then(async (data) => {
+          if(this.doMode==3){
+            this.simulateExamId = data.simulateExamId
+            data = data.questionList
+          }
+          if (!data.length) {
             this.$message({
               type: "warning",
               message: "该试卷暂无题目",
@@ -1364,10 +1373,8 @@ export default {
             }
           }
 
-          res.data.forEach((item, index) => {
+          data.forEach((item, index) => {
             item.jsonStr = JSON.parse(item.jsonStr);
-
-            console.log(item.type, "item");
             if (item.type == 2) {
               //多选
               item.jsonStr.forEach((str) => {
@@ -1485,13 +1492,12 @@ export default {
             item.ans = item.answerQuestion;
           });
 
-          this.questionList = res.data;
+          this.questionList = data;
           this.lastCount = this.questionList.length;
           this.getCollectInfo(this.current)
           await this.mockRecord();
         });
     },
-
     /**
      * 记录总题数,获取recordId
      * hasSpecial (是否包含简答和案例) true 包含  false 不包含
@@ -1654,10 +1660,10 @@ export default {
         this.$request.bankExam(this.examId).then((res) => {
           this.bankType = res.data.doType;
           this.examData = res.data;
+          this.doMode = res.data.simulateStatus ? 3 : 1;
           if (this.bankType == 2) {
             this.needBack = true;
           }
-
           resolve();
         });
       });
@@ -2126,7 +2132,7 @@ export default {
             questionId: this.questionList[index].questionId,
             goodsId: this.goodsId || "",
             orderGoodsId: this.orderGoodsId,
-            doMode:1
+            doMode:this.doMode
           })
           .then((res) => {
             this.$set(this.collectList, index, true);
@@ -2618,6 +2624,7 @@ export default {
         });
     },
   },
+
 };
 </script>
 

Some files were not shown because too many files changed in this diff