unitAnswer.vue 6.0 KB

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