ExamResultPage.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <el-container>
  3. <el-header height="150">
  4. <el-card style="height: 150px">
  5. <span class="examName">{{ examRecord.examName }}</span>
  6. <span class="examTime">{{ examRecord.examTime }}</span>
  7. <el-row style="margin-top: 55px;">
  8. <el-tooltip class="item" effect="dark" content="包括选择题和判断题" placement="top-start">
  9. <span style="font-weight: 800;font-size: 17px">
  10. 客观题得分: {{ examRecord.logicScore }}分</span>
  11. </el-tooltip>
  12. <el-tooltip class="item" effect="dark" content="简答题与逻辑题" placement="top-start">
  13. <span style="float: right;font-weight: 800;font-size: 17px">
  14. 试卷总分: {{ examRecord.totalScore }}分</span>
  15. </el-tooltip>
  16. </el-row>
  17. </el-card>
  18. </el-header>
  19. <el-main>
  20. <el-card>
  21. <!--题目信息-->
  22. <div v-for="(item,index) in questionInfo" :key="index" style="margin-top: 15px">
  23. <div>
  24. <i class="num">{{ index + 1 }}</i>
  25. <span style="color: red;font-style: italic;font-weight: 400;">&nbsp;{{
  26. item.score
  27. }}分</span>
  28. <span v-if="item.questionType === 1">【单选题】</span>
  29. <span v-else-if="item.questionType === 2">【多选题】</span>
  30. <span v-else-if="item.questionType === 3">【不定项选择题】</span>
  31. <span v-else-if="item.questionType === 4">【判断题】</span>
  32. <span v-else-if="item.questionType === 5">【填空题】</span>
  33. <span v-else-if="item.questionType === 6">【问答题】</span>
  34. <span v-else-if="item.questionType === 7">【理解题】</span>
  35. <span v-else>【综合题】</span>
  36. <span v-html="item.questionContent" />
  37. </div>
  38. <!--题目中的配图-->
  39. <img
  40. v-for="url in item.images"
  41. :src="url"
  42. title="点击查看大图"
  43. alt="题目图片"
  44. style="width: 100px;height: 100px;cursor: pointer"
  45. @click="showBigImg(url)"
  46. >
  47. <!-- 单选和判断题候选答案列表 -->
  48. <div
  49. v-show="item.questionType === 1 || item.questionType === 4"
  50. style="margin-top: 25px"
  51. >
  52. <div class="el-radio-group">
  53. <label
  54. v-for="(i2,index2) in item.answer"
  55. :class="String(index2) === userAnswer[index] && i2.correct ?
  56. 'activeAndTrue' : String(index2) === userAnswer[index] ? 'active' :
  57. i2.correct ? 'true' : ''"
  58. >
  59. <span>{{ optionName[index2] + '、' + i2.answer }}</span>
  60. <img
  61. v-for="i3 in i2.images"
  62. v-if="i2.images !== null"
  63. style="position: absolute;left:100%;top:50%;transform: translateY(-50%);
  64. width: 40px;height: 40px;float: right;cursor: pointer;"
  65. title="点击查看大图"
  66. :src="i3"
  67. alt=""
  68. @mouseover="showBigImg(i3)"
  69. >
  70. </label>
  71. </div>
  72. </div>
  73. <!-- 多选和不定项选择题的候选答案列表 -->
  74. <div
  75. v-show="item.questionType === 2 || item.questionType === 3"
  76. style="margin-top: 25px"
  77. >
  78. <div class="el-radio-group">
  79. <label
  80. v-for="(i2,index2) in item.answer"
  81. :class="(userAnswer[index]+'').indexOf(index2+'') !== -1 && i2.correct
  82. ? 'activeAndTrue' : (userAnswer[index]+'').indexOf(index2+'') !== -1 ? 'active' :
  83. i2.correct ? 'true' : ''"
  84. >
  85. <span>{{ optionName[index] + '、' + i2.answer }}</span>
  86. <img
  87. v-for="i3 in i2.images"
  88. v-if="i2.images !== null"
  89. style="position: absolute;left:100%;top:50%;transform: translateY(-50%);
  90. width: 40px;height: 40px;float: right;cursor: pointer;"
  91. title="点击查看大图"
  92. :src="i3"
  93. alt=""
  94. @mouseover="showBigImg(i3)"
  95. >
  96. </label>
  97. </div>
  98. </div>
  99. <!-- 填空题和问答题的回答区 -->
  100. <div
  101. v-show="item.questionType === 5 || item.questionType === 6"
  102. style="margin-top: 25px"
  103. >
  104. <div class="ques-analysis">
  105. <h3 style="font-weight: 400">我的回答:</h3>
  106. <p style="font-weight: 400;color: orange"> {{ userAnswer[index] }} </p>
  107. </div>
  108. <div v-if="markExam">
  109. <span>评分:</span>
  110. <el-input-number
  111. v-model="item.score"
  112. :min="0"
  113. :max="parseInt(item.score)"
  114. />
  115. <el-input
  116. v-model="markForm.review"
  117. type="textarea"
  118. :rows="3"
  119. placeholder="请输入评语"
  120. />
  121. </div>
  122. </div>
  123. </div>
  124. </el-card>
  125. </el-main>
  126. <!--图片回显-->
  127. <el-dialog :visible.sync="bigImgDialog" @close="bigImgDialog = false">
  128. <img style="width: 100%" :src="bigImgUrl">
  129. </el-dialog>
  130. </el-container>
  131. </template>
  132. <script>
  133. import { getExamResult, getPaperQuestions } from '@/api/exam'
  134. export default {
  135. name: 'ExamResult',
  136. data() {
  137. return {
  138. // 考试记录信息
  139. examRecord: {},
  140. // 考试的信息
  141. examInfo: {},
  142. // 当前考试的题目
  143. questionInfo: [],
  144. // 页面加载
  145. loading: {},
  146. // 答案的选项名abcd数据
  147. optionName: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
  148. // 图片回显的url
  149. bigImgUrl: '',
  150. // 图片回显的对话框是否显示
  151. bigImgDialog: false,
  152. // 用户回答的答案
  153. userAnswer: [],
  154. markExam: true,
  155. markForm: {
  156. review: null
  157. }
  158. }
  159. },
  160. created() {
  161. document.title = '考试结果'
  162. this.getExamRecord()
  163. // 页面数据加载的等待状态栏
  164. this.loading = this.$loading({
  165. body: true,
  166. lock: true,
  167. text: '数据拼命加载中,(*╹▽╹*)',
  168. spinner: 'el-icon-loading'
  169. })
  170. },
  171. methods: {
  172. renderByMathjax() {
  173. // tinymce 的 mathjax 插件生成的 latex 格式公式放在 className 为 math-tex 的 span 标签内
  174. const className = 'math-tex'
  175. this.$nextTick(function() {
  176. if (this.MathJax.isMathjaxConfig) {
  177. this.MathJax.initMathjaxConfig()
  178. }
  179. this.MathJax.MathQueue1(className)
  180. })
  181. },
  182. // 查询用户当时考试的信息
  183. async getExamRecord() {
  184. const examId = this.$route.params.examId
  185. await getExamResult(examId).then((resp) => {
  186. if (resp.code === 0) {
  187. this.examRecord = resp.data
  188. // this.userAnswer = resp.data.userAnswers.split('-')
  189. this.userAnswer = resp.data.userAnswers.split(',')
  190. const paperId = resp.data.examId
  191. this.getPaperQuestions(paperId)
  192. // 数据加载完毕
  193. this.loading.close()
  194. this.renderByMathjax()
  195. }
  196. })
  197. },
  198. async getPaperQuestions(paperId) {
  199. await getPaperQuestions(paperId).then((resp) => {
  200. if (resp.code === 0) {
  201. this.questionInfo = resp.data || []
  202. // 重置问题的顺序 单选 多选 判断 简答
  203. this.questionInfo = this.questionInfo.sort(function(a, b) {
  204. return a.questionType - b.questionType
  205. })
  206. }
  207. })
  208. },
  209. // 点击展示高清大图
  210. showBigImg(url) {
  211. this.bigImgUrl = url
  212. this.bigImgDialog = true
  213. },
  214. // 根据考试id查询考试中每一题的分数
  215. async getQuestionScore(examId) {
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped lang="scss">
  221. * {
  222. font-weight: 800;
  223. }
  224. .el-container {
  225. width: 100%;
  226. height: 100%;
  227. }
  228. .el-container {
  229. animation: leftMoveIn .7s ease-in;
  230. }
  231. @keyframes leftMoveIn {
  232. 0% {
  233. transform: translateX(-100%);
  234. opacity: 0;
  235. }
  236. 100% {
  237. transform: translateX(0%);
  238. opacity: 1;
  239. }
  240. }
  241. .examName {
  242. color: #160f58;
  243. border-bottom: 4px solid #ffd550;
  244. font-size: 18px;
  245. font-weight: 700;
  246. padding-bottom: 10px
  247. }
  248. .examTime {
  249. font-size: 16px;
  250. color: #cbcacf;
  251. margin-left: 20px;
  252. font-weight: 700;
  253. }
  254. .el-radio-group label {
  255. display: block;
  256. width: 400px;
  257. padding: 48px 20px 10px 20px;
  258. border-radius: 4px;
  259. border: 1px solid #dcdfe6;
  260. margin-bottom: 10px;
  261. position: relative;
  262. span {
  263. position: absolute;
  264. top: 50%;
  265. transform: translateY(-50%);
  266. font-size: 16px;
  267. }
  268. }
  269. .num {
  270. display: inline-block;
  271. background: url('../../assets/img/examTitle.png') no-repeat 100% 100%;
  272. background-size: contain;
  273. height: 37px;
  274. width: 37px;
  275. line-height: 30px;
  276. color: #fff;
  277. font-size: 20px;
  278. text-align: center;
  279. margin-right: 15px;
  280. }
  281. /*选中的答案*/
  282. .active {
  283. border: 1px solid #ff1f39 !important;
  284. opacity: .5;
  285. }
  286. /* 选中的答案且是正确答案*/
  287. .activeAndTrue {
  288. border: 1px solid #1f90ff !important;
  289. opacity: .5;
  290. height: 15px;
  291. width: 15px;
  292. background-size: contain;
  293. background: url('../../assets/img/true.png') no-repeat 95%;
  294. position: absolute;
  295. top: 0;
  296. left: 0;
  297. }
  298. .true {
  299. height: 15px;
  300. width: 15px;
  301. background-size: contain;
  302. background: url('../../assets/img/true.png') no-repeat 95%;
  303. position: absolute;
  304. top: 0;
  305. left: 0;
  306. }
  307. .ques-analysis {
  308. padding: 30px 40px;
  309. background: #f6f6f8;
  310. margin-bottom: 70px;
  311. }
  312. </style>