闫增涛
2024-06-28 f0c2c003738addcc452c4e7a001481f245056dec
题库优化
4个文件已修改
118 ■■■■■ 已修改文件
src/views/examination/components/list.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/examination/components/sheet.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/examination/index.vue 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/readerPages/webHome.vue 46 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/examination/components/list.vue
@@ -339,7 +339,7 @@
  // if (props.collectList) presentId.value = props.collectList[0]
})
// 数组转为字符串方法
const arrayToString = (data) => {
const arrayToString = (data:any) => {
  // 检查是否为数组
  if (Array.isArray(data)) {
    // 使用 join 方法将数组转换为字符串,默认使用逗号分隔
@@ -349,7 +349,7 @@
    return data.replace(/<[^>]*>/g, '')
  }
}
const isHaveAnswer = (data) => {
const isHaveAnswer = (data:any) => {
  if (typeof data == 'string') {
    data = data
      .replace(/<[^>]*>/g, '')
@@ -370,7 +370,7 @@
  }
}
// 收藏按钮
const handleCollect = (num,number) => {
const handleCollect = (num:number,number:number) => {
  emits('setCollect',num,number)
}
// 单选框输入
src/views/examination/components/sheet.vue
@@ -102,8 +102,8 @@
import { defineProps, watch, ref, computed, defineEmits, onMounted } from 'vue'
const props = defineProps<{
  cardList: any
  submitStatus: boolean
  answerType: string,
  submitStatus: Boolean
  answerType: String,
  
}>()
@@ -113,7 +113,7 @@
  document.getElementById(`listItem-${id}`)!.scrollIntoView()
}
// 判断是否输入答案
const isHaveAnswer = (data) => {
const isHaveAnswer = (data:any) => {
  if (typeof data == 'string') {
    data = data
      .replace(/<[^>]*>/g, '')
src/views/examination/index.vue
@@ -349,24 +349,24 @@
      domain: 'collectData',
      keys: [props.activeBook.bookId]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('收藏数据', res)
      try {
        const collect = JSON.parse(res[0].value)
        if (collect.length) {
          examination.collectList = collect.find((citem) => citem.type == 'bits').collectList
          examination.collectList = collect.find((citem:any) => citem.type == 'bits').collectList
          examination.allCollect[0].collectList = collect.find(
            (citem) => citem.type == 'bits'
            (citem:any) => citem.type == 'bits'
          ).collectList
          examination.allCollect[1].collectList = collect.find(
            (citem) => citem.type == 'json'
            (citem:any) => citem.type == 'json'
          ).collectList
        }
      } catch (error) {
        console.log('暂无数据')
      }
      if (props.type == 'option') {
        getAnswerInfo(async (res) => {
        getAnswerInfo(async (res:any) => {
          if (res.length) {
            // 有记录,不能答题,状态设为已提交
            examination.submitStatus = true
@@ -921,14 +921,14 @@
      domain: 'errorData',
      keys: [props.activeBook.bookId]
    })
    .then(async (res) => {
    .then(async (res:any) => {
      try {
        const error = JSON.parse(res[0].value)
        if (error.length) {
          console.log('有吗', error)
          examination.errorList = error.find((citem) => citem.type == 'bits').errorList
          examination.allError[0].errorList = error.find((citem) => citem.type == 'bits').errorList
          examination.allError[1].errorList = error.find((citem) => citem.type == 'json').errorList
          examination.errorList = error.find((citem:any) => citem.type == 'bits').errorList
          examination.allError[0].errorList = error.find((citem:any) => citem.type == 'bits').errorList
          examination.allError[1].errorList = error.find((citem:any) => citem.type == 'json').errorList
        }
      } catch (error) {}
      if (examination.allError[0].errorList || examination.allError[1].errorList) {
@@ -960,7 +960,7 @@
  }
  // 开始请求
  let oldData = null
  let oldList = []
  let oldList:any = []
  let cardList = [
    {
      catalogName: '单选题',
@@ -983,11 +983,11 @@
      infoList: []
    }
  ]
  let singleChoiceArr = [] // 单选
  let judgeArr = [] // 判断
  let shortArr = [] // 简答
  let multipleChoiceArr = [] // 多选
  let completionArr = [] // 填空
  let singleChoiceArr:any = [] // 单选
  let judgeArr:any = [] // 判断
  let shortArr:any = [] // 简答
  let multipleChoiceArr:any = [] // 多选
  let completionArr:any = [] // 填空
  // 11
  for (let qindex = 0; qindex < examination.errorList.length; qindex++) {
    const qitem = examination.errorList[qindex]
@@ -1013,10 +1013,10 @@
    }
    const res = await MG.store.getProductDetail(query)
    if (!res.datas) return false
    res.datas.cmsDatas[0].datas.forEach((item, index) => {
    res.datas.cmsDatas[0].datas.forEach((item:any, index:number) => {
      let oldObj = {}
      if (oldList) {
        oldObj = oldList.find((item) => item.id == qitem)
        oldObj = oldList.find((item:any) => item.id == qitem)
      }
      const questionObj = {
        number: index + 1, // 题号
@@ -1081,7 +1081,7 @@
        questionObj.stem.stemImage = getPublicImage(questionObj.stem.stemImage, 150)
      }
      if (questionObj.optionStyle == 'Image' || questionObj.optionStyle == 'TxtAndImage') {
        questionObj.option.forEach((optionItem) => {
        questionObj.option.forEach((optionItem:any) => {
          if (optionItem.img) optionItem.img = getPublicImage(optionItem.img, 150)
        })
      }
@@ -1103,7 +1103,7 @@
          questionObj.questionType == 'judge' ||
          questionObj.questionType == 'multipleChoice')
      ) {
        questionObj.option.forEach((item) => {
        questionObj.option.forEach((item:any) => {
          if (item.txt)
            item.txt = item.txt
              .replace(/\<img/gi, '<img class="option-rich-img"')
@@ -1286,7 +1286,7 @@
        }
      ]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('错题已保存', examination.allError)
    })
  if (props.type == 'option') {
@@ -1331,7 +1331,7 @@
  setUserAnswer(arr)
}
// 未提交退出答题,保存用户答案
const setUserAnswer = (data) => {
const setUserAnswer = (data:any) => {
  MG.identity
    .setUserKey({
      setKeyRequests: [
@@ -1342,7 +1342,7 @@
        }
      ]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('提交用户答题数据成功')
    })
}
@@ -1354,7 +1354,7 @@
      domain: 'beforeAnswerData',
      keys: [props.info.id]
    })
    .then((res) => {
    .then((res:any) => {
      if(res) {
        data = JSON.parse(res[0].value)
      }
@@ -1362,13 +1362,13 @@
    return data
 }
// 获取用户旧答题数据(提交后)
const getAnswerInfo = (callback) => {
const getAnswerInfo = (callback:any) => {
  MG.identity
    .getUserKey({
      domain: 'answerData',
      keys: [props.info.id]
    })
    .then((res) => {
    .then((res:any) => {
      if (callback) callback(res)
    })
}
@@ -1384,18 +1384,18 @@
        }
      ]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('提交用户答题数据成功')
    })
}
// 删除用户答题数据
const deleteAnswerInfo = (callback) => {
const deleteAnswerInfo = (callback:any) => {
  MG.identity
    .delUserKey({
      domain: 'answerData',
      keys: [props.info.id]
    })
    .then((res) => {
    .then((res:any) => {
      if (callback) callback()
    })
}
@@ -1410,7 +1410,7 @@
        }
      ]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('收藏/取消成功')
    })
}
@@ -1425,7 +1425,7 @@
        }
      ]
    })
    .then((res) => {
    .then((res:any) => {
      console.log('错题已保存', examination.allError)
    })
}
src/views/readerPages/webHome.vue
@@ -141,7 +141,7 @@
              <div>附加题</div>
              <div :class="exercisesType == 'additional' ? 'text' : 'line'"></div>
            </div>
            <hr class="hr" v-if="bookConfig.textbookComponents.indexOf('AFC1A288') > -1" />
            <!-- <hr class="hr" v-if="bookConfig.textbookComponents.indexOf('AFC1A288') > -1" />
            <div
              class="tabItem hover"
              @click="selectExercisesType('wrong')"
@@ -149,8 +149,8 @@
            >
              <div>错题本</div>
              <div :class="exercisesType == 'wrong' ? 'text' : 'line'"></div>
            </div>
            <hr class="hr" v-if="bookConfig.textbookComponents.indexOf('A434F2C0') > -1" />
            </div> -->
            <!-- <hr class="hr" v-if="bookConfig.textbookComponents.indexOf('A434F2C0') > -1" />
            <div
              class="tabItem hover"
              @click="selectExercisesType('collection')"
@@ -158,7 +158,7 @@
            >
              <div>收藏夹</div>
              <div :class="exercisesType == 'collection' ? 'text' : 'line'"></div>
            </div>
            </div> -->
          </div>
        </div>
        <!-- 目录 -->
@@ -535,6 +535,11 @@
            </div>
          </div>
        </div>
        <!-- 题库底部收藏夹和错题集 -->
        <ul class="question-bottom" v-if="activeMenu == '题库'">
            <li @click="selectExercisesType('collection')">收藏夹</li>
            <li @click="selectExercisesType('wrong')">错题本</li>
          </ul>
        <!-- 菜单内容收起 -->
        <div class="menuStateBox" v-if="menuState.open">
          <svg
@@ -2340,18 +2345,19 @@
//错题本
const wrongQuestionVisble = ref(false)
const selectExercisesType = (type) => {
  exercisesType.value = type
  searchText.value = ''
  if (type == 'exercises') {
    getExercisesList()
      exercisesType.value = type
      searchText.value = ''
  } else if (type == 'additional') {
    getAdditionalList()
      exercisesType.value = type
      searchText.value = ''
  } else if (type == 'wrong') {
    openExaminationDialog(true, {}, 'errorQuestion')
    questionList.value = []
  } else {
    openExaminationDialog(true, {}, 'collectQuestion')
    questionList.value = []
  }
}
// 题列表点击
@@ -4112,6 +4118,7 @@
      }
    }
    .menuContent {
      // position: relative;
      width: 300px;
      flex-shrink: 0;
      height: calc(100vh - 48px);
@@ -4532,6 +4539,29 @@
        height: calc(100% - 60px);
        overflow-y: auto;
      }
      .questionList {
        height:83%
      }
      .question-bottom {
        position: absolute;
        bottom: 0;
        display: flex;
        justify-content: space-evenly;
        width:300px;
        padding:20px 0;
        background-color:#fff;
        li {
          cursor: pointer;
          width: 65px;
          height:65px;
          border:1px solid #cfcfcf;
          border-radius:10px;
          background-color:#f9f9f9;
          display:flex;
          justify-content: center;
          align-items: center;
        }
      }
    }
    .menuStateBox {
      width: 25px;