kaoshiChengjiInfo.vue 16 KB

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