exam.vue 24 KB

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