index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <div class="scroll_content">
  3. <div class="select_box">
  4. <el-radio-group v-model="errorType" size="medium" @change="_queryStudentErrorQuestion">
  5. <el-radio-button :label="-1">全部试题({{ allErrorCount }})</el-radio-button>
  6. <el-radio-button :label="0">未掌握({{ unMasterCount }})</el-radio-button>
  7. <el-radio-button :label="1">已掌握({{ masterCount }})</el-radio-button>
  8. <el-radio-button :label="2">复习题({{ reviewCount }})</el-radio-button>
  9. </el-radio-group>
  10. </div>
  11. <div class="content">
  12. <div class="right_btn" v-if="errorType !== 1">
  13. <el-button size="medium" @click="downloadDialogVisible = true">下载错题本</el-button>
  14. <el-button type="primary" size="medium" @click="downloadDialogVisible = true">下载个性化提升手册</el-button>
  15. </div>
  16. <Download :visible.sync="downloadDialogVisible" :examId="examId" :subjectCode="subjectCode" />
  17. <template v-if="questionList.length > 0">
  18. <div v-for="(question, index) in questionList" :key="question.questionId">
  19. <div class="question_card">
  20. <div class="card_top">
  21. <div class="card_top_info">
  22. <div class="left">
  23. <span class="number mr_10">{{ countGlobalIndex(index + 1) }}</span>
  24. <span class="gray">试题类型:</span>
  25. <span class="black mr_10">{{ question.questionType }}</span>
  26. <span class="tag" v-if="question.classScoreRate < 40">高频错题</span>
  27. </div>
  28. </div>
  29. <div class="question_content" v-if="question.sourceType === 1"
  30. v-html="question.questionData.questionStem"></div>
  31. <div class="question_content" v-if="question.sourceType === 2">
  32. <img :src="question.questionImg" alt="" width="100%">
  33. </div>
  34. <div class="card_footer">
  35. <div class="footer_item">
  36. <span class="gray">满分:</span>
  37. <span class="blue">{{ question.fullScore }}</span>
  38. <span class="gray">分</span>
  39. </div>
  40. <div class="footer_item">
  41. <span class="gray">我的得分:</span>
  42. <span class="blue">{{ question.score }}</span>
  43. <span class="gray">分</span>
  44. </div>
  45. <div class="footer_item">
  46. <span class="gray">难度:</span>
  47. <span :class="countDiffcutyClass(question.difficulty)">{{ question.difficulty }}
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="card_buttom">
  53. <div class="btn_box">
  54. <span class="black" :class="{ blue: question.answerShow }" size="small"
  55. @click="ShowAnserAndParse(1, question);">
  56. <i class="iconfont icon_daan"></i>
  57. 我的答案
  58. <i class="answerShow_content" v-if="question.answerShow && !question.parseShow"></i>
  59. </span>
  60. <span class="black" :class="{ blue: question.parseShow }" size="small"
  61. @click="ShowAnserAndParse(2, question);">
  62. <i class="iconfont icon_jiexi"></i>
  63. 查看解析
  64. <i class="parseShow_content" v-if="question.parseShow && !question.answerShow"></i>
  65. </span>
  66. <template v-if="question.errorStatus === 0">
  67. <template v-if="errorType === -1 || errorType === 0">
  68. <span class="black" size="small"
  69. @click="_markStudentErrorQuestion(question, 1)">
  70. <i class="iconfont icon_biaojiyizhangwo"></i>
  71. 标记为已掌握
  72. </span>
  73. <span class="black" size="small"
  74. @click="_markStudentErrorQuestion(question, 2)">
  75. <i class="iconfont icon_jiarufuxiben"></i>
  76. 加入复习本
  77. </span>
  78. </template>
  79. </template>
  80. <template v-if="errorType === 1 || question.errorStatus === 1">
  81. <span class="black" size="small" @click="_markStudentErrorQuestion(question, 0)">
  82. <i class="iconfont icon_biaojiweizhangwo"></i>
  83. 标记为未掌握
  84. </span>
  85. </template>
  86. <template v-if="errorType === 2 || question.errorStatus === 2">
  87. <span class="black" size="small" @click="_markStudentErrorQuestion(question, 0)">
  88. <i class="iconfont icon_yichufuxiben"></i>
  89. 移除复习本
  90. </span>
  91. </template>
  92. </div>
  93. <div class="content" v-if="question.parseShow && !question.answerShow">
  94. <div class="flex" style="align-items: center;">
  95. <div class="flex_left">知识点:</div>
  96. <div class="flex_right">
  97. <template v-if="question.knowledgePoint && question.knowledgePoint.length > 0">
  98. <KnowledgePoint v-for="(know, index) in question.knowledgePoint"
  99. :key="index" :text="know" />
  100. </template>
  101. </div>
  102. </div>
  103. <div class="flex">
  104. <div class="flex_left">答&nbsp;&nbsp;&nbsp;案:</div>
  105. <div class="flex_right">
  106. <div v-if="question.sourceType === 1" v-html="question.questionData.answer">
  107. </div>
  108. <div v-if="question.sourceType === 2">
  109. <img :src="question.answerImg" alt="" width="100%" />
  110. </div>
  111. </div>
  112. </div>
  113. <div class="flex">
  114. <div class="flex_left">解&nbsp;&nbsp;&nbsp;析:</div>
  115. <div class="flex_right">
  116. <div style="line-height: 1.5;" v-show="question.sourceType === 1"
  117. v-html="question.questionData.analysis">
  118. </div>
  119. <div v-if="question.sourceType === 2">
  120. <img :src="question.parseImg" alt="" width="100%" />
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="content" v-if="question.answerShow && !question.parseShow">
  126. <div class="content_inner" v-if="question.sourceType === 1"
  127. v-html="question.studentAnswer"></div>
  128. <div class="content_inner" v-if="question.sourceType === 2">
  129. <img :src="question.studentAnswerImg" alt="" width="100%" />
  130. </div>
  131. </div>
  132. </div>
  133. </div>
  134. <!-- 变式题推送,无数据 -->
  135. <div class="question_card" v-if="question.variationQuestion">
  136. <div class="card_top">
  137. <div class="card_top_info">
  138. <div class="left">
  139. <span class="number mr_10"
  140. :class="countLevel(question.variationQuestion.questionLevel).color">
  141. {{ countLevel(question.variationQuestion.questionLevel).text }}
  142. </span>
  143. <span class="gray">试题类型:</span>
  144. <span class="black" style="margin-right: 20px;">
  145. {{ question.variationQuestion.questionType }}
  146. </span>
  147. <span class="gray">难度:</span>
  148. <span :class="countDiffcutyClass(question.variationQuestion.difficulty)">{{
  149. question.variationQuestion.difficulty }}</span>
  150. </div>
  151. </div>
  152. <div class="question_content" v-html="question.variationQuestion.questionStem">这是题目内容</div>
  153. <!-- <div class="yuwen">
  154. <span class="btn_span active">1</span>
  155. <span class="btn_span">2</span>
  156. <div class="question_list"></div>
  157. </div> -->
  158. <div class="card_footer">
  159. <div class="gray">知识点:</div>
  160. <KnowledgePoint :text="question.variationQuestion.knowledgePoint" />
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <div style="text-align: right;">
  166. <el-pagination background layout="prev, pager, next" :total="pageParam.total"
  167. :page-size="pageParam.pageSize" :current-page="pageParam.pageNum"
  168. @current-change="handleCurrentChange">
  169. </el-pagination>
  170. </div>
  171. </template>
  172. <NoData v-else>暂无数据</NoData>
  173. </div>
  174. </div>
  175. </template>
  176. <script>
  177. import {
  178. queryStudentErrorQuestion,
  179. markStudentErrorQuestion,
  180. downloadStudentErrorQuestion,
  181. } from '../../../http/api/errorQuestion';
  182. import Download from './Download.vue';
  183. import loadImg from './loadImg.js'
  184. import { Loading } from 'element-ui';
  185. import NoData from './NoData/NoData.vue';
  186. import KnowledgePoint from './KnowledgePoint.vue';
  187. export default {
  188. components: {
  189. Download,
  190. NoData,
  191. KnowledgePoint,
  192. },
  193. data() {
  194. return {
  195. pageParam: {
  196. pageNum: 1,
  197. pageSize: 10,
  198. total: 0,
  199. },
  200. questionList: [],
  201. allErrorCount: 0,
  202. unMasterCount: 0,
  203. masterCount: 0,
  204. reviewCount: 0,
  205. answerUrls: [],
  206. uploadPaperUrls: [],
  207. errorType: -1, // -1全部 0未掌握 1已掌握 2复习题
  208. examId: null,
  209. examType: null,
  210. gradeCode: null,
  211. downloadDialogVisible: false,
  212. };
  213. },
  214. computed: {
  215. subjectCode() {
  216. return this.$store.state.report.filterObject.subjectCode;
  217. }, //分析报告公共参数变量
  218. },
  219. watch: {
  220. subjectCode(newVal, oldVal) {
  221. if (newVal !== oldVal) {
  222. this._queryStudentErrorQuestion();
  223. }
  224. },
  225. },
  226. created() {
  227. const ExamInfoItem = JSON.parse(localStorage.getItem("ExamInfoItem") || "{}");
  228. const reportExamCourseItem = JSON.parse(localStorage.getItem("reportExamCourseItem") || "{}");
  229. this.examId = reportExamCourseItem.examId;
  230. this.gradeCode = ExamInfoItem.examData.gradeCode;
  231. this.examType = ExamInfoItem.examData.examType;
  232. },
  233. async mounted() {
  234. await this._queryStudentErrorQuestion();
  235. },
  236. methods: {
  237. countGlobalIndex(index) {
  238. return (this.pageParam.pageNum - 1) * this.pageParam.pageSize + index;
  239. },
  240. countDiffcutyClass(difficulty) {
  241. // 容易:#90CB75 较易:#FAC858 一般:#5470C6 较难:#EA7ACB 困难:#EE6666
  242. const classMap = {
  243. '容易': 'easy',
  244. '较易': 'medium_easy',
  245. '一般': 'medium',
  246. '较难': 'medium_hard',
  247. '困难': 'hard'
  248. }
  249. return classMap[difficulty] || ''
  250. },
  251. countLevel(num) {
  252. const arr = ['拔高题', '进阶题', '巩固题']
  253. const color = ['easy', 'medium', 'hard']
  254. return {
  255. text: arr[num - 1],
  256. color: color[num - 1],
  257. }
  258. },
  259. ShowAnserAndParse(type, question) {
  260. if (type === 1) {
  261. question.answerShow = !question.answerShow;
  262. question.parseShow = false
  263. }
  264. if (type === 2) {
  265. question.parseShow = !question.parseShow;
  266. question.answerShow = false
  267. }
  268. },
  269. async _queryStudentErrorQuestion() {
  270. const instance = Loading.service({ fullscreen: true });
  271. const { subjectCode, gradeCode, examType, examId, errorType, pageParam: { pageNum, pageSize } } = this
  272. const res = await queryStudentErrorQuestion({ subjectCode, gradeCode, examType, examId, errorType, pageNum, pageSize });
  273. if (res.code === 200) {
  274. const { allErrorCount, unMasterCount, masterCount, reviewCount, questionList, answerUrls, uploadPaperUrls } = res.data.records[0];
  275. this.allErrorCount = allErrorCount;
  276. this.masterCount = masterCount;
  277. this.unMasterCount = unMasterCount;
  278. this.reviewCount = reviewCount;
  279. this.answerUrls = answerUrls;
  280. this.uploadPaperUrls = uploadPaperUrls;
  281. this.pageParam.total = res.data.total * 1;
  282. for (let i = 0; i < questionList.length; i++) {
  283. const { sourceType, titleCoordinates, answerCoordinates, parseCoordinates, paintingPosition } = questionList[i]
  284. questionList[i].answerShow = false;
  285. questionList[i].parseShow = false;
  286. if (sourceType === 2) {
  287. const questionImg = await loadImg(this.uploadPaperUrls, titleCoordinates);
  288. questionList[i].questionImg = questionImg;
  289. const answerImg = await loadImg(this.answerUrls, answerCoordinates);
  290. questionList[i].answerImg = answerImg;
  291. const parseImg = await loadImg(this.answerUrls, parseCoordinates);
  292. questionList[i].parseImg = parseImg;
  293. // TODO: 学生答案图片加载,由于
  294. const studentAnswerImg = await loadImg(this.answerUrls, paintingPosition);
  295. questionList[i].studentAnswerImg = studentAnswerImg;
  296. }
  297. }
  298. this.questionList = questionList;
  299. // 缓慢滚动到顶部
  300. this.scrollToTop();
  301. }
  302. instance.close();
  303. },
  304. scrollToTop() {
  305. // 等待 DOM 更新完成
  306. this.$nextTick(() => {
  307. const container = document.querySelector('.content_right');
  308. if (container) {
  309. container.scrollTo({ top: 0, behavior: 'smooth' });
  310. }
  311. });
  312. },
  313. async _markStudentErrorQuestion(question, markStatus) {
  314. const res = await markStudentErrorQuestion({
  315. questionId: question.questionId,
  316. examId: this.examId,
  317. subjectCode: this.subjectCode,
  318. markStatus
  319. })
  320. if (res.code === 200) {
  321. this.$message.success('操作成功');
  322. await this._queryStudentErrorQuestion();
  323. } else {
  324. this.$message.error(res.message || '操作失败');
  325. }
  326. },
  327. async handleCurrentChange(page) {
  328. this.pageParam.pageNum = page;
  329. await this._queryStudentErrorQuestion();
  330. },
  331. },
  332. }
  333. </script>
  334. <style scoped lang="scss">
  335. .flex {
  336. display: flex;
  337. margin-bottom: 10px;
  338. .flex_left {
  339. width: 60px;
  340. }
  341. .flex_right {
  342. flex: 1;
  343. }
  344. }
  345. .select_box {
  346. background-color: #ffffff;
  347. border-radius: 10px;
  348. padding: 10px;
  349. margin-bottom: 10px;
  350. }
  351. .content {
  352. background-color: #ffffff;
  353. border-radius: 10px;
  354. padding: 20px;
  355. margin-bottom: 10px;
  356. }
  357. .right_btn {
  358. display: flex;
  359. justify-content: flex-end;
  360. margin-bottom: 10px;
  361. }
  362. .question_card {
  363. margin-bottom: 10px;
  364. border: 1px solid #DCDFE6;
  365. border-radius: 10px;
  366. overflow: hidden;
  367. .card_top {
  368. padding: 20px;
  369. }
  370. .card_top_info {
  371. display: flex;
  372. justify-content: space-between;
  373. margin-bottom: 20px;
  374. .left {
  375. display: flex;
  376. align-items: center;
  377. span {
  378. font-size: 14px;
  379. }
  380. .tag {
  381. color: #ffffff;
  382. padding: 4px 5px;
  383. font-size: 12px;
  384. background-color: #F56C6C;
  385. border-radius: 2px;
  386. position: relative;
  387. &::before {
  388. content: '';
  389. position: absolute;
  390. left: -5px;
  391. top: 50%;
  392. transform: translateY(-50%);
  393. width: 0;
  394. height: 0;
  395. border-top: 5px solid transparent;
  396. border-bottom: 5px solid transparent;
  397. border-right: 5px solid #EE6666;
  398. }
  399. }
  400. }
  401. }
  402. .number {
  403. color: #ffffff;
  404. font-size: 14px;
  405. padding: 5px 9px;
  406. background-color: #2E64FA;
  407. border-radius: 4px;
  408. }
  409. .btn_span {
  410. color: #2E64FA;
  411. font-size: 14px;
  412. padding: 5px 9px;
  413. border: 1px solid #2E64FA;
  414. border-radius: 4px;
  415. cursor: pointer;
  416. margin-right: 10px;
  417. &.active {
  418. color: #ffffff;
  419. background-color: #2E64FA;
  420. border-radius: 4px;
  421. }
  422. }
  423. .gray {
  424. color: #999;
  425. }
  426. .black {
  427. color: #333;
  428. }
  429. .blue {
  430. color: #2E64FA;
  431. }
  432. .question_content {
  433. margin-bottom: 20px;
  434. }
  435. .yuwen {
  436. margin-top: 20px;
  437. .question_list {
  438. margin-top: 20px;
  439. height: 100px;
  440. padding-top: 20px;
  441. border-top: 1px solid #EBEEF5;
  442. }
  443. }
  444. .card_footer {
  445. display: flex;
  446. align-items: center;
  447. padding-top: 20px;
  448. border-top: 1px solid #EBEEF5;
  449. .footer_item {
  450. margin-right: 40px;
  451. span {
  452. margin-right: 5px;
  453. }
  454. }
  455. }
  456. .card_buttom {
  457. background-color: #F0F2F5;
  458. padding: 15px 20px;
  459. .btn_box {
  460. display: flex;
  461. justify-content: flex-end;
  462. span {
  463. margin-left: 20px;
  464. cursor: pointer;
  465. }
  466. }
  467. .content {
  468. padding: 20px;
  469. background-color: #ffffff;
  470. margin-top: 20px;
  471. border-radius: 10px;
  472. .content_inner {
  473. border: 2px dotted #DCDFE6;
  474. border-radius: 4px;
  475. padding: 10px;
  476. }
  477. }
  478. .parseShow_content {
  479. position: relative;
  480. &::before {
  481. content: '';
  482. position: absolute;
  483. right: 20px;
  484. /* 根据需要调整三角水平位置 */
  485. top: 24px;
  486. /* 三角放置在外部,超出上方 */
  487. width: 0;
  488. height: 0;
  489. border-left: 10px solid transparent;
  490. border-right: 10px solid transparent;
  491. border-bottom: 12px solid #ffffff;
  492. z-index: 2;
  493. }
  494. }
  495. .answerShow_content {
  496. position: relative;
  497. &::before {
  498. content: '';
  499. position: absolute;
  500. right: 20px;
  501. /* 根据需要调整三角水平位置 */
  502. top: 24px;
  503. /* 三角放置在外部,超出上方 */
  504. width: 0;
  505. height: 0;
  506. border-left: 10px solid transparent;
  507. border-right: 10px solid transparent;
  508. border-bottom: 12px solid #ffffff;
  509. z-index: 2;
  510. }
  511. }
  512. }
  513. }
  514. </style>