kaoshiChengjiInfo.vue 16 KB

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