exam.vue 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073
  1. <template>
  2. <view class="phone-kaoshi-page">
  3. <!-- 导航区域 -->
  4. <!-- <view class="icon-title-bjcolor-navBar-box">
  5. <text class="nav-bar-title">{{data.ksName}}</text>
  6. </view> -->
  7. <customNavbarVue :show-back-btn="true" @back="handleBack"></customNavbarVue>
  8. <!-- 第一行 -->
  9. <view class="kaoshi-page-title">
  10. <view v-if="activeSt" class="title-types">{{dlName}}</view>
  11. <!-- 倒计时 -->
  12. <view v-if="!!data.endSecond">
  13. <uni-countdown :show-day="false" :showHour="true" :showMinute="true" :second="data.endSecond"
  14. @timeup="onTimeUp" :start="startCountDown"></uni-countdown>
  15. </view>
  16. </view>
  17. <view class="kaoshi-shiti-content">
  18. <!-- 内容区域 -->
  19. <!-- 试题区域 -->
  20. <view v-if="activeSt">
  21. <template v-if="activeSt.stTypeId == 1">
  22. <!-- 单选 -->
  23. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  24. </template>
  25. <template v-if="activeSt.stTypeId == 2">
  26. <!-- 多选 -->
  27. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  28. </template>
  29. <template v-if="activeSt.stTypeId == 3">
  30. <!-- 判断 -->
  31. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  32. </template>
  33. <template v-if="activeSt.stTypeId == 4">
  34. <!-- 填空 -->
  35. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  36. </template>
  37. <template v-if="activeSt.stTypeId == 5">
  38. <!-- 简答 -->
  39. <jianda :question="activeSt" :key="activeSt.stId"></jianda>
  40. </template>
  41. <template v-if="activeSt.stTypeId == 6">
  42. <!-- 阅读 -->
  43. <yuedu :question="activeSt" :key="activeSt.stId"></yuedu>
  44. </template>
  45. </view>
  46. </view>
  47. <view class="kaoshi-bottom-box">
  48. <button class="phone-green-btn bj-btn" hover-class="none" type="default" size="mini"
  49. @click="handleBiaoji">{{activeSt && activeSt.marked ? '取标':'标记'}}</button>
  50. <view @click="showAnswerCard" class="shiti-num-box">
  51. <icon class="shiti-num-icon"></icon>
  52. <text class="active-num">{{answercartsCount}}</text>/<text>{{data.StListForSearch.length}}</text>
  53. </view>
  54. <button class="phone-green-btn save-btn" hover-class="none" type="default" size="mini"
  55. @click="handleSave(true)">保存</button>
  56. </view>
  57. <template v-if="activeSt">
  58. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev"
  59. @click="handlePrev" v-if="!isFistStId">上一题</button>
  60. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  61. @click="handleNext" v-if="!isLastStId">下一题</button>
  62. </template>
  63. <!-- 答题卡 -->
  64. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  65. <view class="answer-card-popup">
  66. <view class="icon-title-bjcolor-navBar-box">
  67. <view @click="handlePopupBack" class="nav-bar-icon"> </view>
  68. <text class="nav-bar-title">答题卡</text>
  69. </view>
  70. <view class="card-content-box">
  71. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  72. :key="paragraphIndex">
  73. <view class="paragraph-title">
  74. {{paragraph.name}}
  75. </view>
  76. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  77. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </uni-popup>
  83. <!-- 摄像头确认 -->
  84. <!-- <zhuapaiConfirm ref="zhuapaiConfirmRef" @success="zpConfirmSuccess" @error="zpConfirmError"
  85. @cancel="zpConfirmCancel" key="1"></zhuapaiConfirm> -->
  86. <!-- <template v-if="data.zhuapai && data.zhuapai > 0"> -->
  87. <!-- 抓拍 -->
  88. <!-- <zhuapaiVue ref="zhuapaiRef" @error="zpError" @success="zpSuccess" key="2" @progress="onProgress"></zhuapaiVue> -->
  89. <!-- </template> -->
  90. <!-- 切屏 -->
  91. <!-- <qiepingVue ref="qiepingRef" @zhuapai="qpZhuapai" @forceSubmit="forceSubmit" @qiepingToast="qiepingToast"
  92. key="3"></qiepingVue> -->
  93. <!-- 交卷确认 -->
  94. <answerQueren ref="answerQrRef" @confirm="handleQuerenConfirm"></answerQueren>
  95. <!-- 考试得分 -->
  96. <submitScoreVue ref="subScoreRef" @confirm="handleScoreConfirm" @close="handleScoreClose"></submitScoreVue>
  97. <!-- 切屏确认弹窗 -->
  98. <!-- <qiepingDlVue ref="qiepingDlRef" :content="messageContent" title="注意" okBtn="知道了"></qiepingDlVue> -->
  99. </view>
  100. </template>
  101. <script setup>
  102. import {
  103. ref,
  104. reactive,
  105. computed,
  106. watch,
  107. nextTick
  108. } from "vue";
  109. import zhuapaiVue from "@/components/zhuapaiConfirm/zhuapai.vue";
  110. import qiepingVue from "@/components/zhuapaiConfirm/qieping.vue";
  111. import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";
  112. import answerQueren from "@/components/zhuapaiConfirm/answerQueren.vue";
  113. import submitScoreVue from "@/components/zhuapaiConfirm/submitScore.vue";
  114. import {
  115. onLoad
  116. } from "@dcloudio/uni-app";
  117. import * as ksApi from "@/api/exam.js"
  118. import danxuan from "@/components/questions/danxuan.vue";
  119. import duoxuan from "@/components/questions/duoxuan.vue";
  120. import tiankong from "@/components/questions/tiankong.vue";
  121. import panduan from "@/components/questions/panduan.vue";
  122. import jianda from "@/components/questions/jianda.vue";
  123. import yuedu from "@/components/questions/yuedu.vue";
  124. import {
  125. useQuestionTools
  126. } from "@/components/questions/useQuestionTools.js";
  127. import {
  128. useKaoShiCache
  129. } from "./examTools"
  130. import qiepingDlVue from "@/components/dialog/qiepingDl.vue";
  131. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  132. const {
  133. checkDanxuanReply,
  134. checkDuoxuanReply,
  135. checkPanduanReply,
  136. checkTiankongReply,
  137. getLetterByIndex,
  138. checkJiandaReply,
  139. checkYueduReply
  140. } = useQuestionTools();
  141. const {
  142. saveCacheKs,
  143. getCacheKs,
  144. removeCacheKs
  145. } = useKaoShiCache();
  146. onLoad((option) => {
  147. data.ksId = option.ksId;
  148. data.zhuapai = option.zhuapai;
  149. if (data.zhuapai && data.zhuapai != 0) {
  150. // 考试前确认摄像头
  151. nextTick(() => {
  152. // initBeforKaoshi();
  153. })
  154. } else {
  155. console.log('初始化')
  156. initKaoshi();
  157. }
  158. })
  159. const popupRef = ref(null)
  160. const zhuapaiRef = ref(null)
  161. const qiepingRef = ref(null)
  162. const zhuapaiConfirmRef = ref(null)
  163. const answerQrRef = ref(null);
  164. const startCountDown = ref(false);
  165. const subScoreRef = ref(null);
  166. const messageContent = ref('');
  167. const qiepingDlRef = ref(null);
  168. const timer1 = ref(null);
  169. const answercartsCount = ref(0); // 已答题数
  170. const data = reactive({
  171. ksId: null,
  172. operId: null,
  173. ksName: '',
  174. stTotal: 0,
  175. stScore: 0,
  176. biaoji: {},
  177. endSecond: 0,
  178. pageSize: 0,
  179. toggleScreenFlag: 0,
  180. toggleScreenSecond: 0,
  181. zhuapai: 0,
  182. duanluo: [],
  183. StListForSearch: [],
  184. from: '',
  185. hisId: '',
  186. })
  187. const markDB = ref([]);
  188. const questionData = ref([]);
  189. const progress = reactive({
  190. dlIndex: 0,
  191. dtIndex: 0
  192. })
  193. const dlName = computed(() => {
  194. if (data.StListForSearch && activeSt.value) {
  195. return data.StListForSearch[activeSt.value.onlyNum - 1].paragraphName
  196. } else {
  197. return ''
  198. }
  199. })
  200. watch(() => questionData, (newVal) => {
  201. // 计算已答试题数量
  202. renderPage(newVal);
  203. }, {
  204. deep: true
  205. })
  206. function renderPage(data) {
  207. let count = 0;
  208. for (const paragraph of data.value) {
  209. for (const qa of paragraph.qas) {
  210. if (qa.stTypeId == 1) {
  211. if (checkDanxuanReply(qa)) {
  212. count++;
  213. }
  214. } else if (qa.stTypeId == 2) {
  215. if (checkDuoxuanReply(qa)) {
  216. count++;
  217. }
  218. } else if (qa.stTypeId == 3) {
  219. if (checkPanduanReply(qa)) {
  220. count++;
  221. }
  222. } else if (qa.stTypeId == 4) {
  223. if (checkTiankongReply(qa)) {
  224. count++;
  225. }
  226. } else if (qa.stTypeId == 5) {
  227. if (checkJiandaReply(qa)) {
  228. count++;
  229. }
  230. } else if (qa.stTypeId == 4) {
  231. if (checkYueduReply(qa)) {
  232. count++;
  233. }
  234. }
  235. }
  236. }
  237. answercartsCount.value = count;
  238. }
  239. const activeSt = computed(() => {
  240. if (questionData.value.length) {
  241. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  242. } else {
  243. return null
  244. }
  245. })
  246. const isFistStId = computed(() => {
  247. if (data.StListForSearch.length) {
  248. return data.StListForSearch[0].stId == activeSt.value.stId
  249. } else {
  250. return false
  251. }
  252. });
  253. const isLastStId = computed(() => {
  254. if (data.StListForSearch.length) {
  255. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  256. } else {
  257. return false
  258. }
  259. });
  260. function handleScoreClose() {
  261. handleBack()
  262. }
  263. // 考试得分相关 start
  264. function handleScoreConfirm() {
  265. // 跳转成绩
  266. uni.redirectTo({
  267. url: `/pages/client/Chengji/ksScoreShijuan?hisId=${data.hisId}`
  268. })
  269. }
  270. // 考试得分相关 end
  271. // 保存相关
  272. function handleSave(showToast) {
  273. if (timer1.value) {
  274. uni.showToast({
  275. title: '请勿连续保存',
  276. icon: 'none'
  277. })
  278. return
  279. }
  280. timer1.value = setTimeout(() => {
  281. clearTimeout(timer1.value);
  282. }, 10 * 1000);
  283. console.log(questionData.value)
  284. const result = []
  285. const option = {
  286. operId: data.operId,
  287. replyList: []
  288. }
  289. questionData.value.forEach(dl => {
  290. dl.qas.forEach(qa => {
  291. console.log('qa:', qa)
  292. if (qa.stTypeId == 5) {
  293. const opt = {
  294. stId: qa.stId,
  295. files: qa.files,
  296. reply: qa.reply,
  297. }
  298. result.push(opt)
  299. option.replyList.push(opt)
  300. } else if (qa.stTypeId != 6) {
  301. const opt = {
  302. stId: qa.stId,
  303. reply: qa.reply,
  304. }
  305. result.push(opt)
  306. option.replyList.push(opt)
  307. } else {
  308. // 阅读题
  309. let danxuanArr = [];
  310. for (const iDanxuan of qa.danxuan) {
  311. danxuanArr.push(iDanxuan.reply);
  312. }
  313. let duoxuanArr = [];
  314. for (const iDuoxuan of qa.duoxuan) {
  315. duoxuanArr.push(iDuoxuan.reply);
  316. }
  317. let panduanArr = [];
  318. for (const iPanduan of qa.panduan) {
  319. panduanArr.push(iPanduan.reply);
  320. }
  321. let tiankongArr = [];
  322. for (const iTiankong of qa.tiankong) {
  323. tiankongArr.push(iTiankong.reply);
  324. }
  325. let jiandaArr = [];
  326. for (const iJianda of qa.jianda) {
  327. const c = {
  328. files: iJianda.files,
  329. reply: iJianda.reply,
  330. };
  331. jiandaArr.push(c);
  332. }
  333. result.push({
  334. reply: {
  335. danxuan: danxuanArr,
  336. duoxuan: duoxuanArr,
  337. panduan: panduanArr,
  338. tiankong: tiankongArr,
  339. jianda: jiandaArr,
  340. },
  341. stId: qa.stId,
  342. })
  343. option.replyList.push({
  344. reply: {
  345. danxuan: danxuanArr,
  346. duoxuan: duoxuanArr,
  347. panduan: panduanArr,
  348. tiankong: tiankongArr,
  349. jianda: jiandaArr,
  350. },
  351. stId: qa.stId,
  352. });
  353. }
  354. })
  355. })
  356. // 保存试题答案
  357. saveCacheKs(data.operId, {
  358. replyList: result,
  359. position: {
  360. dlIndex: progress.dlIndex,
  361. dtIndex: progress.dtIndex
  362. }
  363. })
  364. // 保存答题进度
  365. ksApi.getClientKsSave(option).then(res => {
  366. if (res.data && showToast) {
  367. uni.showToast({
  368. title: '保存成功',
  369. })
  370. }
  371. })
  372. }
  373. // 交卷相关功能 start
  374. function checkJiaojuan() {
  375. const result = []
  376. let count = 0;
  377. let total = 0;
  378. questionData.value.forEach(item => {
  379. item.qas.forEach(qa => {
  380. total++;
  381. if (qa.stTypeId == 1 && !checkDanxuanReply(qa)) {
  382. count++;
  383. }
  384. if (qa.stTypeId == 2 && !checkDuoxuanReply(qa)) {
  385. count++;
  386. }
  387. if (qa.stTypeId == 3 && !checkPanduanReply(qa)) {
  388. count++;
  389. }
  390. if (qa.stTypeId == 4 && !checkTiankongReply(qa)) {
  391. count++;
  392. }
  393. if (qa.stTypeId == 5 && !checkJiandaReply(qa)) {
  394. count++;
  395. }
  396. if (qa.stTypeId == 6 && !checkYueduReply(qa)) {
  397. count++;
  398. }
  399. })
  400. })
  401. return {
  402. total,
  403. count,
  404. }
  405. }
  406. function handleJiaojuan() {
  407. const result = checkJiaojuan()
  408. if (result.count) {
  409. // 提示
  410. answerQrRef.value.showDialog({
  411. answercartsCount: result.total - result.count,
  412. answercartsTotal: result.total,
  413. })
  414. } else {
  415. handleSubmit()
  416. }
  417. }
  418. function handleQuerenConfirm() {
  419. handleSubmit()
  420. }
  421. function handleSubmit(force = false) {
  422. const result = {
  423. force,
  424. operId: data.operId,
  425. replyList: []
  426. };
  427. questionData.value.forEach(dl => {
  428. dl.qas.forEach(st => {
  429. if (st.stTypeId == 5) {
  430. // 简答题
  431. const opt = {
  432. stId: st.stId,
  433. reply: st.reply,
  434. files: st.files,
  435. }
  436. result.replyList.push(opt)
  437. } else if (st.stTypeId == 6) {
  438. // 阅读题
  439. // 阅读题
  440. let danxuanArr = [];
  441. for (const iDanxuan of qa.danxuan) {
  442. danxuanArr.push(iDanxuan.reply);
  443. }
  444. let duoxuanArr = [];
  445. for (const iDuoxuan of qa.duoxuan) {
  446. duoxuanArr.push(iDuoxuan.reply);
  447. }
  448. let panduanArr = [];
  449. for (const iPanduan of qa.panduan) {
  450. panduanArr.push(iPanduan.reply);
  451. }
  452. let tiankongArr = [];
  453. for (const iTiankong of qa.tiankong) {
  454. tiankongArr.push(iTiankong.reply);
  455. }
  456. let jiandaArr = [];
  457. for (const iJianda of qa.jianda) {
  458. const c = {
  459. files: iJianda.files,
  460. reply: iJianda.reply,
  461. };
  462. jiandaArr.push(c);
  463. }
  464. result.replyList.push({
  465. reply: {
  466. danxuan: danxuanArr,
  467. duoxuan: duoxuanArr,
  468. panduan: panduanArr,
  469. tiankong: tiankongArr,
  470. jianda: jiandaArr,
  471. },
  472. stId: qa.stId,
  473. })
  474. } else {
  475. // 其他
  476. const opt = {
  477. stId: st.stId,
  478. reply: st.reply
  479. }
  480. result.replyList.push(opt)
  481. }
  482. })
  483. })
  484. ksApi.getClientKsSubmit(result).then(res => {
  485. if (res.code == 0) {
  486. subScoreRef.value.showDialog(res.data);
  487. data.hisId = res.data.hisId;
  488. // 清空缓存
  489. removeCacheKs(data.operId);
  490. }
  491. })
  492. }
  493. function onTimeUp() {
  494. handleSubmit();
  495. }
  496. // 交卷相关功能 end
  497. // 切屏功能 start
  498. function qiepingToast(count) {
  499. messageContent.value = `已离开${count}次。${data.toggleScreenFlag}次将自动交卷!`
  500. qiepingDlRef.value.handleShow()
  501. }
  502. function forceSubmit() {
  503. // 强制交卷
  504. console.log('强制交卷')
  505. handleSubmit(true)
  506. }
  507. function qpZhuapai() {
  508. // 重新开启抓拍
  509. zhuapaiRef.value && zhuapaiRef.value.showVideoBtn();
  510. }
  511. // 切屏功能 end
  512. // 摄像头抓拍相关功能 start
  513. function zpSuccess() {}
  514. function zpError() {
  515. uni.showToast({
  516. title: '抓拍图片异常',
  517. icon: 'none'
  518. })
  519. handleBack()
  520. }
  521. // 摄像头抓拍相关功能 end
  522. // 摄像头确认相关功能 start
  523. function onProgress() {
  524. uni.showToast({
  525. icon: 'none',
  526. title: '摄像头运行环境异常,请重新进入考试',
  527. duration: 8000
  528. })
  529. handleBack();
  530. }
  531. function zpConfirmSuccess() {
  532. console.log('zpConfirmSuccess')
  533. initKaoshi();
  534. }
  535. function zpConfirmError() {
  536. handleBack()
  537. }
  538. function zpConfirmCancel() {
  539. handleBack()
  540. }
  541. // 摄像头确认相关功能 end
  542. function getQaClass(qa) {
  543. if (qa.marked && qa.marked === true) {
  544. return 'paragraph-qa-block-mark';
  545. } else {
  546. if (qa.stTypeId == 1) {
  547. if (checkDanxuanReply(qa)) {
  548. return 'paragraph-qa-block-done';
  549. } else {
  550. return 'paragraph-qa-block-init';
  551. }
  552. } else if (qa.stTypeId == 2) {
  553. if (checkDuoxuanReply(qa)) {
  554. return 'paragraph-qa-block-done';
  555. } else {
  556. return 'paragraph-qa-block-init';
  557. }
  558. } else if (qa.stTypeId == 3) {
  559. if (checkPanduanReply(qa)) {
  560. return 'paragraph-qa-block-done';
  561. } else {
  562. return 'paragraph-qa-block-init';
  563. }
  564. } else if (qa.stTypeId == 4) {
  565. if (checkTiankongReply(qa)) {
  566. return 'paragraph-qa-block-done';
  567. } else {
  568. return 'paragraph-qa-block-init';
  569. }
  570. } else if (qa.stTypeId == 5) {
  571. if (checkJiandaReply(qa)) {
  572. return 'paragraph-qa-block-done';
  573. } else {
  574. return 'paragraph-qa-block-init';
  575. }
  576. } else if (qa.stTypeId == 6) {
  577. if (checkYueduReply(qa)) {
  578. return 'paragraph-qa-block-done';
  579. } else {
  580. return 'paragraph-qa-block-init';
  581. }
  582. }
  583. }
  584. }
  585. function skipQuestion(dlIndex, dtIndex) {
  586. progress.dlIndex = dlIndex;
  587. progress.dtIndex = dtIndex;
  588. handlePopupBack()
  589. }
  590. function answerCardItemClick(qa) {
  591. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  592. console.log('actQa', actQa)
  593. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  594. }
  595. function handleBack() {
  596. // const pages = getCurrentPages();
  597. // if (pages.length > 1) {
  598. // uni.navigateBack()
  599. // } else {
  600. // history.back();
  601. // }
  602. uni.navigateBack()
  603. }
  604. function showAnswerCard() {
  605. popupRef.value.open('top')
  606. }
  607. function handlePopupBack() {
  608. popupRef.value.close()
  609. }
  610. function handlePrev() {
  611. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  612. const index = qa.onlyNum - 1;
  613. if (index > 0) {
  614. const result = data.StListForSearch[index - 1];
  615. progress.dlIndex = result.dlIndex;
  616. progress.dtIndex = result.dtIndex
  617. }
  618. }
  619. function handleNext() {
  620. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  621. const index = qa.onlyNum - 1;
  622. if (index < data.StListForSearch.length) {
  623. const result = data.StListForSearch[index + 1];
  624. progress.dlIndex = result.dlIndex;
  625. progress.dtIndex = result.dtIndex
  626. }
  627. }
  628. function formatDuanluoList(dlData) {
  629. let uIndex = 0; // 试题onlyNum
  630. let iDuanluo = 0; // 段落onlyNum
  631. let result = [];
  632. for (const duanluo of data.duanluo) {
  633. let paragraph = {
  634. qas: [],
  635. };
  636. paragraph.name = duanluo.name;
  637. let iQa = 0; // 当前试题序号
  638. let order = 0; // 当前题型中第几题
  639. for (const iDanxuan of duanluo.danxuan) {
  640. iDanxuan.type = 'danxuan';
  641. iDanxuan.marked = data.biaoji[iDanxuan.stId] ? true : false;
  642. iDanxuan.onlyNum = uIndex + 1;
  643. iDanxuan.order = order;
  644. iDanxuan.iQa = iQa;
  645. paragraph.qas.push(iDanxuan);
  646. uIndex++;
  647. order++;
  648. iQa++;
  649. data.StListForSearch.push({
  650. stId: iDanxuan.stId,
  651. paragraphName: paragraph.name,
  652. dlIndex: iDuanluo,
  653. dtIndex: iDanxuan.iQa,
  654. onlyNum: iDanxuan.onlyNum
  655. })
  656. }
  657. order = 0;
  658. for (const iDuoxuan of duanluo.duoxuan) {
  659. iDuoxuan.type = 'duoxuan';
  660. iDuoxuan.marked = data.biaoji[iDuoxuan.stId] ? true : false;
  661. iDuoxuan.onlyNum = uIndex + 1;
  662. iDuoxuan.order = order;
  663. paragraph.qas.push(iDuoxuan);
  664. iDuoxuan.iQa = iQa;
  665. iDuoxuan.reply = [];
  666. uIndex++;
  667. order++;
  668. iQa++;
  669. data.StListForSearch.push({
  670. stId: iDuoxuan.stId,
  671. paragraphName: paragraph.name,
  672. dlIndex: iDuanluo,
  673. dtIndex: iDuoxuan.iQa,
  674. onlyNum: iDuoxuan.onlyNum
  675. })
  676. }
  677. order = 0;
  678. for (const iPanduan of duanluo.panduan) {
  679. iPanduan.type = 'panduan';
  680. iPanduan.marked = data.biaoji[iPanduan.stId] ? true : false;
  681. iPanduan.onlyNum = uIndex + 1;
  682. iPanduan.order = order;
  683. paragraph.qas.push(iPanduan);
  684. iPanduan.iQa = iQa;
  685. uIndex++;
  686. order++;
  687. iQa++;
  688. data.StListForSearch.push({
  689. stId: iPanduan.stId,
  690. paragraphName: paragraph.name,
  691. dlIndex: iDuanluo,
  692. dtIndex: iPanduan.iQa,
  693. onlyNum: iPanduan.onlyNum
  694. })
  695. }
  696. order = 0;
  697. for (const iTiankong of duanluo.tiankong) {
  698. iTiankong.type = 'tiankong';
  699. iTiankong.marked = data.biaoji[iTiankong.stId] ? true : false;
  700. iTiankong.onlyNum = uIndex + 1;
  701. iTiankong.order = order;
  702. paragraph.qas.push(iTiankong);
  703. iTiankong.iQa = iQa;
  704. iTiankong.reply = new Array(iTiankong.count).fill('');
  705. uIndex++;
  706. order++;
  707. iQa++;
  708. data.StListForSearch.push({
  709. stId: iTiankong.stId,
  710. paragraphName: paragraph.name,
  711. dlIndex: iDuanluo,
  712. dtIndex: iTiankong.iQa,
  713. onlyNum: iTiankong.onlyNum
  714. })
  715. }
  716. order = 0;
  717. for (const iJianda of duanluo.jianda) {
  718. iJianda.marked = data.biaoji[iJianda.stId] ? true : false;
  719. iJianda.type = 'jianda';
  720. iJianda.onlyNum = uIndex + 1;
  721. iJianda.order = order;
  722. iJianda.iQa = iQa;
  723. paragraph.qas.push(iJianda);
  724. iJianda.reply = '';
  725. uIndex++;
  726. order++;
  727. iQa++;
  728. data.StListForSearch.push({
  729. stId: iJianda.stId,
  730. paragraphName: paragraph.name,
  731. dlIndex: iDuanluo,
  732. dtIndex: iJianda.iQa,
  733. onlyNum: iJianda.onlyNum
  734. })
  735. }
  736. order = 0;
  737. for (const iYuedu of duanluo.yuedu) {
  738. iYuedu.marked = data.biaoji[iYuedu.stId] ? true : false;
  739. iYuedu.type = 'yuedu';
  740. iYuedu.onlyNum = uIndex + 1;
  741. iYuedu.order = order;
  742. iYuedu.iQa = iQa;
  743. if (iYuedu.duoxuan && iYuedu.duoxuan.length) {
  744. iYuedu.duoxuan.map((qIt) => {
  745. qIt.reply = qIt.reply || [];
  746. return qIt
  747. })
  748. }
  749. if (iYuedu.tiankong && iYuedu.tiankong.length) {
  750. iYuedu.tiankong.map((qIt) => {
  751. qIt.reply = new Array(qIt.count).fill('');
  752. return qIt;
  753. });
  754. }
  755. paragraph.qas.push(iYuedu);
  756. iYuedu.reply = [];
  757. uIndex++;
  758. order++;
  759. iQa++;
  760. data.StListForSearch.push({
  761. stId: iYuedu.stId,
  762. paragraphName: paragraph.name,
  763. dlIndex: iDuanluo,
  764. dtIndex: iYuedu.iQa,
  765. onlyNum: iYuedu.onlyNum
  766. })
  767. }
  768. iDuanluo++;
  769. questionData.value.push(paragraph)
  770. }
  771. }
  772. function handleBiaoji() {
  773. activeSt.value.marked = !activeSt.value.marked;
  774. data.biaoji[activeSt.value.stId] = activeSt.value.marked
  775. ksApi.getClientKaoshiBiaoji({
  776. operId: data.operId,
  777. biaoji: JSON.stringify(data.biaoji)
  778. }).catch(err => {
  779. /* uni.redirectTo({
  780. url: '/pages/client/Kaoshi/list'
  781. }) */
  782. setTimeout(() => {
  783. handleBack()
  784. },1000)
  785. })
  786. }
  787. function formatKaoshiData() {
  788. const historyData = getCacheKs(data.operId);
  789. if (historyData) {
  790. const {
  791. replyList,
  792. position
  793. } = historyData;
  794. if (replyList) {
  795. questionData.value.forEach(dl => {
  796. dl.qas.forEach(st => {
  797. if (st.stTypeId == 5) {
  798. // 简答题
  799. st.reply = replyList.find(item => item.stId == st.stId).reply;
  800. st.files = replyList.find(item => item.stId == st.stId).files;
  801. } else if (st.stTypeId != 6) {
  802. st.reply = replyList.find(item => item.stId == st.stId).reply
  803. } else {
  804. // 阅读题
  805. const hisSt = replyList.find(item => item.stId == st.stId);
  806. if (hisSt) {
  807. st.danxuan.forEach((itm, index) => {
  808. itm.reply = hisSt.reply['danxuan'][index];
  809. })
  810. st.duoxuan.forEach((itm, index) => {
  811. itm.reply = hisSt.reply['duoxuan'][index];
  812. })
  813. st.panduan.forEach((itm, index) => {
  814. itm.reply = hisSt.reply['panduan'][index];
  815. })
  816. st.tiankong.forEach((itm, index) => {
  817. itm.reply = hisSt.reply['tiankong'][index];
  818. })
  819. st.jianda.forEach((itm, index) => {
  820. itm.reply = hisSt.reply['jianda'][index].reply;
  821. itm.files = hisSt.reply['jianda'][index].files;
  822. })
  823. }
  824. }
  825. })
  826. })
  827. }
  828. if (position) {
  829. progress.dlIndex = position.dlIndex;
  830. progress.dtIndex = position.dtIndex;
  831. }
  832. }
  833. }
  834. // 摄像头确认初始化
  835. function initBeforKaoshi() {
  836. console.log(zhuapaiConfirmRef.value)
  837. zhuapaiConfirmRef.value.showDialog()
  838. }
  839. function initKaoshi() {
  840. ksApi.getClientKsStart({
  841. ksId: data.ksId,
  842. }).then(res => {
  843. const {
  844. ksId,
  845. operId,
  846. ksName,
  847. stTotal,
  848. stScore,
  849. biaoji,
  850. endSecond,
  851. pageSize,
  852. toggleScreenFlag,
  853. toggleScreenSecond,
  854. zhuapai,
  855. duanluoList
  856. } = res.data;
  857. data.ksId = ksId;
  858. data.operId = operId;
  859. data.ksName = ksName;
  860. data.stTotal = stTotal;
  861. data.stScore = stScore;
  862. data.biaoji = biaoji ? JSON.parse(biaoji) : {};
  863. data.endSecond = endSecond;
  864. data.pageSize = pageSize;
  865. data.toggleScreenFlag = toggleScreenFlag;
  866. data.toggleScreenSecond = toggleScreenSecond;
  867. // data.zhuapai = zhuapai;
  868. data.duanluo = duanluoList;
  869. formatDuanluoList(data.duanluo);
  870. // 设置缓存
  871. formatKaoshiData();
  872. // 设置抓拍监听
  873. // if (data.zhuapai && data.zhuapai > 0) {
  874. // zhuapaiRef.value.init({
  875. // zhuapai: zhuapai,
  876. // operId: operId
  877. // });
  878. // }
  879. // 设置切屏监听
  880. // qiepingRef.value.init({
  881. // zhuapaiFlag: !!zhuapai,
  882. // toggleScreenFlag: toggleScreenFlag,
  883. // toggleScreenSecond: toggleScreenSecond,
  884. // ksId: data.ksId
  885. // })
  886. startCountDown.value = true;
  887. uni.setNavigationBarTitle({
  888. title: data.ksName
  889. });
  890. }).catch(err => {
  891. console.log('asdasd', err)
  892. setTimeout(() => {
  893. handleBack()
  894. },1000)
  895. })
  896. }
  897. </script>
  898. <style lang="scss">
  899. .phone-kaoshi-page {
  900. display: flex;
  901. flex-direction: column;
  902. background-color: #f4f6fa;
  903. position: relative;
  904. .kaoshi-page-title {
  905. height: 80rpx;
  906. line-height: 80rpx;
  907. background-color: #fff;
  908. margin-top: 20rpx;
  909. font-size: 26rpx;
  910. color: #333;
  911. display: flex;
  912. justify-content: space-between;
  913. padding: 0 24rpx;
  914. border-bottom: 1rpx solid #ebebeb;
  915. .title-types {
  916. font-size: 32rpx;
  917. color: #000;
  918. }
  919. }
  920. .kaoshi-shiti-content {
  921. padding: 24rpx 24rpx 0 24rpx;
  922. background-color: #fff;
  923. flex: 1;
  924. }
  925. .kaoshi-bottom-box {
  926. width: 100%;
  927. height: 100rpx;
  928. background-color: #f0f0f0;
  929. display: flex;
  930. align-items: center;
  931. justify-content: space-between;
  932. padding: 0 24rpx;
  933. box-sizing: border-box;
  934. position: fixed;
  935. bottom: var(--window-bottom);
  936. .bj-btn,
  937. .jx-btn,
  938. .save-btn {
  939. height: 60rpx;
  940. line-height: 58rpx;
  941. box-sizing: border-box;
  942. }
  943. .bj-btn {
  944. margin-left: unset;
  945. }
  946. .jx-btn,
  947. .save-btn {
  948. margin-right: unset;
  949. }
  950. .shiti-num-icon {
  951. width: 27px;
  952. height: 24px;
  953. vertical-align: middle;
  954. // background-image: url("@/static/images/exam/shiti-num-icon.png");
  955. @include ezy-no-repeat-cover();
  956. }
  957. .active-num {
  958. color: #30c190;
  959. }
  960. }
  961. .ks-btn-prev {
  962. position: fixed;
  963. bottom: 130rpx;
  964. left: 24rpx;
  965. }
  966. .ks-btn-next {
  967. position: fixed;
  968. bottom: 130rpx;
  969. right: 24rpx;
  970. }
  971. }
  972. </style>