闫增涛
2024-09-07 892efc9976feb68ce1a3a4d759317e2585d67ebe
packageBookService/pages/bookServices/examination/examination.js
@@ -1,6 +1,9 @@
import {
  getPublicImage
} from "../../../../assets/js/middleGround/tool";
import {
  loginInfo
} from '../../../../assets/js/login';
const app = getApp();
Page({
  /**
@@ -15,6 +18,7 @@
    isCountdownRunning: true, // 是否倒计时
    countdownTime: 0, // 倒计时时间
    storeInfo: '',
    jslx: '',
    bookId: "",
    productLinkPath: "",
    rootCmsItemId: "",
@@ -49,7 +53,8 @@
    startTime: "", //进入页面当前时间
    pauseTime: 0, //暂停时间
    showDialog: false, // 未提交退出拦截弹窗
    showId: ''
    showId: '',
    isShowDialog: false, // 测试报告弹窗是否显示
  },
  /**
@@ -70,6 +75,7 @@
      idPathList: options.idPathList ? JSON.parse(options.idPathList) : [],
      answerType: options.answerType,
      storeInfo: options.storeInfo,
      jslx: options.jslx,
    });
    wx.setNavigationBarTitle({
      title: options.answerTitle,
@@ -80,7 +86,21 @@
        mockid: options.mockid,
      });
    }
    this.init();
    const token = wx.getStorageSync(app.config.tokenKey)
    if (!token) {
      loginInfo(app, (data) => {
        if (data) {
          this.init();
        } else {
          this.init();
        }
      })
    } else {
      this.init()
    }
  },
  /**
@@ -464,7 +484,6 @@
    const inputData = e.detail.value.detail.value;
    const id = e.detail.value.currentTarget.dataset.id;
    const index = Number(e.detail.value.currentTarget.dataset.index);
    console.log(index);
    const questionList = this.data.questionDataList;
    questionList.forEach((item) => {
      if (item.id == id) {
@@ -531,7 +550,8 @@
      submitStatus: true,
      loading: true,
    });
    const child = this.selectComponent("#question-options");
    const child = this.selectComponent('#question-options');
    if (
      this.data.answerType == "option" ||
      this.data.answerType == "errorQuestion" ||
@@ -547,7 +567,11 @@
    if (this.data.answerType == "option") {
      this.toggleCountdown();
      this.recordAnswerData();
      child.openTestReportDialog();
      // this.selectComponent 拿不到 组件了, 改为监听组件传值 打开弹窗
      // child.openTestReportDialog();
      this.setData({
        isShowDialog: true
      })
    } else if (
      this.data.answerType == "collectQuestion" ||
      this.data.answerType == "errorQuestion"
@@ -590,7 +614,10 @@
          }),
        }, ],
      });
      child.openTestReportDialog();
      // child.openTestReportDialog();
      this.setData({
        isShowDialog: true
      })
    }
    this.setData({
      loading: false,
@@ -820,7 +847,7 @@
      let query = {
        path: "*",
        queryType: "*",
        storeInfo: this.data.storeInfo,
        productId: this.data.bookId,
        cmsPath: pathitem.productLinkPath,
        itemFields: {
@@ -840,6 +867,9 @@
          size: 999,
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        this.setData({
          total: res.datas.cmsDatas[0].datas.length,
@@ -856,7 +886,7 @@
          });
        }
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          if (this.data.storeInfo) {
          if (this.data.storeInfo || this.data.jslx) {
            if (item.Embedded_QuestionBank_QuestionType == 'singleChoice') {
              pathitem.name = "单选题"
            } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') {
@@ -1040,6 +1070,9 @@
            questionDataList: questionList,
            cardList: cardUpdatedList,
          });
          console.log(
            '题目', this.data.questionDataList
          );
        });
      });
    }
@@ -1088,7 +1121,7 @@
      // 简答 翻译
      questionList[index].isRight = null;
    } else if (item.questionType == "completion") {
      if (item.answer == "string") {
      if (typeof item.answer == "string") {
        item.isRight = item.answer == item.userAnswer[0];
      } else {
        if (item.answer.length != item.userAnswer.length) {
@@ -1355,7 +1388,6 @@
    for (let qindex = 0; qindex < this.data.collectList.length; qindex++) {
      const qitem = this.data.collectList[qindex];
      let query = {
        storeInfo: this.data.storeInfo,
        path: "*",
        cmsPath: this.data.rootCmsItemId,
        cmsType: "*",
@@ -1374,6 +1406,9 @@
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        let questionArr = [];
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
@@ -1603,7 +1638,6 @@
    let multipleChoiceArr = []; // 多选
    let completionArr = []; // 填空
    let query = {
      storeInfo: this.data.storeInfo,
      path: "*",
      cmsPath: this.data.rootCmsItemId,
      cmsType: "*",
@@ -1622,6 +1656,9 @@
        Embedded_QuestionBank_Difficulty: [],
      },
    };
    if (this.data.storeInfo) {
      query.storeInfo = this.data.storeInfo
    }
    await app.MG.store.getProductDetail(query).then((res) => {
      let questionArr = [];
      res.datas.cmsDatas[0].datas.forEach((item, index) => {
@@ -1889,7 +1926,6 @@
        itemIds.push(item.id + "");
      });
      let query = {
        storeInfo: this.data.storeInfo,
        path: "*",
        cmsPath: this.data.rootCmsItemId,
        cmsType: "*",
@@ -1908,6 +1944,9 @@
          Embedded_QuestionBank_Difficulty: [],
        },
      };
      if (this.data.storeInfo) {
        query.storeInfo = this.data.storeInfo
      }
      await app.MG.store.getProductDetail(query).then((res) => {
        res.datas.cmsDatas[0].datas.forEach((item, index) => {
          // 循环questionList,给每题赋值分数