ksScoreShijuan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  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-bjcolor-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 handleBack() {
  274. uni.redirectTo({
  275. url: "/pages/admin/Chengji/list"
  276. })
  277. }
  278. function formatDuanluoList() {
  279. let uIndex = 0; // 试题num
  280. let iDuanluo = 0; // 段落num
  281. let result = [];
  282. for (const duanluo of data.duanluo) {
  283. let paragraph = {
  284. qas: [],
  285. };
  286. paragraph.name = duanluo.name;
  287. let iQa = 0; // 当前试题序号
  288. let order = 0; // 当前题型中第几题
  289. for (const iDanxuan of duanluo.danxuan) {
  290. iDanxuan.type = 'danxuan';
  291. iDanxuan.marked = false;
  292. iDanxuan.onlyNum = uIndex + 1;
  293. iDanxuan.order = order;
  294. iDanxuan.iQa = iQa;
  295. paragraph.qas.push(iDanxuan);
  296. uIndex++;
  297. order++;
  298. iQa++;
  299. data.StListForSearch.push({
  300. stId: iDanxuan.stId,
  301. paragraphName: paragraph.name,
  302. dlIndex: iDuanluo,
  303. dtIndex: iDanxuan.iQa,
  304. num: iDanxuan.onlyNum
  305. })
  306. }
  307. order = 0;
  308. for (const iDuoxuan of duanluo.duoxuan) {
  309. iDuoxuan.type = 'duoxuan';
  310. iDuoxuan.marked = false;
  311. iDuoxuan.onlyNum = uIndex + 1;
  312. iDuoxuan.order = order;
  313. paragraph.qas.push(iDuoxuan);
  314. iDuoxuan.iQa = iQa;
  315. uIndex++;
  316. order++;
  317. iQa++;
  318. data.StListForSearch.push({
  319. stId: iDuoxuan.stId,
  320. paragraphName: paragraph.name,
  321. dlIndex: iDuanluo,
  322. dtIndex: iDuoxuan.iQa,
  323. num: iDuoxuan.onlyNum
  324. })
  325. }
  326. order = 0;
  327. for (const iPanduan of duanluo.panduan) {
  328. iPanduan.type = 'panduan';
  329. iPanduan.marked = false;
  330. iPanduan.onlyNum = uIndex + 1;
  331. iPanduan.order = order;
  332. paragraph.qas.push(iPanduan);
  333. iPanduan.iQa = iQa;
  334. uIndex++;
  335. order++;
  336. iQa++;
  337. data.StListForSearch.push({
  338. stId: iPanduan.stId,
  339. paragraphName: paragraph.name,
  340. dlIndex: iDuanluo,
  341. dtIndex: iPanduan.iQa,
  342. num: iPanduan.onlyNum
  343. })
  344. }
  345. order = 0;
  346. for (const iTiankong of duanluo.tiankong) {
  347. iTiankong.type = 'tiankong';
  348. iTiankong.marked = false;
  349. iTiankong.onlyNum = uIndex + 1;
  350. iTiankong.order = order;
  351. paragraph.qas.push(iTiankong);
  352. iTiankong.iQa = iQa;
  353. uIndex++;
  354. order++;
  355. iQa++;
  356. data.StListForSearch.push({
  357. stId: iTiankong.stId,
  358. paragraphName: paragraph.name,
  359. dlIndex: iDuanluo,
  360. dtIndex: iTiankong.iQa,
  361. num: iTiankong.onlyNum
  362. })
  363. }
  364. iDuanluo++;
  365. questionData.value.push(paragraph)
  366. }
  367. }
  368. function handlePrev() {
  369. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  370. const index = qa.num - 1;
  371. if (index > 0) {
  372. const result = data.StListForSearch[index - 1];
  373. progress.dlIndex = result.dlIndex;
  374. progress.dtIndex = result.dtIndex
  375. }
  376. }
  377. function handleNext() {
  378. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  379. const index = qa.num - 1;
  380. if (index < data.StListForSearch.length) {
  381. const result = data.StListForSearch[index + 1];
  382. progress.dlIndex = result.dlIndex;
  383. progress.dtIndex = result.dtIndex
  384. }
  385. }
  386. function initPage() {
  387. ksApi.getAdminKsChengjiView({
  388. hisId: hisId.value
  389. }).then(res => {
  390. const {
  391. duanluoList,
  392. ksName,
  393. zyLevelName,
  394. userScore,
  395. ksScore
  396. } = res.data;
  397. data.ksName = ksName;
  398. data.zyLevelName = zyLevelName;
  399. data.userScore = userScore;
  400. data.ksScore = ksScore;
  401. data.duanluo = duanluoList;
  402. formatDuanluoList();
  403. })
  404. }
  405. function handlePopupBack() {
  406. popupRef.value.close()
  407. }
  408. function handleOpenCard() {
  409. popupRef.value.open('bottom')
  410. }
  411. </script>
  412. <style>
  413. </style>