litian
2024-11-22 020d40734a2062300d8b1651a1688fc987590c0a
Merge branch 'master' of http://182.92.203.7:2001/r/TextbookReader
4个文件已修改
210 ■■■■■ 已修改文件
src/assets/js/middleGround/tool.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/components/formula.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/examination/components/list.vue 171 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/examination/index.vue 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/js/middleGround/tool.js
@@ -417,6 +417,7 @@
// 获取不受保护的图片
export function getPublicImage(md5, width, height,storeInfo) {
  if(md5 && md5.includes('http')) return md5 + `?md5=${md5}`
  let src = null;
  if (md5) {
    src = requestCtx + `/file/GetPreViewImage?md5=${md5}`;
src/views/components/formula.vue
@@ -48,7 +48,7 @@
<style lang="less">
  .mathField {
    width: 500px;
    // width: 500px;
    margin-top: 10px;
  }
src/views/examination/components/list.vue
@@ -7,12 +7,21 @@
      v-show="item.infoList.length"
    >
      <p class="catalogName" :style="{ color: primaryColor }">
        <span v-if="nindex == 0">一、</span>
        <span v-if="nindex == 1">二、</span>
        <span v-if="nindex == 2">三、</span>
        <span v-if="nindex == 3">四、</span>
        <span v-if="nindex == 4">五、</span>
        <span>{{ item.catalogName }}</span>
        <span class="catalogName-box" >
          <span v-if="nindex == 0">一、</span>
          <span v-if="nindex == 1">二、</span>
          <span v-if="nindex == 2">三、</span>
          <span v-if="nindex == 3">四、</span>
          <span v-if="nindex == 4">五、</span>
          <span>{{ item.catalogName }}</span>
        </span>
        <img
          :src="item.isCollect ? isHeart : heart"
          alt=""
          class="collect-png"
          @click="handleCollect(nindex)"
          v-if="item.type == 'material'"
        />
      </p>
      <ul>
        <li v-for="(value, index) in item.infoList" :key="value.id" :id="'listItem-' + value.id">
@@ -46,7 +55,7 @@
              ></el-image>
              <!-- 文字加图片 -->
              <p class="stemTxtAndImage titleText" v-else-if="value.stemStyle == 'TxtAndImage'">
                <span> {{ value.stem.stemTxt }}</span>
                <span v-html="value.stem.stemTxt" ></span>
                <el-image
                  :src="getPublicImage(value.stem.stemImage, 150)"
                  :preview-src-list="[getPublicImage(value.stem.stemImage)]"
@@ -56,16 +65,20 @@
              <!-- 填空题题干 -->
              <p class="titleText" v-if="value.questionType == 'completion'">
                <span v-for="(itemText, indexText) in value.stem" :key="indexText">
                  <span v-if="typeof itemText == 'string'" v-html="itemText"></span>
                  <span style="display: flex;align-items: center;" v-if="typeof itemText == 'string'" v-html="itemText"></span>
                  <!-- &nbsp; -->
                  <input
                  <!-- <input
                    v-else
                    type="text"
                    class="input"
                    v-model.trim="value.userAnswer[itemText.num]"
                    :disabled="value.isComplete"
                    :style="{ backgroundColor: inputBc }"
                  />
                  /> -->
                  <math-field v-else @input="onChangeInput($event,nindex,index,indexText)" class="mathField" :menuItems="[]">
                    {{ value.userAnswer[itemText.num] }}
                    </math-field
                  >
                  <!-- &nbsp; -->
                </span>
              </p>
@@ -77,14 +90,14 @@
                v-cloak
              ></p>
            </div>
            <!-- 收藏 -->
            <img
              :src="value.isCollect ? isHeart : heart"
              alt=""
              class="collect-png"
              @click="handleCollect(nindex, index)"
              v-if="!(hideCollect && value.questionType == 'shortAnswer')"
              v-if="item.type != 'material'"
            />
            <!-- 收藏 -->
          </div>
          <div class="questionContent">
            <!-- 单选 -->
@@ -98,7 +111,7 @@
                v-for="content in value.option"
                :key="content.value"
                :label="content.value"
                @change="onChangeRadio(nindex,index)"
                @change="onChangeRadio(nindex, index)"
                border
                :class="
                  value.optionStyle == 'Image' ||
@@ -118,7 +131,7 @@
                    :preview-src-list="[getPublicImage(content.img)]"
                    v-if="isReal"
                  ></el-image>
                  <img :src="content.img" alt="" v-if="value.isJson" class="radio-img"  />
                  <img :src="content.img" alt="" v-if="value.isJson" class="radio-img" />
                  <el-image
                    v-else
                    :src="getPublicImage(content.img, 115)"
@@ -202,7 +215,7 @@
            <el-input
              :disabled="value.isComplete"
              style="width: 94%; margin: 0 auto"
              v-else-if="value.questionType == 'shortAnswer'"
              v-else-if="value.questionType == 'shortAnswer' ||value.questionType =='formula'"
              type="textarea"
              :rows="6"
              placeholder="请输入内容"
@@ -217,18 +230,20 @@
                  value.questionType == 'completion')
              "
            >
              <el-button @click="onChangeRadio(nindex,index)" style="margin-top: 10px">查看解析</el-button>
              <el-button @click="onChangeRadio(nindex, index)" style="margin-top: 10px"
                >查看解析</el-button
              >
            </div>
            <!-- 提交后解析 -->
            <div class="analysis" v-if="value.isComplete">
              <ul class="analysis-box">
                <li class="headerConent" style="width:60%">
                <li class="headerConent" style="width: 60%">
                  <!-- 正确错误标识 -->
                    <ul class="mark">
                  <ul class="mark">
                    <li v-if="value.isRight" class="mark-correct">正确</li>
                    <li v-if="value.isRight == false" class="mark-error">错误</li>
                    </ul>
                  <p  :title="arrayToString(value.answer)">
                  </ul>
                  <p :title="arrayToString(value.answer)">
                    <span>【正确答案】:</span>
                    <span v-html="arrayToString(value.answer)" class="correctBox"></span>
                  </p>
@@ -238,23 +253,22 @@
                    style="margin-left: 20px"
                  >
                    <span>您的答案:</span>
                    <span class="errorBox" >{{
                    <span class="errorBox">{{
                      arrayToString(value.userAnswer) ? arrayToString(value.userAnswer) : '-'
                    }}</span>
                  </p>
                </li>
                <li>
                  <div class="difficulty" v-if="value.difficulty">
                        <span style="color: #333">难度等级:</span>
                        <el-rate
                          v-model="value.difficulty"
                          :max="3"
                          size="large"
                          disabled
                          disabled-void-color="#949494"
                        />
                      </div>
                    <span style="color: #333">难度等级:</span>
                    <el-rate
                      v-model="value.difficulty"
                      :max="3"
                      size="large"
                      disabled
                      disabled-void-color="#949494"
                    />
                  </div>
                </li>
              </ul>
              <el-collapse
@@ -269,11 +283,11 @@
                      <div class="headerConent sitgBox">
                        <p v-if="!value.isUnfold" class="al-cn">
                          <span class="analysisColor">展开解析</span>
                          <img :src="openIcon" alt="" class="analysis-icon">
                          <img :src="openIcon" alt="" class="analysis-icon" />
                        </p>
                        <p v-else>
                          <span class="analysisColor">收起解析</span>
                          <img :src="closeIcon" alt="" class="analysis-icon">
                          <img :src="closeIcon" alt="" class="analysis-icon" />
                        </p>
                      </div>
                    </div>
@@ -288,13 +302,13 @@
                <el-collapse-item :name="value.id" class="objective">
                  <template #title>
                    <div class="headerBox">
                      <p v-if="!value.isUnfold"  class="al-cn">
                      <p v-if="!value.isUnfold" class="al-cn">
                        <span class="analysisColor">展开答案与解析</span>
                        <img :src="openIcon" alt="" class="analysis-icon">
                        <img :src="openIcon" alt="" class="analysis-icon" />
                      </p>
                      <p v-else  class="al-cn">
                      <p v-else class="al-cn">
                        <span class="analysisColor">收起答案与解析</span>
                        <img :src="closeIcon" alt="" class="analysis-icon">
                        <img :src="closeIcon" alt="" class="analysis-icon" />
                      </p>
                    </div>
                  </template>
@@ -327,20 +341,20 @@
</template>
<script setup lang="ts">
import { defineProps, onMounted, ref,reactive } from 'vue'
import { defineProps, onMounted, ref, reactive } from 'vue'
import { getPublicImage } from '@/assets/js/middleGround/tool.js'
import heart from '@/assets/images/examination/collectIcon.png'
import isHeart from '@/assets/images/examination/collectClickIcon.png'
import openIcon from '@/assets/images/examination/open.png'
import closeIcon from '@/assets/images/examination/close.png'
const props = defineProps({ cardList: Array, collectList: Array })
const emits = defineEmits([ 'onChangeRadio','setCollect'])
const emits = defineEmits(['onChangeRadio', 'setCollect','onChangeInput'])
// const presentId = ref<Number>(props.collectList[0])
onMounted(() => {
  // if (props.collectList) presentId.value = props.collectList[0]
})
// 数组转为字符串方法
const arrayToString = (data:any) => {
const arrayToString = (data: any) => {
  // 检查是否为数组
  if (Array.isArray(data)) {
    // 使用 join 方法将数组转换为字符串,默认使用逗号分隔
@@ -350,7 +364,7 @@
    return data.replace(/<[^>]*>/g, '')
  }
}
const isHaveAnswer = (data:any) => {
const isHaveAnswer = (data: any) => {
  if (typeof data == 'string') {
    data = data
      .replace(/<[^>]*>/g, '')
@@ -371,18 +385,25 @@
  }
}
// 收藏按钮
const handleCollect = (num:number,number:number) => {
  emits('setCollect',num,number)
const handleCollect = (num: number, number: number) => {
  emits('setCollect', num, number)
}
// 单选框输入
const onChangeRadio = (num:number,number:number) => {
  emits('onChangeRadio', num,number)
const onChangeRadio = (num: number, number: number) => {
  emits('onChangeRadio', num, number)
}
const onChangeInput = (event: any,index:number,cindex:number,dindex:number) => {
  emits('onChangeInput',event.target.value,index,cindex,dindex)
}
</script>
<style lang="less" scoped>
.catalogName {
  display: flex;
  margin-top: 40px;
  .catalogName-box {
    width: 94%;
  }
}
.collect-png {
  cursor: pointer;
@@ -454,7 +475,6 @@
    display: flex;
    align-items: flex-start;
    span {
      height: 24px;
      line-height: 24px;
      text-align: center;
      font-size: 16px;
@@ -462,6 +482,9 @@
      font-weight: bold;
    }
    .titleText {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      padding: 0 10px 10px 10px;
      min-width: 90%;
      font-size: 14px;
@@ -542,8 +565,8 @@
  width: 100%;
  padding: 0 20px;
  font-size: 14px;
  background-color: #E0F2FF ;
  color: #3B93FE;
  background-color: #e0f2ff;
  color: #3b93fe;
  .checkAnalysis {
    cursor: pointer;
    height: 100%;
@@ -554,7 +577,7 @@
/deep/ .el-collapse-item__content {
  width: 100%;
  padding: 0 20px;
  background-color: #E0F2FF;
  background-color: #e0f2ff;
  font-size: 14px;
  color: #333;
}
@@ -595,7 +618,8 @@
.mark {
  font-size: 14px;
  color: #fff;
  .mark-error,.mark-correct {
  .mark-error,
  .mark-correct {
    white-space: nowrap;
    min-height: 20px;
    line-height: 18px;
@@ -606,29 +630,29 @@
    background-color: #1fbc1f;
  }
  .mark-error {
    background-color: #FF5E5E;
    background-color: #ff5e5e;
  }
}
.headerConent {
      height: 100%;
      display: flex;
      align-items: center;
      .el-image {
        width: 9px;
        height: 9px;
      }
      .correct {
        color: #70B503;
        width: 200px;
        text-align: left;
      }
      .error {
        text-align: left;
        margin-left: 40px;
        width: 200px;
        color: #FF5E5E;
      }
    }
  height: 100%;
  display: flex;
  align-items: center;
  .el-image {
    width: 9px;
    height: 9px;
  }
  .correct {
    color: #70b503;
    width: 200px;
    text-align: left;
  }
  .error {
    text-align: left;
    margin-left: 40px;
    width: 200px;
    color: #ff5e5e;
  }
}
.difficulty {
  display: flex;
  align-items: center;
@@ -648,6 +672,11 @@
  background-color: red;
}
.primary-text-color {
  color: #3B93FE;
  color: #3b93fe;
}
.mathField {
  min-width: 200px;
  max-width: 518px;
  margin-top: 10px;
}
</style>
src/views/examination/index.vue
@@ -85,6 +85,7 @@
              :cardList="examination.cardList"
              @setCollect="setCollect"
              @onChangeRadio="onChangeRadio"
              @onChangeInput="onChangeInput"
            />
          </div>
        </li>
@@ -190,7 +191,7 @@
    getErrorList()
  } else if (props.type == 'collectQuestion') {
    examination.submitStatus = true
    await getcollectId() // 获取收藏题目
    await getcollectId() // 获取收藏题目id
    // 收藏夹
  } else if (props.type == 'errorQuestion') {
    examination.submitStatus = true
@@ -244,7 +245,7 @@
  } else if (item.questionType == 'singleChoice' || item.questionType == 'judge') {
    // 单选 判断
    item.isRight = item.answer == item.userAnswer
  } else if (item.questionType == 'shortAnswer') {
  } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') {
    // 简答 翻译
    item.isRight = null
  } else if (item.questionType == 'completion') {
@@ -275,7 +276,7 @@
        citem.isUnfold = ''
        examination.isCollapse = false
      } else {
        citem.questionType == 'shortAnswer' ? (citem.isUnfold = true) : (citem.isUnfold = citem.id)
        citem.questionType == 'shortAnswer' || citem.questionType == 'formula' ? (citem.isUnfold = true) : (citem.isUnfold = citem.id)
        examination.isCollapse = true
      }
    }
@@ -289,8 +290,13 @@
  examination.submitStatus = true
}
// 题目收藏按钮,收藏和取消同一接口,取消数组减去该项id
const setCollect = (num: number, number: number) => {
  const item = examination.cardList[num].infoList[number]
const setCollect = (num: number, number?: number) => {
  let item = null
  if(number) {
   item = examination.cardList[num].infoList[number]
  } else {
    item = examination.cardList[num]
  }
  item.isCollect = !item.isCollect
  if (item.isJson) {
    // json题目收藏取消
@@ -663,6 +669,7 @@
}
// 获取收藏夹
const getCollectDataList = async () => {
  console.log('收藏id',examination.allCollect)
  // 开始请求
  let oldData = null
  let oldList:any = []
@@ -752,7 +759,7 @@
        isSubmit: false, // 查看解析
        isRight: null, // 是否正确
        isComplete: false,
        isCollect: examination.collectList.indexOf(item.id) > -1 ? true : false,
        isCollect: true,
        isUnfold: ''
      }
      // 多选和填空答案肯为数组,要转换JSON格式
@@ -889,7 +896,7 @@
      }
    }
  }
  console.log('收藏json',jsonCollectList);
  for (let index = 0; index < jsonCollectList.length; index++) {
    const item = jsonCollectList[index]
  if (item.questionType == 'singleChoice') {
@@ -900,11 +907,11 @@
      examination.cardList[2].infoList.push(item)
    } else if (item.questionType == 'completion') {
      examination.cardList[3].infoList.push(item)
    } else if (item.questionType == 'shortAnswer') {
    } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') {
      examination.cardList[4].infoList.push(item)
    } else if (item.type && item.type == 'material') {
      examination.cardList[examination.cardList.length] = item
    }
    }
  }
  examination.cardList = examination.cardList.filter((item) => item.infoList.length > 0)
  console.log('拼接题', examination.cardList)
@@ -1128,7 +1135,7 @@
      } else if (item.Embedded_QuestionBank_QuestionType == 'completion') {
        questionObj.type = '填空题'
        completionArr.push(questionObj)
      } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer') {
      } else if (item.Embedded_QuestionBank_QuestionType == 'shortAnswer' ) {
        questionObj.type = '简答题'
        shortArr.push(questionObj)
      }
@@ -1185,7 +1192,7 @@
      examination.cardList[2].infoList.push(item)
    } else if (item.questionType == 'completion') {
      examination.cardList[3].infoList.push(item)
    } else if (item.questionType == 'shortAnswer') {
    } else if (item.questionType == 'shortAnswer' || item.questionType == 'formula') {
      examination.cardList[4].infoList.push(item)
    } else if (item.type && item.type == 'material') {
      examination.cardList[examination.cardList.length] = item
@@ -1215,7 +1222,7 @@
      } else if (citem.questionType == 'singleChoice' || citem.questionType == 'judge') {
        if (citem.id == '63825') console.log('i', item)
        citem.isRight = citem.answer == citem.userAnswer
      } else if (citem.questionType == 'shortAnswer') {
      } else if (citem.questionType == 'shortAnswer' || item.questionType == 'formula') {
        // 简答 翻译
        citem.isRight = null
      } else if (citem.questionType == 'completion') {
@@ -1230,7 +1237,7 @@
          }
        }
      }
      if (!citem.isRight && citem.questionType != 'shortAnswer') {
      if (!citem.isRight && citem.questionType != 'shortAnswer' && citem.questionType != 'formula') {
        
        // 客观题回答错误 记录错题
        if (citem.isJson) {
@@ -1419,6 +1426,9 @@
      console.log('错题已清空')
    })
}
const onChangeInput = (value:any,index:number,cindex:number,dindex:number) => {
  examination.cardList[index].infoList[cindex].userAnswer[dindex] = value
}
defineExpose({ handleExaminationDialog })
</script>