ksScoreShijuan.vue 12 KB

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