kaoshiChengjiInfo.vue 16 KB

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