unitAnswer.vue 5.6 KB

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