1
闫增涛
2024-03-27 b2a6887c94cc7887b03ba1cce578e3fc59a62259
packageBookService/pages/bookServices/examination/examination.js
@@ -246,10 +246,11 @@
    this.setData({
      currentIndex: e.detail.index
    })
    if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') {
      let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
      let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer)
      if (flag) this.handleQuestion(e.detail.index)
    let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0
    const item = this.data.questionDataList[index]
    if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
      let flag = this.isHaveAnswer(item.userAnswer)
      if (flag) this.handleQuestion(index)
    }
  },
  // 点击答题卡跳转题目
@@ -269,21 +270,47 @@
    const id = e.detail.value.currentTarget.dataset.id
    const radioChecked = e.detail.value.detail.value
    const questionList = this.data.questionDataList
    questionList.forEach(item => {
      if (item.id == id) {
    // 我的错题和我的收藏模式下,单选题选择了直接批改
    for (let index = 0; index < questionList.length; index++) {
      const item = questionList[index];
      if (item.id == id && !item.isComplete) {
        item.userAnswer = radioChecked
        item.isUserAnswer = this.isHaveAnswer(radioChecked)
        if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
          debugger
          let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0
          this.handleQuestion(index)
        }
      }
    })
    }
    // questionList.forEach(item => {
    //   if (item.id == id && !item.isComplete) {
    //     item.userAnswer = radioChecked
    //     item.isUserAnswer = this.isHaveAnswer(radioChecked)
    //     if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) {
    //       this.handleQuestion(this.data.currentIndex)
    //     }
    //   }
    // })
    const cardListUpdata = this.data.cardList
    cardListUpdata.forEach(item => {
      item.infoList.forEach(citem => {
        if (citem.id == id) {
    for (let index = 0; index < cardListUpdata.length; index++) {
      const item = cardListUpdata[index];
      for (let cindex = 0; cindex < item.infoList.length; cindex++) {
        const citem = item.infoList[cindex];
        if (citem.id == id && !citem.isComplete) {
          citem.userAnswer = radioChecked
          citem.isUserAnswer = this.isHaveAnswer(radioChecked)
        }
      })
    })
      }
    }
    // cardListUpdata.forEach(item => {
    //   item.infoList.forEach(citem => {
    //     if (citem.id == id && !citem.isComplete) {
    //       citem.userAnswer = radioChecked
    //       citem.isUserAnswer = this.isHaveAnswer(radioChecked)
    //     }
    //   })
    // })
    this.setData({
      questionDataList: questionList,
      cardList: cardListUpdata
@@ -362,10 +389,12 @@
  },
  // 提交逻辑
  submitPaper() {
    // 关闭退出页面监听
    wx.disableAlertBeforeUnload()
    this.setData({
      submitStatus: true
      submitStatus: true,
      loading: true
    })
    const child = this.selectComponent('#question-options')
    if (this.data.answerType == 'option' || this.data.answerType == 'errorQuestion' || this.data.answerType == 'mock') {
@@ -373,7 +402,7 @@
      const qustionList = this.data.questionDataList
      for (let index = 0; index < qustionList.length; index++) {
        const item = qustionList[index];
        if (!item.isComplete) this.handleQuestion(index + 1)
        if (!item.isComplete) this.handleQuestion(index)
      }
    }
    if (this.data.answerType == 'option') {
@@ -423,7 +452,9 @@
      })
      child.openTestReportDialog()
    }
    this.setData({
      loading: false
    })
  },
  // 初始化函数
  async init() {
@@ -435,10 +466,10 @@
    })
    if (this.data.answerType == 'option') {
      if (this.data)
        this.startCountdown()
      this.setData({
        countdownTime: 2 * 60 * 60 * 1000
      })
        // this.startCountdown()
        this.setData({
          countdownTime: 2 * 60 * 60 * 1000
        })
      // 测试答题
      await this.getCollectIdList() // 获取收藏id列表
      await this.getErrorList()   // 获取错题id列表
@@ -788,6 +819,8 @@
        })
      })
    }
    // 有题目再开始倒计时
    if (this.data.questionDataList.length) this.startCountdown()
    this.setData({
      loading: false
    })
@@ -795,7 +828,7 @@
  // 批改题目 (练习,我的错题,我的收藏,,组卷)
  handleQuestion(num) {
    const questionList = this.data.questionDataList
    const index = num - 1 >= 0 ? num - 1 : 0
    const index = num
    if (questionList[index].isComplete) {
      // 题目已完成,跳过
      return true