闫增涛
2024-05-15 cc232247648ea4cd6b4d3909bb71caea61e388e1
src/components/examinations/index.vue
@@ -1,6 +1,11 @@
<template>
  <div class="examination" v-loading="loading">
    <div v-for="(item, nindex) in cardList" :key="nindex" class="border-box" v-show="item.infoList.length">
    <div
      v-for="(item, nindex) in cardList"
      :key="nindex"
      class="border-box"
      v-show="item.infoList.length"
    >
      <p class="catalogName">
        <span v-if="nindex == 0">一、</span>
        <span v-if="nindex == 1">二、</span>
@@ -23,8 +28,8 @@
                :style="{
                  marginTop: value.questionType == 'completion' ? '12px' : '0',
                }"
                >{{ index + 1 }}. </span
              >
                >{{ index + 1 }}.
              </span>
              <!-- 听力进度条 -->
              <!-- <answerAudioPlayer :audioUrl="value.src" v-show="item.name == '听力题'" /> -->
              <!-- 题干 -->
@@ -63,7 +68,7 @@
                  v-for="(itemText, indexText) in value.stem"
                  :key="indexText"
                >
                  <span v-if="typeof itemText == 'string'" >{{ itemText }}</span>
                  <span v-if="typeof itemText == 'string'">{{ itemText }}</span>
                  <!-- &nbsp; -->
                  <el-input
                    v-else
@@ -207,7 +212,7 @@
          ></TEditorVue> -->
            <el-input
              :disabled="value.isComplete"
              style="width: 90%; margin: 0 auto"
              style="width: 94%; margin: 0 auto"
              v-else-if="value.questionType == 'shortAnswer'"
              type="textarea"
              :rows="6"
@@ -276,11 +281,11 @@
                      <div class="headerConent sitgBox">
                        <p v-if="!value.isUnfold">
                          <span class="analysisColor">查看解析</span
                          ><el-image  />
                          ><el-image />
                        </p>
                        <p v-else>
                          <span class="analysisColor">收起解析</span
                          ><el-image  />
                          ><el-image />
                        </p>
                      </div>
                    </div>
@@ -313,8 +318,8 @@
                    <span class="analysisColor"
                      >{{
                        value.isUnfold ? "收起答案和解析" : "查看答案与解析"
                      }} </span
                    >
                      }}
                    </span>
                  </p>
                </div>
                <!-- :class="['analysisDetailBox', value.isUnfold ? 'open' : 'close'].join(' ') -->
@@ -360,18 +365,27 @@
    </div>
    <div class="bottom-btn" v-if="!loading">
      <el-button style="height: 34px; padding: 4px 10px">保存</el-button>
      <el-button style="height: 30px; width: 78px; padding: 4px 10px"
        >保存</el-button
      >
      <el-button
        @click="handleQuestion"
        style="border-color: #1eb9ee; height: 34px; padding: 4px 10px"
        style="
          border-color: #1eb9ee;
          height: 30px;
          width: 78px;
          padding: 4px 10px;
        "
        >提交</el-button
      >
      <el-button @click="redo" style="height: 34px; padding: 4px 10px"
      <el-button
        @click="redo"
        style="height: 30px; width: 78px; padding: 4px 10px"
        >重做</el-button
      >
      <el-button
        @click="openAnswers"
        style="border-color: #1eb9ee; height: 34px; padding: 4px 10px"
        style="border-color: #1eb9ee; height: 30px; padding: 4px 10px"
        >查看答案</el-button
      >
    </div>
@@ -386,12 +400,10 @@
  data() {
    return {
      type: "option",
      cardList: [],
      loading: false,
    };
  },
  mounted() {
  },
  mounted() {},
  methods: {
    // 数组转为字符串方法
    arrayToString(data) {
@@ -451,8 +463,6 @@
      this.$data.loading = false;
    },
    watchParsing(data) {
      debugger
      data.isUnfold = !data.isUnfold;
    },
    // // 获取试卷下题目类型
@@ -700,54 +710,52 @@
    // },
    // 批改题目  (练习,我的做题,我的收藏模式下)
    handleQuestion() {
      const list = this.$props.cardList
      const list = this.$props.cardList;
      for (let index = 0; index < list.length; index++) {
        const item = list[index];
        for (let cindex = 0; cindex < item.infoList.length; cindex++) {
          const citem = item.infoList[cindex];
          citem.isComplete = true;
           // 修改题目状态为完成
           citem.isComplete = true;
            // 批改题目
            if (citem.questionType == "multipleChoice") {
              // 多选题
              if (citem.answer.length == citem.userAnswer.length) {
                const sortedArr1 = citem.answer.slice().sort();
                const sortedArr2 = citem.userAnswer.slice().sort();
                citem.isRight = sortedArr1.every(
                  (value, index) => value === sortedArr2[index]
                );
              } else {
          // 修改题目状态为完成
          citem.isComplete = true;
          // 批改题目
          if (citem.questionType == "multipleChoice") {
            // 多选题
            if (citem.answer.length == citem.userAnswer.length) {
              const sortedArr1 = citem.answer.slice().sort();
              const sortedArr2 = citem.userAnswer.slice().sort();
              citem.isRight = sortedArr1.every(
                (value, index) => value === sortedArr2[index]
              );
            } else {
              citem.isRight = false;
            }
          } 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") {
            // 简答 翻译
            citem.isRight = null;
          } else if (citem.questionType == "completion") {
            // 填空
            if (typeof citem.answer == "string") {
              citem.isRight = citem.answer == citem.userAnswer[0];
            } else {
              if (citem.answer.length != citem.userAnswer.length) {
                citem.isRight = false;
              }
            } 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") {
              // 简答 翻译
              citem.isRight = null;
            } else if (citem.questionType == "completion") {
              // 填空
              if (typeof citem.answer == "string") {
                citem.isRight = citem.answer == citem.userAnswer[0];
              } else {
                if (citem.answer.length != citem.userAnswer.length) {
                  citem.isRight = false;
                } else {
                  citem.isRight = citem.answer.every(
                    (value, index) =>
                      value === citem.userAnswer[index]
                  );
                }
                citem.isRight = citem.answer.every(
                  (value, index) => value === citem.userAnswer[index]
                );
              }
            }
          }
        }
      }
      this.$props.cardList = list
      this.$props.cardList = list;
      console.log(this.$props.cardList);
    },
  },
@@ -769,15 +777,16 @@
}
.border-box {
  padding-top: 20px;
  border: 2px solid #e9e9e9;
}
.border-box:first-child {
  border-top:2px solid #e9e9e9 ;
  // border: 2px solid #e9e9e9;
}
.questionContent {
  // display: flex;
  // justify-content: center;
  text-indent: 0em !important;
  margin-left: 20px;
  /deep/ .el-textarea__inner:focus {
    border-color: #15c0f2;
  }
}
.input {
  /deep/ .el-input__inner {
@@ -853,6 +862,8 @@
    display: flex;
    align-items: flex-start;
    .questionNum {
      text-indent: 0 !important;
      margin-right: 5px;
      height: 32px;
      line-height: 32px;
      text-align: center;
@@ -881,7 +892,7 @@
        border-top: 0;
      }
      /deep/ .el-textarea.is-disabled .el-textarea__inner {
        background-color: #fff ;
        background-color: #fff;
      }
      /deep/.el-input__wrapper {
        border-top: 0 !important;
@@ -943,7 +954,7 @@
}
.analysis {
  margin: 20px 0;
  width:550px;
  width: 94%;
  // margin-left: 12px;
}
.el-collapse {