|
@@ -6,10 +6,10 @@
|
|
|
</div>
|
|
|
<div v-for="(option, index) in studentAnswer.split('##')" :key="examQuestion.id + index" class="option">
|
|
|
<span class="question-options">{{index+1}}. </span>
|
|
|
- <input type="text" name="question" class="input-answer" :value="option" @input="inputAnswer" @blur="submitAnswer" />
|
|
|
+ <input type="text" name="question" class="input-answer" :value="option" @input="inputAnswer" />
|
|
|
</div>
|
|
|
<div class="reset">
|
|
|
- <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
|
|
|
+ <i-button type="warning" size="large" @click="resetAnswer">重置答案</i-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -41,15 +41,12 @@ export default {
|
|
|
examQuestion: Object
|
|
|
},
|
|
|
created() {
|
|
|
+ console.log("created");
|
|
|
this.prepareData();
|
|
|
},
|
|
|
- // beforeUpdate() {
|
|
|
- // this.prepareData();
|
|
|
- // const realAnswer = this.studentAnswer.replace(/##/g, "").trim() || null;
|
|
|
- // if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
|
- // this.answerQuestion(this.examQuestion.id, realAnswer);
|
|
|
- // }
|
|
|
- // },
|
|
|
+ beforeDestroy() {
|
|
|
+ console.log("before destory");
|
|
|
+ },
|
|
|
methods: {
|
|
|
...mapMutations(["updateExamQuestion"]),
|
|
|
prepareData() {
|
|
@@ -67,21 +64,6 @@ export default {
|
|
|
"</span>"
|
|
|
);
|
|
|
},
|
|
|
- async answerQuestion(studentAnswer) {
|
|
|
- await this.$http.post(
|
|
|
- "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
|
|
|
- [
|
|
|
- {
|
|
|
- order: this.examQuestion.order,
|
|
|
- studentAnswer: studentAnswer
|
|
|
- }
|
|
|
- ]
|
|
|
- );
|
|
|
- this.updateExamQuestion({
|
|
|
- order: this.$route.params.order,
|
|
|
- studentAnswer
|
|
|
- });
|
|
|
- },
|
|
|
inputAnswer: function() {
|
|
|
const questionNumber = this.question.body.split(/_{5,}/).length - 1;
|
|
|
let ans = "";
|
|
@@ -98,25 +80,36 @@ export default {
|
|
|
"</span>"
|
|
|
);
|
|
|
},
|
|
|
- submitAnswer() {
|
|
|
+ resetAnswer() {
|
|
|
+ this.updateExamQuestion({
|
|
|
+ order: this.examQuestion.order,
|
|
|
+ studentAnswer: null
|
|
|
+ });
|
|
|
+ this.examQuestion.studentAnswer = null;
|
|
|
+ this.prepareData();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // examQuestion: function() {
|
|
|
+ // this.prepareData();
|
|
|
+ // },
|
|
|
+ // question(question) {
|
|
|
+ // this.questionBody = question.body;
|
|
|
+ // },
|
|
|
+ studentAnswer() {
|
|
|
let realAnswer = null;
|
|
|
- if (this.studentAnswer.replace(/##/g, "").trim()) {
|
|
|
+ if (this.studentAnswer && this.studentAnswer.replace(/##/g, "").trim()) {
|
|
|
// 如果有实际内容
|
|
|
realAnswer = this.studentAnswer;
|
|
|
}
|
|
|
if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
|
- this.answerQuestion(realAnswer);
|
|
|
+ this.updateExamQuestion({
|
|
|
+ order: this.examQuestion.order,
|
|
|
+ studentAnswer: realAnswer
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- watch: {
|
|
|
- examQuestion: function() {
|
|
|
- this.prepareData();
|
|
|
- },
|
|
|
- question(question) {
|
|
|
- this.questionBody = question.body;
|
|
|
- }
|
|
|
- },
|
|
|
components: {
|
|
|
QuestionBody
|
|
|
}
|