ksScoreShijuan.vue 11 KB

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