ksScoreShijuan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  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.score;
  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 == 0) {
  179. reply = '错误'
  180. }else if (qa.reply == 1) {
  181. reply = '正确'
  182. }
  183. if (qa.result == 0) {
  184. result = '错误'
  185. }else if (qa.result == 1) {
  186. result = '正确'
  187. }
  188. }
  189. if (qa.stTypeId == 4) {
  190. let reply = qa.reply || [];
  191. let result =qa.result || [];
  192. // 填空题
  193. return {score,reply,result,answer}
  194. } else {
  195. return {
  196. score,reply,result,answer
  197. }
  198. }
  199. })
  200. const isFistStId = computed(() => {
  201. if (data.StListForSearch.length) {
  202. return data.StListForSearch[0].stId == activeSt.value.stId
  203. } else {
  204. return false
  205. }
  206. });
  207. const isLastStId = computed(() => {
  208. if (data.StListForSearch.length) {
  209. return data.StListForSearch[data.StListForSearch.length - 1].stId == activeSt.value.stId
  210. } else {
  211. return false
  212. }
  213. });
  214. onLoad((options) => {
  215. hisId.value = options.hisId;
  216. data.from = options.from;
  217. initPage()
  218. })
  219. function getQaClass(qa) {
  220. if (qa.marked && qa.marked === true) {
  221. return 'paragraph-qa-block-mark';
  222. } else {
  223. if (qa.stTypeId == 1) {
  224. if (checkDanxuanReply(qa)) {
  225. return 'paragraph-qa-block-done';
  226. } else {
  227. return 'paragraph-qa-block-init';
  228. }
  229. } else if (qa.stTypeId == 2) {
  230. if (checkDuoxuanReply(qa)) {
  231. return 'paragraph-qa-block-done';
  232. } else {
  233. return 'paragraph-qa-block-init';
  234. }
  235. } else if (qa.stTypeId == 3) {
  236. if (checkPanduanReply(qa)) {
  237. return 'paragraph-qa-block-done';
  238. } else {
  239. return 'paragraph-qa-block-init';
  240. }
  241. } else if (qa.stTypeId == 4) {
  242. if (checkTiankongReply(qa)) {
  243. return 'paragraph-qa-block-done';
  244. } else {
  245. return 'paragraph-qa-block-init';
  246. }
  247. }
  248. }
  249. }
  250. function handleBack() {
  251. if (data.from == 'chengjiList') {
  252. uni.redirectTo({
  253. url: "/pages/client/Chengji/list"
  254. })
  255. } else if (data.from == 'kaoshi'){
  256. uni.redirectTo({
  257. url: "/pages/client/Kaoshi/list"
  258. })
  259. }
  260. }
  261. function formatDuanluoList() {
  262. let uIndex = 0; // 试题num
  263. let iDuanluo = 0; // 段落num
  264. let result = [];
  265. for (const duanluo of data.duanluo) {
  266. let paragraph = {
  267. qas: [],
  268. };
  269. paragraph.name = duanluo.name;
  270. let iQa = 0; // 当前试题序号
  271. let order = 0; // 当前题型中第几题
  272. for (const iDanxuan of duanluo.danxuan) {
  273. iDanxuan.type = 'danxuan';
  274. iDanxuan.marked = false;
  275. iDanxuan.onlyNum = uIndex + 1;
  276. iDanxuan.order = order;
  277. iDanxuan.iQa = iQa;
  278. paragraph.qas.push(iDanxuan);
  279. uIndex++;
  280. order++;
  281. iQa++;
  282. data.StListForSearch.push({
  283. stId: iDanxuan.stId,
  284. paragraphName: paragraph.name,
  285. dlIndex: iDuanluo,
  286. dtIndex: iDanxuan.iQa,
  287. num: iDanxuan.onlyNum
  288. })
  289. }
  290. order = 0;
  291. for (const iDuoxuan of duanluo.duoxuan) {
  292. iDuoxuan.type = 'duoxuan';
  293. iDuoxuan.marked = false;
  294. iDuoxuan.onlyNum = uIndex + 1;
  295. iDuoxuan.order = order;
  296. paragraph.qas.push(iDuoxuan);
  297. iDuoxuan.iQa = iQa;
  298. uIndex++;
  299. order++;
  300. iQa++;
  301. data.StListForSearch.push({
  302. stId: iDuoxuan.stId,
  303. paragraphName: paragraph.name,
  304. dlIndex: iDuanluo,
  305. dtIndex: iDuoxuan.iQa,
  306. num: iDuoxuan.onlyNum
  307. })
  308. }
  309. order = 0;
  310. for (const iPanduan of duanluo.panduan) {
  311. iPanduan.type = 'panduan';
  312. iPanduan.marked = false;
  313. iPanduan.onlyNum = uIndex + 1;
  314. iPanduan.order = order;
  315. paragraph.qas.push(iPanduan);
  316. iPanduan.iQa = iQa;
  317. uIndex++;
  318. order++;
  319. iQa++;
  320. data.StListForSearch.push({
  321. stId: iPanduan.stId,
  322. paragraphName: paragraph.name,
  323. dlIndex: iDuanluo,
  324. dtIndex: iPanduan.iQa,
  325. num: iPanduan.onlyNum
  326. })
  327. }
  328. order = 0;
  329. for (const iTiankong of duanluo.tiankong) {
  330. iTiankong.type = 'tiankong';
  331. iTiankong.marked = false;
  332. iTiankong.onlyNum = uIndex + 1;
  333. iTiankong.order = order;
  334. paragraph.qas.push(iTiankong);
  335. iTiankong.iQa = iQa;
  336. uIndex++;
  337. order++;
  338. iQa++;
  339. data.StListForSearch.push({
  340. stId: iTiankong.stId,
  341. paragraphName: paragraph.name,
  342. dlIndex: iDuanluo,
  343. dtIndex: iTiankong.iQa,
  344. num: iTiankong.onlyNum
  345. })
  346. }
  347. iDuanluo++;
  348. questionData.value.push(paragraph)
  349. }
  350. }
  351. function handlePrev() {
  352. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  353. const index = qa.num - 1;
  354. if (index > 0) {
  355. const result = data.StListForSearch[index - 1];
  356. progress.dlIndex = result.dlIndex;
  357. progress.dtIndex = result.dtIndex
  358. }
  359. }
  360. function handleNext() {
  361. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  362. const index = qa.num - 1;
  363. if (index < data.StListForSearch.length) {
  364. const result = data.StListForSearch[index + 1];
  365. progress.dlIndex = result.dlIndex;
  366. progress.dtIndex = result.dtIndex
  367. }
  368. }
  369. function initPage() {
  370. ksApi.getClientKsChengjiView({hisId: hisId.value}).then(res => {
  371. const { duanluoList,ksName, zyLevelName,userScore,ksScore } = res.data;
  372. data.ksName = ksName;
  373. data.zyLevelName = zyLevelName;
  374. data.userScore = userScore;
  375. data.ksScore = ksScore;
  376. data.duanluo = duanluoList;
  377. formatDuanluoList();
  378. })
  379. }
  380. function handlePopupBack() {
  381. popupRef.value.close()
  382. }
  383. function handleOpenCard() {
  384. popupRef.value.open('bottom')
  385. }
  386. </script>
  387. <style>
  388. </style>