ksScoreShijuan.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. <template>
  2. <view class="socre-shijuan">
  3. <!-- 导航区域 -->
  4. <view class="icon-title-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. <view>
  11. <!-- 段落 -->
  12. <view class="kaoshi-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">
  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. <template v-if="activeSt">
  60. <button type="default" size="mini" hover-class="none" class="phone-green-btn ks-btn-prev" @click="handlePrev" v-if="!isFistStId">上一题</button>
  61. <button type="default" size="mini" hover-class="none"class="phone-green-btn ks-btn-next" @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. </view>
  82. </template>
  83. <script setup>
  84. import topCard from "@/components/score/topCard.vue"
  85. import danxuan from "@/components/questions/danxuan.vue";
  86. import duoxuan from "@/components/questions/duoxuan.vue";
  87. import tiankong from "@/components/questions/tiankong.vue";
  88. import panduan from "@/components/questions/panduan.vue";
  89. import {useQuestionTools} from "@/components/questions/useQuestionTools.js";
  90. import { onLoad } from "@dcloudio/uni-app";
  91. import {ref,reactive,computed} from "vue"
  92. import * as lxApi from "@/api/lianxi.js"
  93. const {
  94. checkDanxuanReply,
  95. checkDuoxuanReply,
  96. checkPanduanReply,
  97. checkTiankongReply,
  98. getLetterByIndex
  99. } = useQuestionTools();
  100. const hisId = ref(null)
  101. const popupRef = ref(null)
  102. const data = reactive({
  103. ksId: null,
  104. ksName: '',
  105. stTotal: 0,
  106. zyLevelName: '',
  107. userScore: '',
  108. ksScore: 0,
  109. StListForSearch: [],
  110. duanluo: []
  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. 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. uni.redirectTo({
  246. url: "/pages/admin/Lianxi/list"
  247. })
  248. }
  249. function formatDuanluoList() {
  250. let uIndex = 0; // 试题num
  251. let iDuanluo = 0; // 段落num
  252. let result = [];
  253. for (const duanluo of data.duanluo) {
  254. let paragraph = {
  255. qas: [],
  256. };
  257. paragraph.name = duanluo.name;
  258. let iQa = 0; // 当前试题序号
  259. let order = 0; // 当前题型中第几题
  260. for (const iDanxuan of duanluo.danxuan) {
  261. iDanxuan.type = 'danxuan';
  262. iDanxuan.marked = false;
  263. iDanxuan.onlyNum = uIndex + 1;
  264. iDanxuan.order = order;
  265. iDanxuan.iQa = iQa;
  266. paragraph.qas.push(iDanxuan);
  267. uIndex++;
  268. order++;
  269. iQa++;
  270. data.StListForSearch.push({
  271. stId: iDanxuan.stId,
  272. paragraphName: paragraph.name,
  273. dlIndex: iDuanluo,
  274. dtIndex: iDanxuan.iQa,
  275. num: iDanxuan.onlyNum
  276. })
  277. }
  278. order = 0;
  279. for (const iDuoxuan of duanluo.duoxuan) {
  280. iDuoxuan.type = 'duoxuan';
  281. iDuoxuan.marked = false;
  282. iDuoxuan.onlyNum = uIndex + 1;
  283. iDuoxuan.order = order;
  284. paragraph.qas.push(iDuoxuan);
  285. iDuoxuan.iQa = iQa;
  286. uIndex++;
  287. order++;
  288. iQa++;
  289. data.StListForSearch.push({
  290. stId: iDuoxuan.stId,
  291. paragraphName: paragraph.name,
  292. dlIndex: iDuanluo,
  293. dtIndex: iDuoxuan.iQa,
  294. num: iDuoxuan.onlyNum
  295. })
  296. }
  297. order = 0;
  298. for (const iPanduan of duanluo.panduan) {
  299. iPanduan.type = 'panduan';
  300. iPanduan.marked = false;
  301. iPanduan.onlyNum = uIndex + 1;
  302. iPanduan.order = order;
  303. paragraph.qas.push(iPanduan);
  304. iPanduan.iQa = iQa;
  305. uIndex++;
  306. order++;
  307. iQa++;
  308. data.StListForSearch.push({
  309. stId: iPanduan.stId,
  310. paragraphName: paragraph.name,
  311. dlIndex: iDuanluo,
  312. dtIndex: iPanduan.iQa,
  313. num: iPanduan.onlyNum
  314. })
  315. }
  316. order = 0;
  317. for (const iTiankong of duanluo.tiankong) {
  318. iTiankong.type = 'tiankong';
  319. iTiankong.marked = false;
  320. iTiankong.onlyNum = uIndex + 1;
  321. iTiankong.order = order;
  322. paragraph.qas.push(iTiankong);
  323. iTiankong.iQa = iQa;
  324. uIndex++;
  325. order++;
  326. iQa++;
  327. data.StListForSearch.push({
  328. stId: iTiankong.stId,
  329. paragraphName: paragraph.name,
  330. dlIndex: iDuanluo,
  331. dtIndex: iTiankong.iQa,
  332. num: iTiankong.onlyNum
  333. })
  334. }
  335. iDuanluo++;
  336. questionData.value.push(paragraph)
  337. }
  338. }
  339. function handlePrev() {
  340. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  341. const index = qa.num - 1;
  342. if (index > 0) {
  343. const result = data.StListForSearch[index - 1];
  344. progress.dlIndex = result.dlIndex;
  345. progress.dtIndex = result.dtIndex
  346. }
  347. }
  348. function handleNext() {
  349. const qa = data.StListForSearch.find(item => item.stId == activeSt.value.stId);
  350. const index = qa.num - 1;
  351. if (index < data.StListForSearch.length) {
  352. const result = data.StListForSearch[index + 1];
  353. progress.dlIndex = result.dlIndex;
  354. progress.dtIndex = result.dtIndex
  355. }
  356. }
  357. function initPage() {
  358. lxApi.getClientKsChengjiView({hisId: hisId.value}).then(res => {
  359. const { duanluoList,ksName, zyLevelName,userScore,ksScore } = res.data;
  360. data.ksName = ksName;
  361. data.zyLevelName = zyLevelName;
  362. data.userScore = userScore;
  363. data.ksScore = ksScore;
  364. data.duanluo = duanluoList;
  365. formatDuanluoList();
  366. })
  367. }
  368. function handlePopupBack() {
  369. popupRef.value.close()
  370. }
  371. function handleOpenCard() {
  372. popupRef.value.open('bottom')
  373. }
  374. </script>
  375. <style>
  376. </style>