unitAnswer.vue 6.0 KB

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