ExamingEnd.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div v-if="!!!loading" id="exam-end" class="container">
  3. <div class="instructions">
  4. <h1 class="">考试已结束</h1>
  5. <div><img class="user-avatar" :src="user.photoPath" alt="无底照" /></div>
  6. <div v-if="showObjectScore">
  7. <div
  8. v-if="!examResult && getResultTimes <= 10"
  9. class="qm-big-text score-text"
  10. >
  11. 考试结果计算中...
  12. </div>
  13. <div
  14. v-if="!examResult && getResultTimes > 10"
  15. class="qm-big-text score-text"
  16. style="font-size: 20px;"
  17. >
  18. 请稍后在待考列表中查看客观题得分。
  19. </div>
  20. <div v-if="examResult">
  21. <div v-if="!examResult.isWarn" class="qm-big-text score-text">
  22. 客观题得分:
  23. <span style="color: red">{{ examResult.objectiveScore }}</span>
  24. </div>
  25. <div v-if="examResult.isWarn" class="qm-big-text score-text">
  26. 客观题得分: 成绩待审核
  27. </div>
  28. <h1
  29. v-if="showCheatingRemark && examResult.isWarn"
  30. style="text-align: left;"
  31. >
  32. 违纪提示:
  33. </h1>
  34. <div
  35. v-if="showCheatingRemark && examResult.isWarn"
  36. class=""
  37. style="text-align: left; padding-bottom: 20px"
  38. >
  39. <p v-html="cheatingRemark"></p>
  40. </div>
  41. </div>
  42. </div>
  43. <h1 style="text-align: left;">考后说明:</h1>
  44. <div style="text-align: left; padding-bottom: 20px">
  45. <p v-html="afterExamRemark"></p>
  46. </div>
  47. <router-link
  48. class="qm-primary-button"
  49. :to="backTo"
  50. style="display: inline-block; width: 100%;"
  51. ondragstart="return false;"
  52. >
  53. 返回主页
  54. </router-link>
  55. </div>
  56. </div>
  57. <div v-else>正在等待数据返回...</div>
  58. </template>
  59. <script>
  60. import { mapState as globalMapState } from "vuex";
  61. import { createNamespacedHelpers } from "vuex";
  62. const { mapMutations } = createNamespacedHelpers("examingHomeModule");
  63. export default {
  64. name: "ExamingEnd",
  65. data() {
  66. return {
  67. loading: true,
  68. exam: null,
  69. afterExamRemark: null,
  70. cheatingRemark: null,
  71. showObjectScore: null,
  72. showCheatingRemark: null,
  73. examResult: null,
  74. getResultTimes: 0,
  75. };
  76. },
  77. computed: {
  78. ...globalMapState(["user"]),
  79. // ...mapState(["exam"])
  80. backTo() {
  81. const examType = this.exam && this.exam.examType;
  82. if (examType === "PRACTICE") {
  83. return "/online-practice";
  84. } else if (examType === "ONLINE_HOMEWORK") {
  85. return "/online-homework";
  86. }
  87. return "/online-exam";
  88. },
  89. },
  90. created() {
  91. this.$Message.destroy(); // 避免极端情况下,心跳过期的错误消息
  92. },
  93. async mounted() {
  94. window._hmt.push(["_trackEvent", "考试结束页面", "进入页面"]);
  95. const examRecordDataId = this.$route.params.examRecordDataId;
  96. const examId = this.$route.params.examId;
  97. try {
  98. this.loading = true;
  99. this.exam = (await this.$http.get(
  100. "/api/ecs_exam_work/exam/" + examId
  101. )).data;
  102. if (this.exam.examType === "PRACTICE") {
  103. this.$router.replace(
  104. `/online-practice/exam/${examId}/detail?examRecordDataId=${examRecordDataId}&disableGoBack=true`
  105. );
  106. return;
  107. }
  108. const resp = await this.$http.get(
  109. "/api/ecs_exam_work/exam/getExamPropertyFromCacheByStudentSession/" +
  110. examId +
  111. `/AFTER_EXAM_REMARK,IS_OBJ_SCORE_VIEW,SHOW_CHEATING_REMARK,CHEATING_REMARK`
  112. );
  113. this.afterExamRemark = resp.data.AFTER_EXAM_REMARK || "";
  114. this.cheatingRemark = resp.data.CHEATING_REMARK || "";
  115. this.showObjectScore = resp.data.IS_OBJ_SCORE_VIEW === "true";
  116. this.showCheatingRemark = resp.data.SHOW_CHEATING_REMARK === "true";
  117. this.loading = false;
  118. } catch (error) {
  119. window._hmt.push([
  120. "_trackEvent",
  121. "考试结束页面",
  122. "获取考试设置错误,请在待考列表查看成绩!",
  123. ]);
  124. this.$Message.error({
  125. content: "获取考试设置错误,请在待考列表查看成绩!",
  126. duration: 15,
  127. closable: true,
  128. });
  129. this.$router.push("/");
  130. }
  131. document.body.style = "";
  132. await this.getExamResult();
  133. },
  134. beforeDestroy() {
  135. clearTimeout(this.timeout);
  136. this.updateExamState({
  137. exam: null,
  138. paperStruct: null,
  139. examQuestionList: null,
  140. questionAnswerFileUrl: [],
  141. pictureAnswer: {},
  142. snapNow: false,
  143. snapProcessingCount: 0,
  144. });
  145. // 清除考试过程中存储的音频
  146. caches.open("audios").then(function(cache) {
  147. cache &&
  148. cache.keys().then(function(keys) {
  149. keys.forEach(function(request) {
  150. cache.delete(request);
  151. });
  152. });
  153. });
  154. },
  155. methods: {
  156. ...mapMutations(["updateExamState"]),
  157. async getExamResult() {
  158. const examRecordDataId = this.$route.params.examRecordDataId;
  159. this.waitingNumber = 0;
  160. const f = async () => {
  161. if (this.$route.name !== "ExamingEnd" || this.waitingNumber > 30) {
  162. // 非成绩页,不在查询成绩
  163. return;
  164. }
  165. try {
  166. this.getResultTimes = this.getResultTimes + 1;
  167. const examResult = (await this.$http.get(
  168. "/api/ecs_oe_student/examControl/getEndExamInfo?examRecordDataId=" +
  169. examRecordDataId
  170. )).data;
  171. if (
  172. examResult === undefined ||
  173. examResult === null ||
  174. examResult === ""
  175. ) {
  176. this.waitingNumber++;
  177. this.timeout = setTimeout(() => f(), 3000);
  178. return;
  179. }
  180. window._hmt.push([
  181. "_trackEvent",
  182. "考试结束页面",
  183. "等待分数",
  184. "等待次数=" + this.waitingNumber,
  185. ]);
  186. this.examResult = examResult;
  187. } catch (error) {
  188. this.waitingNumber++;
  189. this.timeout = setTimeout(() => f(), 3000);
  190. }
  191. };
  192. await f();
  193. },
  194. },
  195. };
  196. </script>
  197. <style scoped>
  198. .container {
  199. margin: 0 auto;
  200. width: 80vw;
  201. overflow: auto;
  202. }
  203. .instructions {
  204. padding: 40px 20px;
  205. }
  206. .instructions > h1,
  207. .instructions > div {
  208. padding-bottom: 30px;
  209. }
  210. .user-avatar {
  211. display: inline-block;
  212. width: 140px;
  213. height: 140px;
  214. object-fit: contain;
  215. }
  216. .score-text {
  217. font-size: 40px;
  218. }
  219. </style>
  220. <style>
  221. #exam-end img {
  222. max-width: 100%;
  223. height: auto !important;
  224. }
  225. </style>