kaoshiChengjiInfo.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <view class="phone-kaoshi-page">
  3. <customNavbarVue :title="data.name" :show-back-btn="true" @back="handleBack"></customNavbarVue>
  4. <!-- 第一行 -->
  5. <view class="kaoshi-page-title">
  6. <view v-if="activeSt" class="title-types">{{dlName}}</view>
  7. <view>100分钟</view>
  8. </view>
  9. <view class="kaoshi-shiti-content">
  10. <!-- 内容区域 -->
  11. <!-- 试题区域 -->
  12. <view v-if="activeSt">
  13. <template v-if="activeSt.stTypeId == 1">
  14. <!-- 单选 -->
  15. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  16. </template>
  17. <template v-if="activeSt.stTypeId == 2">
  18. <!-- 多选 -->
  19. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  20. </template>
  21. <template v-if="activeSt.stTypeId == 3">
  22. <!-- 判断 -->
  23. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  24. </template>
  25. <template v-if="activeSt.stTypeId == 4">
  26. <!-- 填空 -->
  27. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  28. </template>
  29. <template v-if="activeSt.stTypeId == 5">
  30. <!-- 简答 -->
  31. <jianda :question="activeSt" :key="activeSt.stId"></jianda>
  32. </template>
  33. <template v-if="activeSt.stTypeId == 6">
  34. <!-- 阅读 -->
  35. <yuedu :question="activeSt" :key="activeSt.stId" @yudu-change="onYueduChange"></yuedu>
  36. </template>
  37. </view>
  38. </view>
  39. <template v-if="activeSt">
  40. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev"
  41. @click="handlePrev" v-if="!isFistStId">上一题</button>
  42. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  43. @click="handleNext" v-if="!isLastStId">下一题</button>
  44. </template>
  45. <!-- 答案解析 -->
  46. <scoreAndAnswerVue ref="scoreAnswerRef"></scoreAndAnswerVue>
  47. <scoreAndAnswerAdminTiankong ref="scoreAnswerTkRef"></scoreAndAnswerAdminTiankong>
  48. <scoreAndAnswerAdminJianda ref="scoreAnswerJdRef"></scoreAndAnswerAdminJianda>
  49. </view>
  50. </template>
  51. <script setup>
  52. import {
  53. ref,
  54. reactive,
  55. computed,
  56. watch
  57. } from "vue";
  58. import {
  59. onLoad
  60. } from "@dcloudio/uni-app";
  61. import * as cjApi from "@/api/chengji.js"
  62. import danxuan from "@/components/questionsChengji/danxuan.vue";
  63. import duoxuan from "@/components/questionsChengji/duoxuan.vue";
  64. import tiankong from "@/components/questionsChengji/tiankong.vue";
  65. import panduan from "@/components/questionsChengji/panduan.vue";
  66. import jianda from "@/components/questionsChengji/jianda.vue";
  67. import yuedu from "@/components/questionsChengji/yuedu.vue";
  68. import scoreAndAnswerVue from "@/components/scoreAndAnswer/scoreAndAnswerAdmin.vue";
  69. import scoreAndAnswerAdminTiankong from "@/components/scoreAndAnswer/scoreAndAnswerAdminTiankong.vue";
  70. import scoreAndAnswerAdminJianda from "@/components/scoreAndAnswer/scoreAndAnswerJianda.vue";
  71. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  72. import {
  73. useQuestionTools
  74. } from "@/components/questions/useQuestionTools.js";
  75. const {
  76. checkDanxuanReply,
  77. checkDuoxuanReply,
  78. checkPanduanReply,
  79. checkTiankongReply,
  80. getLetterByIndex,
  81. checkJiandaReply,
  82. checkYueduReply
  83. } = useQuestionTools();
  84. const stTypes = {
  85. 1: '单选题',
  86. 2: '多选题',
  87. 3: '判断题',
  88. 4: '填空题',
  89. }
  90. const popupRef = ref(null)
  91. const scoreAnswerRef = ref(null)
  92. const scoreAnswerTkRef = ref(null)
  93. const startCountDown = ref(false);
  94. const scoreAnswerJdRef = ref(null);
  95. const data = reactive({
  96. hisId: null,
  97. name: '',
  98. stTotal: 0,
  99. stScore: 0,
  100. biaoji: null,
  101. endSecond: 0,
  102. pageSize: 0,
  103. toggleScreenFlag: 0,
  104. toggleScreenSecond: 0,
  105. zhuapai: 0,
  106. duanluo: [],
  107. markDB: [],
  108. StListForSearch: [],
  109. })
  110. const yuduIndexQa = ref(null);
  111. const questionData = ref([]);
  112. const progress = reactive({
  113. dlIndex: 0,
  114. dtIndex: 0
  115. })
  116. const dlName = computed(() => {
  117. if (data.StListForSearch && activeSt.value) {
  118. return data.StListForSearch[activeSt.value.onlyNum - 1].paragraphName
  119. } else {
  120. return ''
  121. }
  122. })
  123. watch(() => data.duanluo, (newVal) => {
  124. // 计算已答试题数量
  125. }, {
  126. deep: true
  127. })
  128. const activeSt = computed(() => {
  129. if (questionData.value.length) {
  130. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  131. } else {
  132. return null
  133. }
  134. })
  135. const isFistStId = computed(() => {
  136. if (data.StListForSearch.length) {
  137. return data.StListForSearch[0].stId == activeSt.value.stId
  138. } else {
  139. return false
  140. }
  141. });
  142. const isLastStId = computed(() => {
  143. if (data.StListForSearch.length) {
  144. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  145. } else {
  146. return false
  147. }
  148. });
  149. onLoad((option) => {
  150. data.hisId = option.hisId;
  151. data.name = option.name;
  152. initKaoshi();
  153. })
  154. function onTimeUp() {
  155. console.log('end')
  156. }
  157. function showAnswerCard() {
  158. popupRef.value.open('top')
  159. }
  160. function handlePopupBack() {
  161. popupRef.value.close()
  162. }
  163. function handlePrev() {
  164. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  165. const index = qa.num - 1;
  166. if (index > 0) {
  167. const result = data.StListForSearch[index - 1];
  168. progress.dlIndex = result.dlIndex;
  169. progress.dtIndex = result.dtIndex
  170. }
  171. // 切换试题时清空阅读提解析
  172. yuduIndexQa.value = null;
  173. }
  174. function handleNext() {
  175. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  176. const index = qa.num - 1;
  177. if (index < data.StListForSearch.length) {
  178. const result = data.StListForSearch[index + 1];
  179. progress.dlIndex = result.dlIndex;
  180. progress.dtIndex = result.dtIndex
  181. }
  182. // 切换试题时清空阅读提解析
  183. yuduIndexQa.value = null
  184. }
  185. function formatDuanluoList(dlData) {
  186. let uIndex = 0; // 试题num
  187. let iDuanluo = 0; // 段落num
  188. let result = [];
  189. for (const duanluo of data.duanluo) {
  190. let paragraph = {
  191. qas: [],
  192. };
  193. paragraph.name = duanluo.name;
  194. let iQa = 0; // 当前试题序号
  195. let order = 0; // 当前题型中第几题
  196. for (const iDanxuan of duanluo.danxuan) {
  197. iDanxuan.type = 'danxuan';
  198. iDanxuan.marked = false;
  199. iDanxuan.onlyNum = uIndex + 1;
  200. iDanxuan.order = order;
  201. iDanxuan.iQa = iQa;
  202. iDanxuan.reply = iDanxuan.result;
  203. paragraph.qas.push(iDanxuan);
  204. uIndex++;
  205. order++;
  206. iQa++;
  207. data.StListForSearch.push({
  208. stId: iDanxuan.stId,
  209. paragraphName: paragraph.name,
  210. dlIndex: iDuanluo,
  211. dtIndex: iDanxuan.iQa,
  212. num: iDanxuan.onlyNum
  213. })
  214. }
  215. order = 0;
  216. for (const iDuoxuan of duanluo.duoxuan) {
  217. iDuoxuan.type = 'duoxuan';
  218. iDuoxuan.marked = false;
  219. iDuoxuan.onlyNum = uIndex + 1;
  220. iDuoxuan.order = order;
  221. paragraph.qas.push(iDuoxuan);
  222. iDuoxuan.reply = iDuoxuan.result;
  223. iDuoxuan.iQa = iQa;
  224. uIndex++;
  225. order++;
  226. iQa++;
  227. data.StListForSearch.push({
  228. stId: iDuoxuan.stId,
  229. paragraphName: paragraph.name,
  230. dlIndex: iDuanluo,
  231. dtIndex: iDuoxuan.iQa,
  232. num: iDuoxuan.onlyNum
  233. })
  234. }
  235. order = 0;
  236. for (const iPanduan of duanluo.panduan) {
  237. iPanduan.type = 'panduan';
  238. iPanduan.marked = false;
  239. iPanduan.onlyNum = uIndex + 1;
  240. iPanduan.order = order;
  241. paragraph.qas.push(iPanduan);
  242. iPanduan.reply = iPanduan.result;
  243. iPanduan.iQa = iQa;
  244. uIndex++;
  245. order++;
  246. iQa++;
  247. data.StListForSearch.push({
  248. stId: iPanduan.stId,
  249. paragraphName: paragraph.name,
  250. dlIndex: iDuanluo,
  251. dtIndex: iPanduan.iQa,
  252. num: iPanduan.onlyNum
  253. })
  254. }
  255. order = 0;
  256. for (const iTiankong of duanluo.tiankong) {
  257. iTiankong.type = 'tiankong';
  258. iTiankong.marked = false;
  259. iTiankong.onlyNum = uIndex + 1;
  260. iTiankong.order = order;
  261. paragraph.qas.push(iTiankong);
  262. iTiankong.reply = iTiankong.result.map(item => item[0]);
  263. iTiankong.iQa = iQa;
  264. uIndex++;
  265. order++;
  266. iQa++;
  267. data.StListForSearch.push({
  268. stId: iTiankong.stId,
  269. paragraphName: paragraph.name,
  270. dlIndex: iDuanluo,
  271. dtIndex: iTiankong.iQa,
  272. num: iTiankong.onlyNum
  273. })
  274. }
  275. order = 0;
  276. for (const iJianda of duanluo.jianda) {
  277. iJianda.marked = false;
  278. iJianda.type = 'jianda';
  279. iJianda.onlyNum = uIndex + 1;
  280. iJianda.order = order;
  281. iJianda.iQa = iQa;
  282. paragraph.qas.push(iJianda);
  283. iJianda.reply = '';
  284. uIndex++;
  285. order++;
  286. iQa++;
  287. data.StListForSearch.push({
  288. stId: iJianda.stId,
  289. paragraphName: paragraph.name,
  290. dlIndex: iDuanluo,
  291. dtIndex: iJianda.iQa,
  292. num: iJianda.onlyNum
  293. })
  294. }
  295. order = 0;
  296. for (const iYuedu of duanluo.yuedu) {
  297. iYuedu.marked = false;
  298. iYuedu.type = 'yuedu';
  299. iYuedu.onlyNum = uIndex + 1;
  300. iYuedu.order = order;
  301. iYuedu.iQa = iQa;
  302. if (iYuedu.duoxuan && iYuedu.duoxuan.length) {
  303. iYuedu.duoxuan.map((qIt) => {
  304. qIt.reply = qIt.reply || [];
  305. return qIt
  306. })
  307. }
  308. if (iYuedu.tiankong && iYuedu.tiankong.length) {
  309. iYuedu.tiankong.map((qIt) => {
  310. qIt.reply = new Array(qIt.count).fill('');
  311. return qIt;
  312. });
  313. }
  314. paragraph.qas.push(iYuedu);
  315. iYuedu.reply = [];
  316. uIndex++;
  317. order++;
  318. iQa++;
  319. data.StListForSearch.push({
  320. stId: iYuedu.stId,
  321. paragraphName: paragraph.name,
  322. dlIndex: iDuanluo,
  323. dtIndex: iYuedu.iQa,
  324. num: iYuedu.onlyNum
  325. })
  326. }
  327. iDuanluo++;
  328. questionData.value.push(paragraph)
  329. console.log(questionData.value)
  330. console.log(paragraph)
  331. }
  332. }
  333. // 切换阅读小题时更新当前试题解析
  334. function onYueduChange(qa) {
  335. yuduIndexQa.value = qa;
  336. }
  337. // 校验阅读解析
  338. function checkYueduJiexi() {
  339. debugger
  340. let qa = yuduIndexQa.value;
  341. let score = qa.userScore;
  342. let reply = '';
  343. let result = '';
  344. let answer = qa.answer;
  345. if (qa.stTypeId == 0) {
  346. // 单选题
  347. if (qa.reply && qa.reply.trim() !== '') {
  348. reply = getLetterByIndex(qa.reply)
  349. } else {
  350. reply = '未答'
  351. }
  352. if (qa.result) {
  353. result = getLetterByIndex(qa.result)
  354. } else {
  355. result = '无答案'
  356. }
  357. scoreAnswerRef.value.showPopup({
  358. score,
  359. reply,
  360. result,
  361. answer
  362. })
  363. }
  364. if (qa.stTypeId == 2) {
  365. // 多选题
  366. if (qa.reply && qa.reply.length) {
  367. reply = qa.reply.map(item => {
  368. if (item.trim()) {
  369. return getLetterByIndex(item.trim())
  370. }
  371. }).join(',')
  372. } else {
  373. reply = '未答'
  374. }
  375. if (qa.result) {
  376. result = qa.result.map(item => {
  377. if (item.trim()) {
  378. return getLetterByIndex(item.trim())
  379. }
  380. }).join(',')
  381. } else {
  382. result = '无答案'
  383. }
  384. scoreAnswerRef.value.showPopup({
  385. score,
  386. reply,
  387. result,
  388. answer
  389. })
  390. }
  391. if (qa.stTypeId == 3) {
  392. // 判断题
  393. if (qa.reply === '') {
  394. reply = '未答'
  395. } else if (qa.reply == 0) {
  396. reply = '错误'
  397. } else if (qa.reply == 1) {
  398. reply = '正确'
  399. }
  400. if (qa.result == 0) {
  401. result = '错误'
  402. } else if (qa.result == 1) {
  403. result = '正确'
  404. }
  405. scoreAnswerRef.value.showPopup({
  406. score,
  407. reply,
  408. result,
  409. answer
  410. })
  411. }
  412. if (qa.stTypeId == 4) {
  413. let reply = qa.reply || [];
  414. let result = qa.result || [];
  415. // 填空题
  416. scoreAnswerTkRef.value.showPopup({
  417. score,
  418. reply,
  419. result,
  420. answer
  421. })
  422. }
  423. if (qa.stTypeId == 5) {
  424. // 简单题
  425. let reply = qa.reply ? '未答' : qa.reply;
  426. let result = qa.result;
  427. scoreAnswerJdRef.value.showPopup({
  428. score,
  429. reply,
  430. result,
  431. answer
  432. })
  433. }
  434. }
  435. // 获取解析
  436. function handleCheckJiexi() {
  437. const qa = activeSt.value;
  438. let score = qa.userScore;
  439. let reply = '';
  440. let result = '';
  441. let answer = qa.answer;
  442. if (qa.stTypeId == 1) {
  443. // 单选题
  444. if (qa.reply && qa.reply.trim() !== '') {
  445. reply = getLetterByIndex(qa.reply)
  446. } else {
  447. reply = '未答'
  448. }
  449. if (qa.result) {
  450. result = getLetterByIndex(qa.result)
  451. } else {
  452. result = '无答案'
  453. }
  454. scoreAnswerRef.value.showPopup({
  455. score,
  456. reply,
  457. result,
  458. answer
  459. })
  460. }
  461. if (qa.stTypeId == 2) {
  462. // 多选题
  463. if (qa.reply && qa.reply.length) {
  464. reply = qa.reply.map(item => {
  465. if (item.trim()) {
  466. return getLetterByIndex(item.trim())
  467. }
  468. }).join(',')
  469. } else {
  470. reply = '未答'
  471. }
  472. if (qa.result) {
  473. result = qa.result.map(item => {
  474. if (item.trim()) {
  475. return getLetterByIndex(item.trim())
  476. }
  477. }).join(',')
  478. } else {
  479. result = '无答案'
  480. }
  481. scoreAnswerRef.value.showPopup({
  482. score,
  483. reply,
  484. result,
  485. answer
  486. })
  487. }
  488. if (qa.stTypeId == 3) {
  489. // 判断题
  490. if (qa.reply === '') {
  491. reply = '未答'
  492. } else if (qa.reply == 0) {
  493. reply = '错误'
  494. } else if (qa.reply == 1) {
  495. reply = '正确'
  496. }
  497. if (qa.result == 0) {
  498. result = '错误'
  499. } else if (qa.result == 1) {
  500. result = '正确'
  501. }
  502. scoreAnswerRef.value.showPopup({
  503. score,
  504. reply,
  505. result,
  506. answer
  507. })
  508. }
  509. if (qa.stTypeId == 4) {
  510. let reply = qa.reply || [];
  511. let result = qa.result || [];
  512. // 填空题
  513. scoreAnswerTkRef.value.showPopup({
  514. score,
  515. reply,
  516. result,
  517. answer
  518. })
  519. }
  520. if (qa.stTypeId == 5) {
  521. // 简单题
  522. let reply = qa.reply;
  523. let result = qa.result;
  524. scoreAnswerJdRef.value.showPopup({
  525. score,
  526. reply,
  527. result,
  528. answer
  529. })
  530. }
  531. if (qa.stTypeId == 6) {
  532. // 简单题
  533. checkYueduJiexi()
  534. }
  535. }
  536. function handleBack() {
  537. // uni.redirectTo({
  538. // url: "/pages/score/index"
  539. // })
  540. uni.navigateBack()
  541. }
  542. function initKaoshi() {
  543. cjApi.lookChengjiView({
  544. hisId: data.hisId
  545. }).then(res => {
  546. const {
  547. hisId,
  548. duanluoList
  549. } = res.data;
  550. data.hisId = hisId;
  551. data.duanluo = duanluoList;
  552. formatDuanluoList(data.duanluo);
  553. uni.setNavigationBarTitle({
  554. title: data.name
  555. });
  556. })
  557. }
  558. </script>