xiangpei
2024-10-31 b0edc0c7a4cb8a0063a56b436a63931904f179c3
src/views/grade/components/answer-main/answer-multiple/index.vue
@@ -4,7 +4,7 @@
      <ExamInfo class="mb-5" :questionIndex="currentIndex" :activeQuestion="activeQuestion"></ExamInfo>
      <div class="answer-content">
        <div class="answer-item flex" v-for="item, index in activeQuestion.items" :class="answerState(item)">
        <div class="answer-item flex" v-for="item, index in activeQuestion.questionItemList" :class="answerState(item)">
          <div class="answer-icon flex flex-col justify-center items-center flex-shrink-0">{{ item.prefix }}</div>
          <div class="answer-text text-gray-700">{{ item.content }}</div>
        </div>
@@ -16,19 +16,17 @@
      <div class="analysis-container">
        <div class="analysis-item" :class="analysisState">
          <div class="item-label">您的答案</div>
          <div class="item-info">{{ activeQuestion.correct }}</div>
          <div class="item-info">{{ activeQuestion.answerList ? activeQuestion.answerList.join(','): '未作答' }}</div>
        </div>
        <div class="analysis-item analysis-right">
          <div class="item-label">正确答案</div>
          <div class="item-info">{{ activeQuestion.right }}</div>
          <div class="item-info">{{ activeQuestion.questionAnswer }}</div>
        </div>
        <div class="analysis-item text-gray-700">
          <div class="item-label">解析</div>
          <div class="item-info">Lorem ipsum dolor sit amet consectetur adipisicing elit. Exercitationem beatae possimus
            nostrum facere inventore aliquid vero fuga minus, mollitia temporibus harum commodi, dolores odio nulla
            aliquam maiores eligendi quis? Ad.</div>
          <div class="item-info" v-html="activeQuestion.analyze"></div>
        </div>
      </div>
    </el-scrollbar>
@@ -36,33 +34,38 @@
</template>
<script setup>
import { ref,computed } from 'vue';
import { ref, computed } from 'vue';
import { storeToRefs } from 'pinia';
import ExamInfo from '@/components/ExamInfo/index.vue';
import { useExamStore } from '@/store/index.js';
import { useGradeStore } from '@/store/index.js';
const gradeStore = useGradeStore();
const examStore = useExamStore();
const { currentIndex } = storeToRefs(gradeStore);
const {  currentIndex } = storeToRefs(examStore);
const activeQuestion = ref(examStore.getActiveQuestion);
const activeQuestion = ref(gradeStore.getActiveQuestion);
const formatAnswer = (answer) => {
  return answer.split(',');
};
  if (answer) {
    if(Array.isArray(answer)) {
      return answer;
    } else {
      return answer.split(',');
    }
  }
const currentAnswer = formatAnswer(activeQuestion.value.correct);
const rightAnswer = formatAnswer(activeQuestion.value.right);
};
const currentAnswer = formatAnswer(activeQuestion.value.answerList);
const rightAnswer = formatAnswer(activeQuestion.value.questionAnswer);
const answerState = (item) => {
  const flag1 = currentAnswer.includes(item.prefix);
  const flag1 = currentAnswer ? currentAnswer.includes(item.prefix) : false;
  const flag2 = rightAnswer.includes(item.prefix);
  if (flag1 && flag2) {
    return {
      right: true
    };
  } else {
  } else if (currentAnswer) {
    if (currentAnswer.length < rightAnswer.length) {
      if (!flag1 && flag2) {
        return {
@@ -74,12 +77,16 @@
        return {
          wrong: true
        };
      } else if (!flag1 && flag2) {
        return {
          right: true
        };
      }
    } else {
      return {
        right: flag2,
        wrong: flag1
      }
      };
    }
  }
};
@@ -170,4 +177,4 @@
.analysis-wrong {
  color: var(--wrong-color);
}
</style>
</style>