|
@@ -2,19 +2,21 @@
|
|
|
<div class="question-view">
|
|
|
<question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
|
|
|
<div class="ops">
|
|
|
- <div class="score">({{question.questionScore}}分)</div>
|
|
|
+ <div class="score">({{examQuestion.questionScore}}分)</div>
|
|
|
</div>
|
|
|
<div class="option">
|
|
|
- <textarea v-model="studentAnswer" class="stu-answer" type="text" />
|
|
|
+ <textarea v-model="studentAnswer" class="stu-answer" @blur="answerQuestion" type="text" />
|
|
|
</div>
|
|
|
<div class="reset">
|
|
|
- <i-button type="warning" size="large" @click="resetQuestion(examQuestion.id)">重置答案</i-button>
|
|
|
+ <i-button type="warning" size="large" @click="() => this.answerQuestion(null)">重置答案</i-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import QuestionBody from "./QuestionBody";
|
|
|
+import { createNamespacedHelpers } from "vuex";
|
|
|
+const { mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
|
|
|
export default {
|
|
|
name: "TextQuestionView",
|
|
@@ -28,18 +30,34 @@ export default {
|
|
|
examQuestion: Object
|
|
|
},
|
|
|
methods: {
|
|
|
- answerQuestion: function(examQuestionId) {
|
|
|
- this.$http.put("/api/exam_question/" + examQuestionId, {
|
|
|
- studentAnswer: this.studentAnswer
|
|
|
- });
|
|
|
- },
|
|
|
- resetQuestion: function(examQuestionId) {
|
|
|
- this.studentAnswer = null;
|
|
|
- this.$http.put("/api/exam_question/" + examQuestionId, {
|
|
|
- studentAnswer: null
|
|
|
+ ...mapMutations(["updateExamQuestion"]),
|
|
|
+ async answerQuestion(reset) {
|
|
|
+ console.log(this.studentAnswer);
|
|
|
+ if (reset === null) {
|
|
|
+ this.studentAnswer = null;
|
|
|
+ }
|
|
|
+ const order = this.examQuestion.order;
|
|
|
+ const studentAnswer = this.studentAnswer;
|
|
|
+ await this.$http.post(
|
|
|
+ "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
|
|
|
+ [
|
|
|
+ {
|
|
|
+ order: order,
|
|
|
+ studentAnswer: studentAnswer
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ this.updateExamQuestion({
|
|
|
+ order: order,
|
|
|
+ studentAnswer: studentAnswer
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ examQuestion(cur, prev) {
|
|
|
+ this.studentAnswer = this.examQuestion.studentAnswer;
|
|
|
+ }
|
|
|
+ },
|
|
|
components: {
|
|
|
QuestionBody
|
|
|
}
|