ExamingHome.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <div v-if="exam && examQuestion()" class="container">
  3. <div class="header">
  4. <RemainTime></RemainTime>
  5. <OverallProgress :exam-question-list="validQuestions"></OverallProgress>
  6. <QuestionFilters :exam-question-list="validQuestions"></QuestionFilters>
  7. <Button class="qm-primary-button" @click="submitPaper">交卷</Button>
  8. </div>
  9. <div class="main">
  10. <QuestionView :exam-question="examQuestion()"></QuestionView>
  11. <ArrowNavView :previous-exam-question="preExamQuestion" :next-exam-question="nextExamQuestion"></ArrowNavView>
  12. </div>
  13. <div class="side">
  14. <div class="question-nav">
  15. <QuestionNavView :paperStruct="paperStruct" :validQuestions="validQuestions" />
  16. </div>
  17. <div class="camera">
  18. <!-- <FaceRecognition width="100%" height="100%" :showRecognizeButton="false" /> -->
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import RemainTime from "./RemainTime.vue";
  25. import OverallProgress from "./OverallProgress.vue";
  26. import QuestionFilters from "./QuestionFilters.vue";
  27. import QuestionView from "./QuestionView.vue";
  28. import ArrowNavView from "./ArrowNavView.vue";
  29. import QuestionNavView from "./QuestionNavView.vue";
  30. import FaceRecognition from "../../../components/FaceRecognition/FaceRecognition";
  31. import { createNamespacedHelpers } from "vuex";
  32. const { mapState, mapMutations, mapGetters } = createNamespacedHelpers(
  33. "examingHomeModule"
  34. );
  35. export default {
  36. name: "ExamingHome",
  37. created() {
  38. this.initData();
  39. if (!this.$route.query.order) {
  40. // created can access this.$route?
  41. this.$router.push(this.$route.fullPath + "&order=" + 4);
  42. return;
  43. }
  44. },
  45. // beforeRouteUpdate(to, from, next) {
  46. // this.updateQuestion(next);
  47. // },
  48. methods: {
  49. ...mapMutations(["updateExamState"]),
  50. async initData() {
  51. const exam = await this.$http.get(
  52. "/api/ecs_exam_work/exam/" + this.$route.params.examId
  53. );
  54. const paperStruct = await this.$http.get(
  55. "/api/ecs_oe_student/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=" +
  56. this.$route.query.examRecordId
  57. );
  58. const examQuestionList = await this.$http.get(
  59. "/api/ecs_oe_student/examQuestion/findExamQuestionList?examRecordDataId=" +
  60. this.$route.query.examRecordId
  61. );
  62. this.updateExamState({
  63. exam: exam.data,
  64. paperStruct: paperStruct.data,
  65. examQuestionList: examQuestionList.data
  66. });
  67. },
  68. updateQuestion: async function(next) {
  69. // 初始化套题的答案,为回填部分选项做准备
  70. // for (let q of this.examQuestionList) {
  71. // if (q.subQuestionList.length > 0) {
  72. // q.stuAnswer = [];
  73. // for (let sq of q.subQuestionList) {
  74. // q.stuAnswer.push(sq.stuAnswer);
  75. // }
  76. // }
  77. // }
  78. next && next();
  79. if (!this.exam) return;
  80. // this.examQuestion = this.examQuestionList.find(
  81. // eq => eq.id == this.$route.query.examQuestionId // number == string
  82. // );
  83. // this.preExamQuestion = this.validQuestions[this.examQuestion.orders - 2];
  84. // this.nextExamQuestion = this.validQuestions[this.examQuestion.orders];
  85. },
  86. async submitPaper() {
  87. //FIXME: submit precondition
  88. await this.$http.get("/api/exam_control/submit");
  89. this.$router.push("/");
  90. },
  91. examQuestion() {
  92. return (
  93. this.examQuestionList &&
  94. this.examQuestionList.find(
  95. eq => eq.order == this.$route.query.order // number == string
  96. )
  97. );
  98. }
  99. },
  100. computed: {
  101. ...mapState(["exam", "paperStruct", "examQuestionList"]),
  102. ...mapGetters(["validQuestions"]),
  103. preExamQuestion: vm =>
  104. vm.examQuestion && vm.validQuestions[vm.examQuestion.orders - 2],
  105. nextExamQuestion: vm =>
  106. vm.examQuestion && vm.validQuestions[vm.examQuestion.orders]
  107. },
  108. watch: {
  109. $route: function() {
  110. this.examQuestion();
  111. }
  112. },
  113. components: {
  114. RemainTime,
  115. OverallProgress,
  116. QuestionFilters,
  117. QuestionView,
  118. ArrowNavView,
  119. QuestionNavView,
  120. FaceRecognition
  121. }
  122. };
  123. </script>
  124. <style scoped>
  125. .container {
  126. display: grid;
  127. grid-template-areas:
  128. "header header"
  129. "main side";
  130. grid-template-rows: 80px 1fr;
  131. grid-template-columns: 1fr 400px;
  132. height: 100vh;
  133. width: 100vw;
  134. }
  135. .header {
  136. display: grid;
  137. place-items: center;
  138. grid-template-columns: 200px 1fr 300px 100px;
  139. grid-area: header;
  140. height: 80px;
  141. background-color: #f5f5f5;
  142. }
  143. .main {
  144. display: grid;
  145. grid-area: main;
  146. grid-template-rows: 1fr 50px;
  147. }
  148. .side {
  149. display: grid;
  150. grid-area: side;
  151. grid-template-rows: 1fr 300px;
  152. background-color: #f5f5f5;
  153. }
  154. .camera {
  155. align-self: flex-end;
  156. justify-self: flex-end;
  157. }
  158. @media screen and (max-height: 768px) {
  159. .container {
  160. grid-template-rows: 50px 1fr;
  161. }
  162. .header {
  163. height: 50px;
  164. }
  165. .side {
  166. grid-template-rows: 1fr 200px;
  167. }
  168. }
  169. </style>