lxScoreShijuan.vue 11 KB

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