lxScoreShijuan.vue 11 KB

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