ksScoreShijuan.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="phone-score-page">
  3. <!-- 导航区域 -->
  4. <customNavbarVue :title="data.ksName" :show-back-btn="true" @back="handleBack"></customNavbarVue>
  5. <!-- 上方区域 -->
  6. <topCard v-if="data.ksName" @openCard="handleOpenCard" :name="data.ksName" :zyLevelName="data.zyLevelName" :userScore="data.userScore" :Score="data.ksScore"></topCard>
  7. <!-- 段落 -->
  8. <view class="score-shiti-content">
  9. <!-- 试题区域 -->
  10. <view v-if="activeSt">
  11. <template v-if="activeSt.stTypeId == 1">
  12. <!-- 单选 -->
  13. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  14. </template>
  15. <template v-if="activeSt.stTypeId == 2">
  16. <!-- 多选 -->
  17. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  18. </template>
  19. <template v-if="activeSt.stTypeId == 3">
  20. <!-- 判断 -->
  21. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  22. </template>
  23. <template v-if="activeSt.stTypeId == 4">
  24. <!-- 填空 -->
  25. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  26. </template>
  27. </view>
  28. <!-- 解析 -->
  29. <view v-if="activeSt" class="score-answer-box">
  30. <view class="phone-question-answer-box" v-if="activeSt.stTypeId != 4">
  31. <view class="phone-line-title">答案解析</view>
  32. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  33. <view class="zqda-row">正确答案:<text>{{answerRes.result}}</text></view>
  34. <view class="ndda-row">您的答案:<text>{{answerRes.reply}}</text></view>
  35. <view class="dajx-row">答案解析:
  36. <rich-text :nodes="answerRes.answer"></rich-text>
  37. </view>
  38. </view>
  39. <view class="phone-question-answer-box" v-else>
  40. <view class="phone-line-title">答案解析</view>
  41. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  42. <view class="zqda-row">正确答案:
  43. <view v-for="(item,index) in answerRes.result">{{`填空${index+1}`}} : {{item}}</view>
  44. </view>
  45. <view class="ndda-row">您的答案:
  46. <view v-for="(item,index) in answerRes.reply"> {{`填空${index+1}`}}: {{item}}</view>
  47. </view>
  48. <view class="dajx-row">答案解析:
  49. <rich-text :nodes="answerRes.answer"></rich-text>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 上下按钮 -->
  55. <view class="score-bottom-box" v-if="activeSt">
  56. <view @click="handleOpenCard" class="score-num-box">
  57. <icon class="score-num-icon" :style="{ backgroundImage: 'url(' + data.imgsArr.shitiNumIcon + ')' }"></icon>
  58. <text class="active-num">{{activeSt && activeSt.onlyNum||0}}</text>/<text>{{data.StListForSearch.length}}</text>
  59. </view>
  60. <view>
  61. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn" @click="handlePrev" v-if="!isFistStId">上一题</button>
  62. <button type="default" size="mini" hover-class="none"class="phone-green-btn score-answer-btn" @click="handleNext" v-if="!isLastStId">下一题</button>
  63. <button type="default" size="mini" hover-class="none"class="phone-green-btn score-answer-btn" @click="handleBack" v-if="isLastStId">完成</button>
  64. </view>
  65. </view>
  66. <!-- 答题卡 -->
  67. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  68. <view class="answer-card-popup">
  69. <customNavbarVue title="答题卡" :show-back-btn="true" @back="handlePopupBack"></customNavbarVue>
  70. <view class="card-content-box">
  71. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData" :key="paragraphIndex">
  72. <view class="paragraph-title">
  73. {{paragraph.name}}
  74. </view>
  75. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  76. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </uni-popup>
  82. </view>
  83. </template>
  84. <script setup>
  85. import topCard from "@/components/score/topCard.vue"
  86. import danxuan from "@/components/questions/danxuan.vue";
  87. import duoxuan from "@/components/questions/duoxuan.vue";
  88. import tiankong from "@/components/questions/tiankong.vue";
  89. import panduan from "@/components/questions/panduan.vue";
  90. import {useQuestionTools} from "@/components/questions/useQuestionTools.js";
  91. import { onLoad } from "@dcloudio/uni-app";
  92. import cacheManager from '@/utils/cacheManager.js';
  93. import {ref,reactive,computed,watch,nextTick} from "vue";
  94. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  95. import * as ksApi from "@/api/kaoshi.js"
  96. const {
  97. checkDanxuanReply,
  98. checkDuoxuanReply,
  99. checkPanduanReply,
  100. checkTiankongReply,
  101. getLetterByIndex
  102. } = useQuestionTools();
  103. const hisId = ref(null)
  104. const popupRef = ref(null)
  105. const data = reactive({
  106. ksId: null,
  107. ksName: '',
  108. stTotal: 0,
  109. zyLevelName: '',
  110. userScore: '',
  111. ksScore: 0,
  112. StListForSearch: [],
  113. duanluo: [],
  114. from: '',
  115. imgsArr: {
  116. shitiNumIcon: '',
  117. },
  118. })
  119. const questionData = ref([]);
  120. const progress = reactive({
  121. dlIndex: 0,
  122. dtIndex: 0
  123. })
  124. const dlName = computed(() => {
  125. if (data.StListForSearch && activeSt.value) {
  126. return data.StListForSearch[activeSt.value.onlyNum].paragraphName
  127. } else {
  128. return ''
  129. }
  130. })
  131. const activeSt = computed(() => {
  132. if (questionData.value.length) {
  133. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  134. } else {
  135. return null
  136. }
  137. })
  138. const answerRes = computed(() => {
  139. const qa = activeSt.value ;
  140. let score = qa.userScore;
  141. let reply = '';
  142. let result = '';
  143. let answer = qa.answer;
  144. if (qa.stTypeId == 1) {
  145. // 单选题
  146. if (qa.reply && qa.reply.trim() !== '') {
  147. reply = getLetterByIndex(qa.reply)
  148. } else {
  149. reply = '未答'
  150. }
  151. if (qa.result) {
  152. result = getLetterByIndex(qa.result)
  153. } else {
  154. result = '无答案'
  155. }
  156. }
  157. if (qa.stTypeId == 2) {
  158. // 多选题
  159. if (qa.reply && qa.reply.length) {
  160. reply = qa.reply.map(item => {
  161. if (item.trim()) {
  162. return getLetterByIndex(item.trim())
  163. }
  164. }).join(',')
  165. } else {
  166. reply = '未答'
  167. }
  168. if (qa.result) {
  169. result = qa.result.map(item => {
  170. if (item.trim()) {
  171. return getLetterByIndex(item.trim())
  172. }
  173. }).join(',')
  174. } else {
  175. result = '无答案'
  176. }
  177. }
  178. if (qa.stTypeId == 3) {
  179. // 判断题
  180. if (qa.reply === '') {
  181. reply = '未答'
  182. } else if (qa.reply == 0) {
  183. reply = '错误'
  184. }else if (qa.reply == 1) {
  185. reply = '正确'
  186. }
  187. if (qa.result == 0) {
  188. result = '错误'
  189. }else if (qa.result == 1) {
  190. result = '正确'
  191. }
  192. }
  193. if (qa.stTypeId == 4) {
  194. let reply = qa.reply || [];
  195. let result =qa.result || [];
  196. // 填空题
  197. return {score,reply,result,answer}
  198. } else {
  199. return {
  200. score,reply,result,answer
  201. }
  202. }
  203. })
  204. const isFistStId = computed(() => {
  205. if (data.StListForSearch.length) {
  206. return data.StListForSearch[0].stId == activeSt.value.stId
  207. } else {
  208. return false
  209. }
  210. });
  211. const isLastStId = computed(() => {
  212. if (data.StListForSearch.length) {
  213. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  214. } else {
  215. return false
  216. }
  217. });
  218. onLoad((options) => {
  219. hisId.value = options.hisId;
  220. data.from = options.from;
  221. data.imgsArr.shitiNumIcon = cacheManager.get('projectImg').shiti_num_icon;
  222. initPage()
  223. })
  224. function getQaClass(qa) {
  225. if (qa.marked && qa.marked === true) {
  226. return 'paragraph-qa-block-mark';
  227. } else {
  228. if (qa.stTypeId == 1) {
  229. if (checkDanxuanReply(qa)) {
  230. return 'paragraph-qa-block-done';
  231. } else {
  232. return 'paragraph-qa-block-init';
  233. }
  234. } else if (qa.stTypeId == 2) {
  235. if (checkDuoxuanReply(qa)) {
  236. return 'paragraph-qa-block-done';
  237. } else {
  238. return 'paragraph-qa-block-init';
  239. }
  240. } else if (qa.stTypeId == 3) {
  241. if (checkPanduanReply(qa)) {
  242. return 'paragraph-qa-block-done';
  243. } else {
  244. return 'paragraph-qa-block-init';
  245. }
  246. } else if (qa.stTypeId == 4) {
  247. if (checkTiankongReply(qa)) {
  248. return 'paragraph-qa-block-done';
  249. } else {
  250. return 'paragraph-qa-block-init';
  251. }
  252. }
  253. }
  254. }
  255. function skipQuestion(dlIndex, dtIndex) {
  256. progress.dlIndex = dlIndex;
  257. progress.dtIndex = dtIndex;
  258. handlePopupBack()
  259. }
  260. function answerCardItemClick(qa) {
  261. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  262. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  263. }
  264. function handleBack() {
  265. const pages = getCurrentPages();
  266. if (pages.length>1) {
  267. uni.navigateBack()
  268. } else {
  269. /* if (data.from == 'chengjiList') {
  270. uni.redirectTo({
  271. url: "/pages/client/Chengji/list"
  272. })
  273. } else if (data.from == 'kaoshi'){
  274. uni.redirectTo({
  275. url: "/pages/client/Kaoshi/list"
  276. })
  277. } */
  278. history.back();
  279. }
  280. }
  281. function formatDuanluoList() {
  282. let uIndex = 0; // 试题num
  283. let iDuanluo = 0; // 段落num
  284. let result = [];
  285. for (const duanluo of data.duanluo) {
  286. let paragraph = {
  287. qas: [],
  288. };
  289. paragraph.name = duanluo.name;
  290. let iQa = 0; // 当前试题序号
  291. let order = 0; // 当前题型中第几题
  292. for (const iDanxuan of duanluo.danxuan) {
  293. iDanxuan.type = 'danxuan';
  294. iDanxuan.marked = false;
  295. iDanxuan.onlyNum = uIndex + 1;
  296. iDanxuan.order = order;
  297. iDanxuan.iQa = iQa;
  298. paragraph.qas.push(iDanxuan);
  299. uIndex++;
  300. order++;
  301. iQa++;
  302. data.StListForSearch.push({
  303. stId: iDanxuan.stId,
  304. paragraphName: paragraph.name,
  305. dlIndex: iDuanluo,
  306. dtIndex: iDanxuan.iQa,
  307. num: iDanxuan.onlyNum
  308. })
  309. }
  310. order = 0;
  311. for (const iDuoxuan of duanluo.duoxuan) {
  312. iDuoxuan.type = 'duoxuan';
  313. iDuoxuan.marked = false;
  314. iDuoxuan.onlyNum = uIndex + 1;
  315. iDuoxuan.order = order;
  316. paragraph.qas.push(iDuoxuan);
  317. iDuoxuan.iQa = iQa;
  318. uIndex++;
  319. order++;
  320. iQa++;
  321. data.StListForSearch.push({
  322. stId: iDuoxuan.stId,
  323. paragraphName: paragraph.name,
  324. dlIndex: iDuanluo,
  325. dtIndex: iDuoxuan.iQa,
  326. num: iDuoxuan.onlyNum
  327. })
  328. }
  329. order = 0;
  330. for (const iPanduan of duanluo.panduan) {
  331. iPanduan.type = 'panduan';
  332. iPanduan.marked = false;
  333. iPanduan.onlyNum = uIndex + 1;
  334. iPanduan.order = order;
  335. paragraph.qas.push(iPanduan);
  336. iPanduan.iQa = iQa;
  337. uIndex++;
  338. order++;
  339. iQa++;
  340. data.StListForSearch.push({
  341. stId: iPanduan.stId,
  342. paragraphName: paragraph.name,
  343. dlIndex: iDuanluo,
  344. dtIndex: iPanduan.iQa,
  345. num: iPanduan.onlyNum
  346. })
  347. }
  348. order = 0;
  349. for (const iTiankong of duanluo.tiankong) {
  350. iTiankong.type = 'tiankong';
  351. iTiankong.marked = false;
  352. iTiankong.onlyNum = uIndex + 1;
  353. iTiankong.order = order;
  354. paragraph.qas.push(iTiankong);
  355. iTiankong.iQa = iQa;
  356. uIndex++;
  357. order++;
  358. iQa++;
  359. data.StListForSearch.push({
  360. stId: iTiankong.stId,
  361. paragraphName: paragraph.name,
  362. dlIndex: iDuanluo,
  363. dtIndex: iTiankong.iQa,
  364. num: iTiankong.onlyNum
  365. })
  366. }
  367. iDuanluo++;
  368. questionData.value.push(paragraph)
  369. }
  370. }
  371. function handlePrev() {
  372. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  373. const index = qa.num - 1;
  374. if (index > 0) {
  375. const result = data.StListForSearch[index - 1];
  376. progress.dlIndex = result.dlIndex;
  377. progress.dtIndex = result.dtIndex
  378. }
  379. }
  380. function handleNext() {
  381. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  382. const index = qa.num - 1;
  383. if (index < data.StListForSearch.length) {
  384. const result = data.StListForSearch[index + 1];
  385. progress.dlIndex = result.dlIndex;
  386. progress.dtIndex = result.dtIndex
  387. }
  388. }
  389. function initPage() {
  390. ksApi.getClientKsChengjiView({hisId: hisId.value}).then(res => {
  391. const { duanluoList,ksName, zyLevelName,userScore,ksScore } = res.data;
  392. data.ksName = ksName;
  393. data.zyLevelName = zyLevelName;
  394. data.userScore = userScore;
  395. data.ksScore = ksScore;
  396. data.duanluo = duanluoList;
  397. formatDuanluoList();
  398. })
  399. }
  400. function handlePopupBack() {
  401. popupRef.value.close()
  402. }
  403. function handleOpenCard() {
  404. popupRef.value.open('top')
  405. }
  406. </script>
  407. <style>
  408. </style>