unitAnswer.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <uni-popup ref="popupRef" :animation="false" :is-mask-click="false"
  3. mask-background-color="rgba(255, 255, 255, 0.6);" class="ezy-popup-width-all">
  4. <view class="ezy-result-page">
  5. <view class="icon-title-navBar-box">
  6. <view @click="handleBack" class="nav-bar-icon"></view>
  7. <view class="nav-bar-title">答案</view>
  8. </view>
  9. <view class="exam-body">
  10. <view class="xx-jd-box">
  11. <view class="xx-row">
  12. <view>当前学习进度</view>
  13. <view class="text-row">
  14. <text class="dq-jd-text">{{current+1}}</text>
  15. <text class="dq-jd-line">/</text>{{myList.length}}</view>
  16. </view>
  17. <progress :percent="(current+1)/myList.length * 100" class="exam-progress-box"
  18. stroke-width="10" backgroundColor="#3c7dfd" activeColor="#ffd11c"/>
  19. </view>
  20. <view class="shiti-frame-box">
  21. <w-swiper :list="myList" :positionIndex="current" class="result-exam-swiper" @change="onSwiperChange">
  22. <template v-slot:default="{item,index}">
  23. <view class="body" v-if="item.mta_show">
  24. <danxuan :question="item" showError v-if="item.type == '1'"></danxuan>
  25. <panduan :question="item" showError v-if="item.type == '2'"></panduan>
  26. <tiankong :question="item" showError v-if="item.type == '3'"
  27. :placeholders="item.placeholders"></tiankong>
  28. <view class="answer-content-box">
  29. <view class="answer-title">答案</view>
  30. <view class="answer-content-border answer-btn-box" v-if="item.type!=3">
  31. <!-- 你的答案 -->
  32. <view class="answer-item-left">
  33. <text class="answer-item-title">您的答案</text>
  34. <text class="answer-item-error">{{showAnswerReply(item)}}</text>
  35. <view class="answer-line"></view>
  36. </view>
  37. <!-- 答案 -->
  38. <view class="answer-item-right">
  39. <text class="answer-item-title">正确答案</text>
  40. <text class="answer-item-correct">{{showAnswerResult(item)}}</text>
  41. </view>
  42. </view>
  43. <!-- 填空题答案 -->
  44. <view class="answer-content-border tiankong-answer-content-box" v-else>
  45. <view class="tiankong-answer-title">正确答案</view>
  46. <view v-for="(ict,cindex) in showAnswerResult(item)" :key="cindex"
  47. class="tiankong-answer-row">
  48. <text class="answer-index-box">{{cindex+1}}</text>
  49. <text v-for="(xItem,xindex) in ict" :key="xindex">
  50. <text> {{xItem}} </text>
  51. <text v-if="xindex != ict.length-1">/</text>
  52. </text>
  53. </view>
  54. </view>
  55. <!-- 试题解析 -->
  56. <view class="answer-stjx-box">
  57. <view class="answer-text-title">试题解析:</view>
  58. <rich-text :nodes="item.answer" class="answer-rich-text"></rich-text>
  59. <!-- 试题视频 -->
  60. <view class="answer-text-title">视频讲解:</view>
  61. <view class="answer-video-box">
  62. <img :src="item.cover"/>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. </w-swiper>
  69. <!-- 左右滑动提示 -->
  70. <view class="swiper-tip-box">
  71. 左右滑动查看更多题目
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 解析浮层数据 -->
  77. <questionJiexi ref="jiexiRef"></questionJiexi>
  78. </uni-popup>
  79. </template>
  80. <script setup>
  81. import questionJiexi from './questionJiexi.vue';
  82. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  83. import danxuan from "@/components/question/danxuan.vue";
  84. import panduan from "@/components/question/panduan.vue";
  85. import tiankong from "@/components/question/tiankong.vue";
  86. import {
  87. useQuestionTools
  88. } from "@/components/question/useQuestionTools.js";
  89. import {
  90. computed
  91. } from "vue";
  92. const {
  93. getLetterByIndex
  94. } = useQuestionTools();
  95. import {
  96. ref
  97. } from "vue";
  98. const props = defineProps({
  99. list: {
  100. type: Array,
  101. },
  102. code: {
  103. type: String,
  104. default: 'cj'
  105. }
  106. })
  107. const myList = computed(() => {
  108. return props.list.map(item => {
  109. return {
  110. ...item,
  111. code: 'cj'
  112. }
  113. })
  114. })
  115. const emits = defineEmits(['back'])
  116. const current = ref(0)
  117. const popupRef = ref(null)
  118. const jiexiRef = ref(null);
  119. function onSwiperChange(index) {
  120. current.value = index;
  121. uni.$emit('swiper-change', index)
  122. }
  123. // 切换成绩
  124. function showPopup() {
  125. popupRef.value.open()
  126. }
  127. function closePopup() {
  128. popupRef.value.close()
  129. }
  130. // 展示
  131. function showJiexiPopup(data) {
  132. jiexiRef.value.showPopup(data);
  133. }
  134. function handleBack() {
  135. // 从 单元测试 到 岛 的路由参数
  136. emits('back')
  137. }
  138. function showAnswerResult(item) {
  139. if (item.type == 1) {
  140. // 单选题
  141. return getLetterByIndex(item.result)
  142. } else if (item.type == 2) {
  143. if (item.result == 1) {
  144. return '正确'
  145. } else {
  146. return '错误'
  147. }
  148. } else if (item.type == 4) {
  149. return getLetterByIndex(item.result)
  150. } else {
  151. return item.result
  152. }
  153. }
  154. function showAnswerReply(item) {
  155. if (item.type == 1) {
  156. if (item.reply == null) {
  157. return '未答'
  158. }
  159. // 单选题
  160. return getLetterByIndex(item.reply)
  161. } else if (item.type == 2) {
  162. if (item.reply == null) {
  163. return '未答'
  164. }
  165. if (item.reply == 1) {
  166. return '正确'
  167. } else {
  168. return '错误'
  169. }
  170. } else if (item.type == 4) {
  171. if (item.reply == null) {
  172. return '未答'
  173. }
  174. // 单选题
  175. return getLetterByIndex(item.reply)
  176. } else {
  177. return item.reply
  178. }
  179. }
  180. defineExpose({
  181. showPopup,
  182. closePopup
  183. })
  184. </script>