ksScoreShijuan.vue 11 KB

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