question-result.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view v-if="isReadOnly && question.isLeaf"
  3. class="question-result mt-40 rounded-8 pt-60 pb-40 flex items-center text-center relative">
  4. <ie-image v-if="question.isCorrect" src="/pagesStudy/static/image/icon-answer-correct.png"
  5. class="absolute top-0 left-1/2 -translate-x-1/2 w-222 h-64" :class="{ 'top-30': isOnlySubjective }" />
  6. <ie-image v-else src="/pagesStudy/static/image/icon-answer-incorrect.png"
  7. class="absolute top-0 left-1/2 -translate-x-1/2 w-240 h-64" :class="{ 'top-30': isOnlySubjective }" />
  8. <view v-if="!isOnlySubjective" class="flex-1">
  9. <view class="text-34 text-[#2CC6A0] font-bold">{{ question.answer1 }}</view>
  10. <view class="mt-4 text-26">正确答案</view>
  11. </view>
  12. <view class="h-40 w-1 bg-back"></view>
  13. <view v-if="!isOnlySubjective" class="flex-1">
  14. <view class="text-34 font-bold" :class="[question.isCorrect ? 'text-[#2CC6A0]' : 'text-[#FF5B5C]']">
  15. {{ question.answers.join('') || (question.isNotKnow ? '不会' : '未答') }}
  16. </view>
  17. <view class="mt-4 text-26">我的答案</view>
  18. </view>
  19. </view>
  20. </template>
  21. <script lang="ts" setup>
  22. import { EnumQuestionType, EnumReviewMode } from '@/common/enum';
  23. import { useExam } from '@/composables/useExam';
  24. import { Study, Transfer } from '@/types';
  25. import { EXAM_DATA, EXAM_PAGE_OPTIONS } from '@/types/injectionSymbols';
  26. const examPageOptions = inject(EXAM_PAGE_OPTIONS) || {} as Transfer.ExamAnalysisPageOptions;
  27. const examData = inject(EXAM_DATA) || {} as ReturnType<typeof useExam>;
  28. const { practiceSettings } = examData;
  29. const props = defineProps<{
  30. question: Study.Question;
  31. }>();
  32. const isReadOnly = computed(() => {
  33. const { readonly } = examPageOptions;
  34. if (readonly) {
  35. return true;
  36. }
  37. // 练习模式下,需要背题模式且题目已经做过且解析过
  38. if (practiceSettings.value.reviewMode === EnumReviewMode.DURING_ANSWER && props.question.hasParsed) {
  39. return true;
  40. }
  41. return false;
  42. });
  43. const isOnlySubjective = computed(() => {
  44. return [EnumQuestionType.SUBJECTIVE, EnumQuestionType.SHORT_ANSWER, EnumQuestionType.ESSAY].includes(props.question.typeId);
  45. });
  46. </script>
  47. <style lang="scss" scoped>
  48. .question-result {
  49. box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.06);
  50. }
  51. </style>