exam.vue 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067
  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. <!-- 第一行 -->
  8. <view class="kaoshi-page-title">
  9. <view v-if="activeSt" class="title-types">{{dlName}}</view>
  10. <!-- 倒计时 -->
  11. <view v-if="!!data.endSecond">
  12. <uni-countdown :show-day="false" :showHour="true" :showMinute="true" :second="data.endSecond"
  13. @timeup="onTimeUp" :start="startCountDown"></uni-countdown>
  14. </view>
  15. </view>
  16. <view class="kaoshi-shiti-content">
  17. <!-- 内容区域 -->
  18. <!-- 试题区域 -->
  19. <view v-if="activeSt">
  20. <template v-if="activeSt.stTypeId == 1">
  21. <!-- 单选 -->
  22. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  23. </template>
  24. <template v-if="activeSt.stTypeId == 2">
  25. <!-- 多选 -->
  26. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  27. </template>
  28. <template v-if="activeSt.stTypeId == 3">
  29. <!-- 判断 -->
  30. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  31. </template>
  32. <template v-if="activeSt.stTypeId == 4">
  33. <!-- 填空 -->
  34. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  35. </template>
  36. <template v-if="activeSt.stTypeId == 5">
  37. <!-- 简答 -->
  38. <jianda :question="activeSt" :key="activeSt.stId"></jianda>
  39. </template>
  40. <template v-if="activeSt.stTypeId == 6">
  41. <!-- 阅读 -->
  42. <yuedu :question="activeSt" :key="activeSt.stId"></yuedu>
  43. </template>
  44. </view>
  45. </view>
  46. <view class="kaoshi-bottom-box">
  47. <button class="phone-green-btn bj-btn" hover-class="none" type="default" size="mini"
  48. @click="handleBiaoji">{{activeSt && activeSt.marked ? '取标':'标记'}}</button>
  49. <view @click="showAnswerCard" class="shiti-num-box">
  50. <icon class="shiti-num-icon"></icon>
  51. <text class="active-num">{{answercartsCount}}</text>/<text>{{data.StListForSearch.length}}</text>
  52. </view>
  53. <button class="phone-green-btn save-btn" hover-class="none" type="default" size="mini"
  54. @click="handleSave(true)">保存</button>
  55. </view>
  56. <template v-if="activeSt">
  57. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev"
  58. @click="handlePrev" v-if="!isFistStId">上一题</button>
  59. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  60. @click="handleNext" v-if="!isLastStId">下一题</button>
  61. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-next"
  62. @click="handleJiaojuan" v-if="isLastStId">交卷</button>
  63. </template>
  64. <!-- 答题卡 -->
  65. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  66. <view class="answer-card-popup">
  67. <view class="icon-title-bjcolor-navBar-box">
  68. <view @click="handlePopupBack" class="nav-bar-icon"> </view>
  69. <text class="nav-bar-title">答题卡</text>
  70. </view>
  71. <view class="card-content-box">
  72. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  73. :key="paragraphIndex">
  74. <view class="paragraph-title">
  75. {{paragraph.name}}
  76. </view>
  77. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  78. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </uni-popup>
  84. <!-- 摄像头确认 -->
  85. <!-- <zhuapaiConfirm ref="zhuapaiConfirmRef" @success="zpConfirmSuccess" @error="zpConfirmError"
  86. @cancel="zpConfirmCancel" key="1"></zhuapaiConfirm> -->
  87. <template v-if="data.zhuapai && data.zhuapai > 0">
  88. <!-- 抓拍 -->
  89. <!-- <zhuapaiVue ref="zhuapaiRef" @error="zpError" @success="zpSuccess" key="2" @progress="onProgress"></zhuapaiVue> -->
  90. </template>
  91. <!-- 切屏 -->
  92. <qiepingVue ref="qiepingRef" @zhuapai="qpZhuapai" @forceSubmit="forceSubmit" @qiepingToast="qiepingToast"
  93. key="3"></qiepingVue>
  94. <!-- 交卷确认 -->
  95. <answerQueren ref="answerQrRef" @confirm="handleQuerenConfirm"></answerQueren>
  96. <!-- 考试得分 -->
  97. <submitScoreVue ref="subScoreRef" @confirm="handleScoreConfirm" @close="handleScoreClose"></submitScoreVue>
  98. <!-- 切屏确认弹窗 -->
  99. <qiepingDlVue ref="qiepingDlRef" :content="messageContent" title="注意" okBtn="知道了"></qiepingDlVue>
  100. </view>
  101. </template>
  102. <script setup>
  103. import {
  104. ref,
  105. reactive,
  106. computed,
  107. watch,
  108. nextTick
  109. } from "vue";
  110. import zhuapaiVue from "@/components/zhuapaiConfirm/zhuapai.vue";
  111. import qiepingVue from "@/components/zhuapaiConfirm/qieping.vue";
  112. import zhuapaiConfirm from "@/components/zhuapaiConfirm/index.vue";
  113. import answerQueren from "@/components/zhuapaiConfirm/answerQueren.vue";
  114. import submitScoreVue from "@/components/zhuapaiConfirm/submitScore.vue";
  115. import {
  116. onLoad
  117. } from "@dcloudio/uni-app";
  118. import * as ksApi from "@/api/exam.js"
  119. import danxuan from "@/components/questions/danxuan.vue";
  120. import duoxuan from "@/components/questions/duoxuan.vue";
  121. import tiankong from "@/components/questions/tiankong.vue";
  122. import panduan from "@/components/questions/panduan.vue";
  123. import jianda from "@/components/questions/jianda.vue";
  124. import yuedu from "@/components/questions/yuedu.vue";
  125. import {
  126. useQuestionTools
  127. } from "@/components/questions/useQuestionTools.js";
  128. import {
  129. useKaoShiCache
  130. } from "./examTools"
  131. import qiepingDlVue from "@/components/dialog/qiepingDl.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. }
  603. function showAnswerCard() {
  604. popupRef.value.open('top')
  605. }
  606. function handlePopupBack() {
  607. popupRef.value.close()
  608. }
  609. function handlePrev() {
  610. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  611. const index = qa.onlyNum - 1;
  612. if (index > 0) {
  613. const result = data.StListForSearch[index - 1];
  614. progress.dlIndex = result.dlIndex;
  615. progress.dtIndex = result.dtIndex
  616. }
  617. }
  618. function handleNext() {
  619. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  620. const index = qa.onlyNum - 1;
  621. if (index < data.StListForSearch.length) {
  622. const result = data.StListForSearch[index + 1];
  623. progress.dlIndex = result.dlIndex;
  624. progress.dtIndex = result.dtIndex
  625. }
  626. }
  627. function formatDuanluoList(dlData) {
  628. let uIndex = 0; // 试题onlyNum
  629. let iDuanluo = 0; // 段落onlyNum
  630. let result = [];
  631. for (const duanluo of data.duanluo) {
  632. let paragraph = {
  633. qas: [],
  634. };
  635. paragraph.name = duanluo.name;
  636. let iQa = 0; // 当前试题序号
  637. let order = 0; // 当前题型中第几题
  638. for (const iDanxuan of duanluo.danxuan) {
  639. iDanxuan.type = 'danxuan';
  640. iDanxuan.marked = data.biaoji[iDanxuan.stId] ? true : false;
  641. iDanxuan.onlyNum = uIndex + 1;
  642. iDanxuan.order = order;
  643. iDanxuan.iQa = iQa;
  644. paragraph.qas.push(iDanxuan);
  645. uIndex++;
  646. order++;
  647. iQa++;
  648. data.StListForSearch.push({
  649. stId: iDanxuan.stId,
  650. paragraphName: paragraph.name,
  651. dlIndex: iDuanluo,
  652. dtIndex: iDanxuan.iQa,
  653. onlyNum: iDanxuan.onlyNum
  654. })
  655. }
  656. order = 0;
  657. for (const iDuoxuan of duanluo.duoxuan) {
  658. iDuoxuan.type = 'duoxuan';
  659. iDuoxuan.marked = data.biaoji[iDuoxuan.stId] ? true : false;
  660. iDuoxuan.onlyNum = uIndex + 1;
  661. iDuoxuan.order = order;
  662. paragraph.qas.push(iDuoxuan);
  663. iDuoxuan.iQa = iQa;
  664. iDuoxuan.reply = [];
  665. uIndex++;
  666. order++;
  667. iQa++;
  668. data.StListForSearch.push({
  669. stId: iDuoxuan.stId,
  670. paragraphName: paragraph.name,
  671. dlIndex: iDuanluo,
  672. dtIndex: iDuoxuan.iQa,
  673. onlyNum: iDuoxuan.onlyNum
  674. })
  675. }
  676. order = 0;
  677. for (const iPanduan of duanluo.panduan) {
  678. iPanduan.type = 'panduan';
  679. iPanduan.marked = data.biaoji[iPanduan.stId] ? true : false;
  680. iPanduan.onlyNum = uIndex + 1;
  681. iPanduan.order = order;
  682. paragraph.qas.push(iPanduan);
  683. iPanduan.iQa = iQa;
  684. uIndex++;
  685. order++;
  686. iQa++;
  687. data.StListForSearch.push({
  688. stId: iPanduan.stId,
  689. paragraphName: paragraph.name,
  690. dlIndex: iDuanluo,
  691. dtIndex: iPanduan.iQa,
  692. onlyNum: iPanduan.onlyNum
  693. })
  694. }
  695. order = 0;
  696. for (const iTiankong of duanluo.tiankong) {
  697. iTiankong.type = 'tiankong';
  698. iTiankong.marked = data.biaoji[iTiankong.stId] ? true : false;
  699. iTiankong.onlyNum = uIndex + 1;
  700. iTiankong.order = order;
  701. paragraph.qas.push(iTiankong);
  702. iTiankong.iQa = iQa;
  703. iTiankong.reply = new Array(iTiankong.count).fill('');
  704. uIndex++;
  705. order++;
  706. iQa++;
  707. data.StListForSearch.push({
  708. stId: iTiankong.stId,
  709. paragraphName: paragraph.name,
  710. dlIndex: iDuanluo,
  711. dtIndex: iTiankong.iQa,
  712. onlyNum: iTiankong.onlyNum
  713. })
  714. }
  715. order = 0;
  716. for (const iJianda of duanluo.jianda) {
  717. iJianda.marked = data.biaoji[iJianda.stId] ? true : false;
  718. iJianda.type = 'jianda';
  719. iJianda.onlyNum = uIndex + 1;
  720. iJianda.order = order;
  721. iJianda.iQa = iQa;
  722. paragraph.qas.push(iJianda);
  723. iJianda.reply = '';
  724. uIndex++;
  725. order++;
  726. iQa++;
  727. data.StListForSearch.push({
  728. stId: iJianda.stId,
  729. paragraphName: paragraph.name,
  730. dlIndex: iDuanluo,
  731. dtIndex: iJianda.iQa,
  732. onlyNum: iJianda.onlyNum
  733. })
  734. }
  735. order = 0;
  736. for (const iYuedu of duanluo.yuedu) {
  737. iYuedu.marked = data.biaoji[iYuedu.stId] ? true : false;
  738. iYuedu.type = 'yuedu';
  739. iYuedu.onlyNum = uIndex + 1;
  740. iYuedu.order = order;
  741. iYuedu.iQa = iQa;
  742. if (iYuedu.duoxuan && iYuedu.duoxuan.length) {
  743. iYuedu.duoxuan.map((qIt) => {
  744. qIt.reply = qIt.reply || [];
  745. return qIt
  746. })
  747. }
  748. if (iYuedu.tiankong && iYuedu.tiankong.length) {
  749. iYuedu.tiankong.map((qIt) => {
  750. qIt.reply = new Array(qIt.count).fill('');
  751. return qIt;
  752. });
  753. }
  754. paragraph.qas.push(iYuedu);
  755. iYuedu.reply = [];
  756. uIndex++;
  757. order++;
  758. iQa++;
  759. data.StListForSearch.push({
  760. stId: iYuedu.stId,
  761. paragraphName: paragraph.name,
  762. dlIndex: iDuanluo,
  763. dtIndex: iYuedu.iQa,
  764. onlyNum: iYuedu.onlyNum
  765. })
  766. }
  767. iDuanluo++;
  768. questionData.value.push(paragraph)
  769. }
  770. }
  771. function handleBiaoji() {
  772. activeSt.value.marked = !activeSt.value.marked;
  773. data.biaoji[activeSt.value.stId] = activeSt.value.marked
  774. ksApi.getClientKaoshiBiaoji({
  775. operId: data.operId,
  776. biaoji: JSON.stringify(data.biaoji)
  777. }).catch(err => {
  778. /* uni.redirectTo({
  779. url: '/pages/client/Kaoshi/list'
  780. }) */
  781. handleBack()
  782. })
  783. }
  784. function formatKaoshiData() {
  785. const historyData = getCacheKs(data.operId);
  786. if (historyData) {
  787. const {
  788. replyList,
  789. position
  790. } = historyData;
  791. if (replyList) {
  792. questionData.value.forEach(dl => {
  793. dl.qas.forEach(st => {
  794. if (st.stTypeId == 5) {
  795. // 简答题
  796. st.reply = replyList.find(item => item.stId == st.stId).reply;
  797. st.files = replyList.find(item => item.stId == st.stId).files;
  798. } else if (st.stTypeId != 6) {
  799. st.reply = replyList.find(item => item.stId == st.stId).reply
  800. } else {
  801. // 阅读题
  802. const hisSt = replyList.find(item => item.stId == st.stId);
  803. if (hisSt) {
  804. st.danxuan.forEach((itm, index) => {
  805. itm.reply = hisSt.reply['danxuan'][index];
  806. })
  807. st.duoxuan.forEach((itm, index) => {
  808. itm.reply = hisSt.reply['duoxuan'][index];
  809. })
  810. st.panduan.forEach((itm, index) => {
  811. itm.reply = hisSt.reply['panduan'][index];
  812. })
  813. st.tiankong.forEach((itm, index) => {
  814. itm.reply = hisSt.reply['tiankong'][index];
  815. })
  816. st.jianda.forEach((itm, index) => {
  817. itm.reply = hisSt.reply['jianda'][index].reply;
  818. itm.files = hisSt.reply['jianda'][index].files;
  819. })
  820. }
  821. }
  822. })
  823. })
  824. }
  825. if (position) {
  826. progress.dlIndex = position.dlIndex;
  827. progress.dtIndex = position.dtIndex;
  828. }
  829. }
  830. }
  831. // 摄像头确认初始化
  832. function initBeforKaoshi() {
  833. console.log(zhuapaiConfirmRef.value)
  834. zhuapaiConfirmRef.value.showDialog()
  835. }
  836. function initKaoshi() {
  837. ksApi.getClientKsStart({
  838. ksId: data.ksId,
  839. }).then(res => {
  840. const {
  841. ksId,
  842. operId,
  843. ksName,
  844. stTotal,
  845. stScore,
  846. biaoji,
  847. endSecond,
  848. pageSize,
  849. toggleScreenFlag,
  850. toggleScreenSecond,
  851. zhuapai,
  852. duanluoList
  853. } = res.data;
  854. data.ksId = ksId;
  855. data.operId = operId;
  856. data.ksName = ksName;
  857. data.stTotal = stTotal;
  858. data.stScore = stScore;
  859. data.biaoji = biaoji ? JSON.parse(biaoji) : {};
  860. data.endSecond = endSecond;
  861. data.pageSize = pageSize;
  862. data.toggleScreenFlag = toggleScreenFlag;
  863. data.toggleScreenSecond = toggleScreenSecond;
  864. data.zhuapai = zhuapai;
  865. data.duanluo = duanluoList;
  866. formatDuanluoList(data.duanluo);
  867. // 设置缓存
  868. formatKaoshiData();
  869. // 设置抓拍监听
  870. if (data.zhuapai && data.zhuapai > 0) {
  871. zhuapaiRef.value.init({
  872. zhuapai: zhuapai,
  873. operId: operId
  874. });
  875. }
  876. // 设置切屏监听
  877. qiepingRef.value.init({
  878. zhuapaiFlag: !!zhuapai,
  879. toggleScreenFlag: toggleScreenFlag,
  880. toggleScreenSecond: toggleScreenSecond,
  881. ksId: data.ksId
  882. })
  883. startCountDown.value = true;
  884. uni.setNavigationBarTitle({
  885. title: data.ksName
  886. });
  887. }).catch(err => {
  888. console.log('asdasd', err)
  889. // handleBack()
  890. })
  891. }
  892. </script>
  893. <style lang="scss">
  894. .phone-kaoshi-page {
  895. display: flex;
  896. flex-direction: column;
  897. background-color: #f4f6fa;
  898. position: relative;
  899. .kaoshi-page-title {
  900. height: 80rpx;
  901. line-height: 80rpx;
  902. background-color: #fff;
  903. margin-top: 20rpx;
  904. font-size: 26rpx;
  905. color: #333;
  906. display: flex;
  907. justify-content: space-between;
  908. padding: 0 24rpx;
  909. border-bottom: 1rpx solid #ebebeb;
  910. .title-types {
  911. font-size: 32rpx;
  912. color: #000;
  913. }
  914. }
  915. .kaoshi-shiti-content {
  916. padding: 24rpx 24rpx 0 24rpx;
  917. background-color: #fff;
  918. flex: 1;
  919. }
  920. .kaoshi-bottom-box {
  921. width: 100%;
  922. height: 100rpx;
  923. background-color: #f0f0f0;
  924. display: flex;
  925. align-items: center;
  926. justify-content: space-between;
  927. padding: 0 24rpx;
  928. box-sizing: border-box;
  929. position: fixed;
  930. bottom: var(--window-bottom);
  931. .bj-btn,
  932. .jx-btn,
  933. .save-btn {
  934. height: 60rpx;
  935. line-height: 58rpx;
  936. box-sizing: border-box;
  937. }
  938. .bj-btn {
  939. margin-left: unset;
  940. }
  941. .jx-btn,
  942. .save-btn {
  943. margin-right: unset;
  944. }
  945. .shiti-num-icon {
  946. width: 27px;
  947. height: 24px;
  948. vertical-align: middle;
  949. // background-image: url("@/static/images/exam/shiti-num-icon.png");
  950. @include ezy-no-repeat-cover();
  951. }
  952. .active-num {
  953. color: #30c190;
  954. }
  955. }
  956. .ks-btn-prev {
  957. position: fixed;
  958. bottom: 130rpx;
  959. left: 24rpx;
  960. }
  961. .ks-btn-next {
  962. position: fixed;
  963. bottom: 130rpx;
  964. right: 24rpx;
  965. }
  966. }
  967. </style>