ksScoreShijuan.vue 11 KB

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