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)
    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
@@ -375,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') {
@@ -472,7 +499,6 @@
        }
        if (mocklist.length && this.data.uuid) {
          const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid)
          debugger
          this.setData({
            'mockData.state': oldMockData.state,
            'mockData.score': oldMockData.score,
@@ -802,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