ksScoreShijuan.vue 11 KB

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