ksScoreShijuan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view class="phone-score-page">
  3. <!-- 导航区域 -->
  4. <view class="icon-title-navBar-box">
  5. <view @click="handleBack" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">{{data.ksName}}</text>
  7. </view>
  8. <!-- 上方区域 -->
  9. <topCard v-if="data.ksName" @openCard="handleOpenCard" :name="data.ksName" :zyLevelName="data.zyLevelName"
  10. :userScore="data.userScore" :Score="data.ksScore"></topCard>
  11. <!-- 段落 -->
  12. <view class="score-shiti-content">
  13. <!-- 试题区域 -->
  14. <view v-if="activeSt">
  15. <template v-if="activeSt.stTypeId == 1">
  16. <!-- 单选 -->
  17. <danxuan :question="activeSt" :key="activeSt.stId"></danxuan>
  18. </template>
  19. <template v-if="activeSt.stTypeId == 2">
  20. <!-- 多选 -->
  21. <duoxuan :question="activeSt" :key="activeSt.stId"></duoxuan>
  22. </template>
  23. <template v-if="activeSt.stTypeId == 3">
  24. <!-- 判断 -->
  25. <panduan :question="activeSt" :key="activeSt.stId"></panduan>
  26. </template>
  27. <template v-if="activeSt.stTypeId == 4">
  28. <!-- 填空 -->
  29. <tiankong :question="activeSt" :key="activeSt.stId"></tiankong>
  30. </template>
  31. </view>
  32. <!-- 解析 -->
  33. <view v-if="activeSt" class="score-answer-box">
  34. <view class="phone-question-answer-box" v-if="activeSt.stTypeId != 4">
  35. <view class="phone-line-title">答案解析</view>
  36. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  37. <view class="zqda-row">正确答案:<text>{{answerRes.result}}</text></view>
  38. <view class="ndda-row">您的答案:<text>{{answerRes.reply}}</text></view>
  39. <view class="dajx-row">答案解析:
  40. <rich-text :nodes="answerRes.answer"></rich-text>
  41. </view>
  42. </view>
  43. <view class="phone-question-answer-box" v-else>
  44. <view class="phone-line-title">答案解析</view>
  45. <view class="btdf-row">本题得分:<text>{{answerRes.score}}</text>分</view>
  46. <view class="zqda-row">正确答案:
  47. <view v-for="(item,index) in answerRes.result">{{`填空${index+1}`}} : {{item}}</view>
  48. </view>
  49. <view class="ndda-row">您的答案:
  50. <view v-for="(item,index) in answerRes.reply"> {{`填空${index+1}`}}: {{item}}</view>
  51. </view>
  52. <view class="dajx-row">答案解析:
  53. <rich-text :nodes="answerRes.answer"></rich-text>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. <!-- 上下按钮 -->
  59. <view v-if="activeSt" class="score-bottom-box">
  60. <view @click="handleOpenCard" class="score-num-box">
  61. <icon class="score-num-icon"></icon>
  62. <text
  63. class="active-num">{{activeSt && activeSt.onlyNum||0}}</text>/<text>{{data.StListForSearch.length}}</text>
  64. </view>
  65. <view>
  66. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  67. @click="handlePrev" v-if="!isFistStId">上一题</button>
  68. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  69. @click="handleNext" v-if="!isLastStId">下一题</button>
  70. <button type="default" size="mini" hover-class="none" class="phone-green-btn score-answer-btn"
  71. @click="handleBack" v-if="isLastStId">完成</button>
  72. </view>
  73. </view>
  74. <!-- 答题卡 -->
  75. <uni-popup ref="popupRef" background-color="#fff" :animation="false" :is-mask-click="false" :mask-click="false">
  76. <view class="answer-card-popup">
  77. <view class="icon-title-navBar-box">
  78. <view @click="handlePopupBack" class="nav-bar-icon"> </view>
  79. <text class="nav-bar-title">答题卡</text>
  80. </view>
  81. <view class="card-content-box">
  82. <view class="answer-card-content" v-for="(paragraph,paragraphIndex) in questionData"
  83. :key="paragraphIndex">
  84. <view class="paragraph-title">
  85. {{paragraph.name}}
  86. </view>
  87. <view class="paragraph-qa" v-for="(qa,qaIndex) in paragraph.qas" :key="qaIndex"
  88. :class="getQaClass(qa)" @click="answerCardItemClick(qa)">{{qa.onlyNum}}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </uni-popup>
  94. </view>
  95. </template>
  96. <script setup>
  97. import topCard from "@/components/score/topCard.vue"
  98. import danxuan from "@/components/questions/danxuan.vue";
  99. import duoxuan from "@/components/questions/duoxuan.vue";
  100. import tiankong from "@/components/questions/tiankong.vue";
  101. import panduan from "@/components/questions/panduan.vue";
  102. import {
  103. useQuestionTools
  104. } from "@/components/questions/useQuestionTools.js";
  105. import {
  106. onLoad
  107. } from "@dcloudio/uni-app";
  108. import {
  109. ref,
  110. reactive,
  111. computed
  112. } from "vue"
  113. import * as ksApi from "@/api/kaoshi.js"
  114. const {
  115. checkDanxuanReply,
  116. checkDuoxuanReply,
  117. checkPanduanReply,
  118. checkTiankongReply,
  119. getLetterByIndex
  120. } = useQuestionTools();
  121. const hisId = ref(null)
  122. const popupRef = ref(null)
  123. const data = reactive({
  124. ksId: null,
  125. ksName: '',
  126. stTotal: 0,
  127. zyLevelName: '',
  128. userScore: '',
  129. ksScore: 0,
  130. StListForSearch: [],
  131. duanluo: []
  132. })
  133. const questionData = ref([]);
  134. const progress = reactive({
  135. dlIndex: 0,
  136. dtIndex: 0
  137. })
  138. const dlName = computed(() => {
  139. if (data.StListForSearch && activeSt.value) {
  140. return data.StListForSearch[activeSt.value.onlyNum].paragraphName
  141. } else {
  142. return ''
  143. }
  144. })
  145. const activeSt = computed(() => {
  146. if (questionData.value.length) {
  147. return questionData.value.length && questionData.value[progress.dlIndex].qas[progress.dtIndex];
  148. } else {
  149. return null
  150. }
  151. })
  152. const answerRes = computed(() => {
  153. const qa = activeSt.value;
  154. let score = qa.score;
  155. let reply = '';
  156. let result = '';
  157. let answer = qa.answer;
  158. if (qa.stTypeId == 1) {
  159. // 单选题
  160. if (qa.reply && qa.reply.trim() !== '') {
  161. reply = getLetterByIndex(qa.reply)
  162. } else {
  163. reply = '未答'
  164. }
  165. if (qa.result) {
  166. result = getLetterByIndex(qa.result)
  167. } else {
  168. result = '无答案'
  169. }
  170. }
  171. if (qa.stTypeId == 2) {
  172. // 多选题
  173. if (qa.reply && qa.reply.length) {
  174. reply = qa.reply.map(item => {
  175. if (item.trim()) {
  176. return getLetterByIndex(item.trim())
  177. }
  178. }).join(',')
  179. } else {
  180. reply = '未答'
  181. }
  182. if (qa.result) {
  183. result = qa.result.map(item => {
  184. if (item.trim()) {
  185. return getLetterByIndex(item.trim())
  186. }
  187. }).join(',')
  188. } else {
  189. result = '无答案'
  190. }
  191. }
  192. if (qa.stTypeId == 3) {
  193. // 判断题
  194. if (qa.reply === '') {
  195. reply = '未答'
  196. } else if (qa.reply == 0) {
  197. reply = '错误'
  198. } else if (qa.reply == 1) {
  199. reply = '正确'
  200. }
  201. if (qa.result == 0) {
  202. result = '错误'
  203. } else if (qa.result == 1) {
  204. result = '正确'
  205. }
  206. }
  207. if (qa.stTypeId == 4) {
  208. let reply = qa.reply || [];
  209. let result = qa.result || [];
  210. // 填空题
  211. return {
  212. score,
  213. reply,
  214. result,
  215. answer
  216. }
  217. } else {
  218. return {
  219. score,
  220. reply,
  221. result,
  222. answer
  223. }
  224. }
  225. })
  226. const isFistStId = computed(() => {
  227. if (data.StListForSearch.length) {
  228. return data.StListForSearch[0].stId == activeSt.value.stId
  229. } else {
  230. return false
  231. }
  232. });
  233. const isLastStId = computed(() => {
  234. if (data.StListForSearch.length) {
  235. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  236. } else {
  237. return false
  238. }
  239. });
  240. onLoad((options) => {
  241. hisId.value = options.hisId;
  242. initPage()
  243. })
  244. function getQaClass(qa) {
  245. if (qa.marked && qa.marked === true) {
  246. return 'paragraph-qa-block-mark';
  247. } else {
  248. if (qa.stTypeId == 1) {
  249. if (checkDanxuanReply(qa)) {
  250. return 'paragraph-qa-block-done';
  251. } else {
  252. return 'paragraph-qa-block-init';
  253. }
  254. } else if (qa.stTypeId == 2) {
  255. if (checkDuoxuanReply(qa)) {
  256. return 'paragraph-qa-block-done';
  257. } else {
  258. return 'paragraph-qa-block-init';
  259. }
  260. } else if (qa.stTypeId == 3) {
  261. if (checkPanduanReply(qa)) {
  262. return 'paragraph-qa-block-done';
  263. } else {
  264. return 'paragraph-qa-block-init';
  265. }
  266. } else if (qa.stTypeId == 4) {
  267. if (checkTiankongReply(qa)) {
  268. return 'paragraph-qa-block-done';
  269. } else {
  270. return 'paragraph-qa-block-init';
  271. }
  272. }
  273. }
  274. }
  275. function skipQuestion(dlIndex, dtIndex) {
  276. progress.dlIndex = dlIndex;
  277. progress.dtIndex = dtIndex;
  278. handlePopupBack()
  279. }
  280. function answerCardItemClick(qa) {
  281. const actQa = data.StListForSearch.find(item => item.stId == qa.stId);
  282. skipQuestion(actQa.dlIndex, actQa.dtIndex)
  283. }
  284. function handleBack() {
  285. uni.redirectTo({
  286. url: "/pages/admin/Chengji/list"
  287. })
  288. }
  289. function formatDuanluoList() {
  290. let uIndex = 0; // 试题num
  291. let iDuanluo = 0; // 段落num
  292. let result = [];
  293. for (const duanluo of data.duanluo) {
  294. let paragraph = {
  295. qas: [],
  296. };
  297. paragraph.name = duanluo.name;
  298. let iQa = 0; // 当前试题序号
  299. let order = 0; // 当前题型中第几题
  300. for (const iDanxuan of duanluo.danxuan) {
  301. iDanxuan.type = 'danxuan';
  302. iDanxuan.marked = false;
  303. iDanxuan.onlyNum = uIndex + 1;
  304. iDanxuan.order = order;
  305. iDanxuan.iQa = iQa;
  306. paragraph.qas.push(iDanxuan);
  307. uIndex++;
  308. order++;
  309. iQa++;
  310. data.StListForSearch.push({
  311. stId: iDanxuan.stId,
  312. paragraphName: paragraph.name,
  313. dlIndex: iDuanluo,
  314. dtIndex: iDanxuan.iQa,
  315. num: iDanxuan.onlyNum
  316. })
  317. }
  318. order = 0;
  319. for (const iDuoxuan of duanluo.duoxuan) {
  320. iDuoxuan.type = 'duoxuan';
  321. iDuoxuan.marked = false;
  322. iDuoxuan.onlyNum = uIndex + 1;
  323. iDuoxuan.order = order;
  324. paragraph.qas.push(iDuoxuan);
  325. iDuoxuan.iQa = iQa;
  326. uIndex++;
  327. order++;
  328. iQa++;
  329. data.StListForSearch.push({
  330. stId: iDuoxuan.stId,
  331. paragraphName: paragraph.name,
  332. dlIndex: iDuanluo,
  333. dtIndex: iDuoxuan.iQa,
  334. num: iDuoxuan.onlyNum
  335. })
  336. }
  337. order = 0;
  338. for (const iPanduan of duanluo.panduan) {
  339. iPanduan.type = 'panduan';
  340. iPanduan.marked = false;
  341. iPanduan.onlyNum = uIndex + 1;
  342. iPanduan.order = order;
  343. paragraph.qas.push(iPanduan);
  344. iPanduan.iQa = iQa;
  345. uIndex++;
  346. order++;
  347. iQa++;
  348. data.StListForSearch.push({
  349. stId: iPanduan.stId,
  350. paragraphName: paragraph.name,
  351. dlIndex: iDuanluo,
  352. dtIndex: iPanduan.iQa,
  353. num: iPanduan.onlyNum
  354. })
  355. }
  356. order = 0;
  357. for (const iTiankong of duanluo.tiankong) {
  358. iTiankong.type = 'tiankong';
  359. iTiankong.marked = false;
  360. iTiankong.onlyNum = uIndex + 1;
  361. iTiankong.order = order;
  362. paragraph.qas.push(iTiankong);
  363. iTiankong.iQa = iQa;
  364. uIndex++;
  365. order++;
  366. iQa++;
  367. data.StListForSearch.push({
  368. stId: iTiankong.stId,
  369. paragraphName: paragraph.name,
  370. dlIndex: iDuanluo,
  371. dtIndex: iTiankong.iQa,
  372. num: iTiankong.onlyNum
  373. })
  374. }
  375. iDuanluo++;
  376. questionData.value.push(paragraph)
  377. }
  378. }
  379. function handlePrev() {
  380. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  381. const index = qa.num - 1;
  382. if (index > 0) {
  383. const result = data.StListForSearch[index - 1];
  384. progress.dlIndex = result.dlIndex;
  385. progress.dtIndex = result.dtIndex
  386. }
  387. }
  388. function handleNext() {
  389. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  390. const index = qa.num - 1;
  391. if (index < data.StListForSearch.length) {
  392. const result = data.StListForSearch[index + 1];
  393. progress.dlIndex = result.dlIndex;
  394. progress.dtIndex = result.dtIndex
  395. }
  396. }
  397. function initPage() {
  398. ksApi.getAdminKsChengjiView({
  399. hisId: hisId.value
  400. }).then(res => {
  401. const {
  402. duanluoList,
  403. ksName,
  404. zyLevelName,
  405. userScore,
  406. ksScore
  407. } = res.data;
  408. data.ksName = ksName;
  409. data.zyLevelName = zyLevelName;
  410. data.userScore = userScore;
  411. data.ksScore = ksScore;
  412. data.duanluo = duanluoList;
  413. formatDuanluoList();
  414. })
  415. }
  416. function handlePopupBack() {
  417. popupRef.value.close()
  418. }
  419. function handleOpenCard() {
  420. popupRef.value.open('top')
  421. }
  422. </script>
  423. <style>
  424. </style>