|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="container">
|
|
|
+ <div v-if="exam" class="container">
|
|
|
<div class="header">
|
|
|
<RemainTime></RemainTime>
|
|
|
<OverallProgress :exam-question-list="validQuestions"></OverallProgress>
|
|
@@ -29,75 +29,58 @@ import QuestionView from "./QuestionView.vue";
|
|
|
import ArrowNavView from "./ArrowNavView.vue";
|
|
|
import QuestionNavView from "./QuestionNavView.vue";
|
|
|
import FaceRecognition from "../../../components/FaceRecognition/FaceRecognition";
|
|
|
+import { createNamespacedHelpers } from "vuex";
|
|
|
+const { mapState, mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
|
|
|
export default {
|
|
|
name: "ExamingHome",
|
|
|
data() {
|
|
|
return {
|
|
|
- exam: null,
|
|
|
- paperStruct: null,
|
|
|
- validQuestions: [],
|
|
|
- examQuestionList: [],
|
|
|
preExamQuestion: null,
|
|
|
nextExamQuestion: null,
|
|
|
examQuestion: null
|
|
|
};
|
|
|
},
|
|
|
- async mounted() {
|
|
|
+ async created() {
|
|
|
+ await this.initData();
|
|
|
if (!this.$route.query.examQuestionId) {
|
|
|
- const exam = await this.$http.get(
|
|
|
- "/api/ecs_exam_work/exam/" + this.$route.params.examId
|
|
|
- );
|
|
|
- this.exam = exam.data;
|
|
|
-
|
|
|
- const paperStruct = await this.$http.get(
|
|
|
- "/api/exam_question/paper_struct/?exam_record_id=" +
|
|
|
- this.$route.query.examRecordId
|
|
|
- );
|
|
|
- this.paperStruct = paperStruct.data;
|
|
|
-
|
|
|
- // FIXME: global API processing. mock or not
|
|
|
- const examQuestionList = await this.$http.get(
|
|
|
- "/api/exam_question/?exam_record_id=" + this.$route.query.examRecordId
|
|
|
- );
|
|
|
- this.examQuestionList = examQuestionList.data;
|
|
|
- this.validQuestions = this.examQuestionList.filter(
|
|
|
- q => q.nestedQuestion === false
|
|
|
- );
|
|
|
this.$router.push(
|
|
|
this.$route.fullPath + "&examQuestionId=" + this.examQuestionList[0].id
|
|
|
);
|
|
|
return;
|
|
|
}
|
|
|
- this.init();
|
|
|
+ this.updateQuestion();
|
|
|
},
|
|
|
beforeRouteUpdate(to, from, next) {
|
|
|
- this.init(next);
|
|
|
+ this.updateQuestion(next);
|
|
|
},
|
|
|
methods: {
|
|
|
- init: async function(next) {
|
|
|
+ ...mapMutations(["updateExamState"]),
|
|
|
+ async initData() {
|
|
|
const exam = await this.$http.get(
|
|
|
"/api/ecs_exam_work/exam/" + this.$route.params.examId
|
|
|
);
|
|
|
- this.exam = exam.data;
|
|
|
|
|
|
- if (!this.paperStruct || this.paperStruct.length == 0) {
|
|
|
- const paperStruct = await this.$http.get(
|
|
|
- "/api/exam_question/paper_struct/?exam_record_id=" +
|
|
|
- this.$route.query.examRecordId
|
|
|
- );
|
|
|
- this.paperStruct = paperStruct.data;
|
|
|
- }
|
|
|
+ const paperStruct = await this.$http.get(
|
|
|
+ "/api/exam_question/paper_struct/?exam_record_id=" +
|
|
|
+ this.$route.query.examRecordId
|
|
|
+ );
|
|
|
|
|
|
- // FIXME: global API processing. mock or not
|
|
|
const examQuestionList = await this.$http.get(
|
|
|
"/api/exam_question/?exam_record_id=" + this.$route.query.examRecordId
|
|
|
);
|
|
|
- this.examQuestionList = examQuestionList.data;
|
|
|
- this.validQuestions = this.examQuestionList.filter(
|
|
|
+ const validQuestions = examQuestionList.data.filter(
|
|
|
q => q.nestedQuestion === false
|
|
|
);
|
|
|
|
|
|
+ this.updateExamState({
|
|
|
+ exam: exam.data,
|
|
|
+ paperStruct: paperStruct.data,
|
|
|
+ examQuestionList: examQuestionList.data,
|
|
|
+ validQuestions
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updateQuestion: async function(next) {
|
|
|
// 初始化套题的答案,为回填部分选项做准备
|
|
|
// for (let q of this.examQuestionList) {
|
|
|
// if (q.subQuestionList.length > 0) {
|
|
@@ -109,6 +92,7 @@ export default {
|
|
|
// }
|
|
|
|
|
|
next && next();
|
|
|
+ if (!this.exam) return;
|
|
|
this.examQuestion = this.examQuestionList.find(
|
|
|
eq => eq.id == this.$route.query.examQuestionId // number == string
|
|
|
);
|
|
@@ -121,6 +105,9 @@ export default {
|
|
|
this.$router.push("/");
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapState(["exam", "paperStruct", "examQuestionList", "validQuestions"])
|
|
|
+ },
|
|
|
components: {
|
|
|
RemainTime,
|
|
|
OverallProgress,
|
|
@@ -135,8 +122,6 @@ export default {
|
|
|
|
|
|
<style scoped>
|
|
|
.container {
|
|
|
- /* display: flex;
|
|
|
- flex-direction: row; */
|
|
|
display: grid;
|
|
|
grid-template-areas:
|
|
|
"header header"
|
|
@@ -149,33 +134,24 @@ export default {
|
|
|
}
|
|
|
|
|
|
.header {
|
|
|
- /* display: flex;
|
|
|
- flex-direction: row; */
|
|
|
display: grid;
|
|
|
place-items: center;
|
|
|
grid-template-columns: 200px 1fr 300px 100px;
|
|
|
-
|
|
|
grid-area: header;
|
|
|
-
|
|
|
height: 80px;
|
|
|
background-color: #f5f5f5;
|
|
|
}
|
|
|
|
|
|
.main {
|
|
|
display: grid;
|
|
|
-
|
|
|
grid-area: main;
|
|
|
-
|
|
|
grid-template-rows: 1fr 50px;
|
|
|
}
|
|
|
|
|
|
.side {
|
|
|
display: grid;
|
|
|
-
|
|
|
grid-area: side;
|
|
|
-
|
|
|
grid-template-rows: 1fr 300px;
|
|
|
-
|
|
|
background-color: #f5f5f5;
|
|
|
}
|
|
|
|