ksScoreShijuan.vue 11 KB

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