unitTest.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="ezy-exam-page">
  3. <view class="icon-title-navBar-box">
  4. <view @click="handleBack" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">单元测试</text>
  6. </view>
  7. <view>
  8. <view>
  9. <view>当前学习进度</view>
  10. <view>{{data.current+1}}/{{data.total}}</view>
  11. </view>
  12. <progress :percent="data.current/data.total * 100" :border-radius="30" stroke-width="10" />
  13. </view>
  14. <view class="shiti-frame-box">
  15. <w-swiper :list="data.list" :current="data.current" class="ezy-exam-swiper" @change="onSwiperChange">
  16. <template v-slot:default="{item}">
  17. <view class="body" v-if="item.mta_show">
  18. <danxuan :question="item" v-if="item.type == '1'"></danxuan>
  19. <panduan :question="item" v-if="item.type == '2'"></panduan>
  20. <tiankong :question="item" v-if="item.type == '3'" :placeholders="item.placeholders"></tiankong>
  21. <button type="primary" v-if="item.stId == data.list[data.total-1].stId"
  22. @click="handleSubmit">交卷</button>
  23. </view>
  24. </template>
  25. </w-swiper>
  26. </view>
  27. <!-- 左右滑动提示 -->
  28. <view>
  29. <view>
  30. < <text>左右滑动查看更多题目</text>>
  31. </view>
  32. </view>
  33. <!-- 填空 -->
  34. <FillItem :value="result" ref="popupRef" @blur="onBlur"></FillItem>
  35. <unitResultVue ref="uniResRef" @check-answer="onCheckAnswer" @do-replay="onDoReplay"></unitResultVue>
  36. <unitAnswerVue :list="data.list" ref="uniAnsRef" @back="handleBack"></unitAnswerVue>
  37. </view>
  38. </template>
  39. <script setup>
  40. import mtaRadio from '@/components/question/yingyu/mtaRadio.vue'
  41. import FillItem from "@/components/question/FillItem.vue";
  42. import wSwiper from '@/components/wSwiper/wSwiper.vue';
  43. import danxuan from "@/components/question/danxuan.vue";
  44. import panduan from "@/components/question/panduan.vue";
  45. import tiankong from "@/components/question/tiankong.vue";
  46. import unitResultVue from './components/unitResult.vue';
  47. import unitAnswerVue from "./components/unitAnswer.vue";
  48. import * as httpApi from "@/api/chanpinShuxue.js"
  49. import {
  50. reactive,
  51. ref
  52. } from "vue"
  53. import {
  54. onLoad
  55. } from "@dcloudio/uni-app"
  56. import {
  57. useShuxueTest
  58. } from "./components/useShuxueUnitTest.js"
  59. const {
  60. data,
  61. handleSubmit
  62. } = useShuxueTest(handleSeeResult, handleCheckAnswer)
  63. const curTiankong = ref(null);
  64. const result = ref('');
  65. const popupRef = ref(null);
  66. const uniResRef = ref(null);
  67. const uniAnsRef = ref(null);
  68. function handleSeeResult() {
  69. uniResRef.value.showPopup({
  70. right: data.right,
  71. wrong: data.wrong
  72. })
  73. }
  74. function handleCheckAnswer() {
  75. uniResRef.value.showPopup({
  76. jieId: data.jieId
  77. })
  78. }
  79. function onDoReplay() {
  80. }
  81. function onCheckAnswer() {
  82. uniAnsRef.value.showPopup();
  83. }
  84. onLoad(() => {
  85. uni.$on('tiankong-fillItem', (val) => {
  86. const {
  87. index,
  88. question
  89. } = val;
  90. curTiankong.value = val;
  91. result.value = question.reply[index];
  92. const dom = getPopupRef();
  93. dom && dom.showPopup();
  94. })
  95. })
  96. function getPopupRef() {
  97. return popupRef.value;
  98. }
  99. function onBlur({
  100. result
  101. }) {
  102. if (curTiankong.value) {
  103. uni.$emit('tiankong-setResult', {
  104. index: curTiankong.value.index,
  105. stId: curTiankong.value.question.stId,
  106. result
  107. });
  108. }
  109. const dom = getPopupRef();
  110. dom && dom.handleClear();
  111. }
  112. function handleBack() {
  113. uni.navigateBack()
  114. }
  115. function onSwiperChange(index) {
  116. data.current = index;
  117. uni.$emit('swiper-change', index)
  118. }
  119. </script>
  120. <style lang="scss" scoped>
  121. .swiper-box {
  122. height: 200px;
  123. }
  124. .swiper-item {
  125. display: flex;
  126. flex-direction: column;
  127. justify-content: center;
  128. align-items: center;
  129. height: 200px;
  130. }
  131. </style>