|
@@ -4,14 +4,14 @@
|
|
<div class="ops">
|
|
<div class="ops">
|
|
<div class="score">({{question.questionScore}}分)</div>
|
|
<div class="score">({{question.questionScore}}分)</div>
|
|
</div>
|
|
</div>
|
|
- <div v-for="(option, index) in stuAnswer.split('##')" :key="examQuestion.id + index" class="option">
|
|
|
|
|
|
+ <div v-for="(option, index) in studentAnswer.split('##')" :key="examQuestion.id + index" class="option">
|
|
<span class="question-options">{{index+1}}. </span>
|
|
<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" @blur="submitAnswer" />
|
|
</div>
|
|
</div>
|
|
- <div class="reset">
|
|
|
|
- <i-button type="warning" size="large" @click="() => answerQuestion(examQuestion.id, null)">重置答案</i-button>
|
|
|
|
|
|
+ <div class="reset">
|
|
|
|
+ <i-button type="warning" size="large" @click="() => answerQuestion(examQuestion.id, null)">重置答案</i-button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
- </div>
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
@@ -20,10 +20,10 @@ import { createNamespacedHelpers } from "vuex";
|
|
const { mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
const { mapMutations } = createNamespacedHelpers("examingHomeModule");
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 1. 进入页面,this.stuAnswer从examQuestion.stuAnswer获得数据
|
|
|
|
- * 2. 输入答案,this.stuAnswer更新,同时questionbody更新,但不提交答案
|
|
|
|
|
|
+ * 1. 进入页面,this.studentAnswer从examQuestion.studentAnswer获得数据
|
|
|
|
+ * 2. 输入答案,this.studentAnswer更新,同时questionbody更新,但不提交答案
|
|
* 3. 输入框失去焦点,提交答案
|
|
* 3. 输入框失去焦点,提交答案
|
|
- * 4. 切换页面,this.stuAnswer从examQuestion获得数据
|
|
|
|
|
|
+ * 4. 切换页面,this.studentAnswer从examQuestion获得数据
|
|
*
|
|
*
|
|
* FIXME: question没有更新。。。。
|
|
* FIXME: question没有更新。。。。
|
|
* */
|
|
* */
|
|
@@ -32,7 +32,7 @@ export default {
|
|
name: "FillBlankQuestionView",
|
|
name: "FillBlankQuestionView",
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- stuAnswer: "",
|
|
|
|
|
|
+ studentAnswer: "",
|
|
questionBody: ""
|
|
questionBody: ""
|
|
};
|
|
};
|
|
},
|
|
},
|
|
@@ -45,20 +45,20 @@ export default {
|
|
},
|
|
},
|
|
// beforeUpdate() {
|
|
// beforeUpdate() {
|
|
// this.prepareData();
|
|
// this.prepareData();
|
|
- // const realAnswer = this.stuAnswer.replace(/##/g, "").trim() || null;
|
|
|
|
- // if (realAnswer !== this.examQuestion.stuAnswer) {
|
|
|
|
|
|
+ // const realAnswer = this.studentAnswer.replace(/##/g, "").trim() || null;
|
|
|
|
+ // if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
// this.answerQuestion(this.examQuestion.id, realAnswer);
|
|
// this.answerQuestion(this.examQuestion.id, realAnswer);
|
|
// }
|
|
// }
|
|
// },
|
|
// },
|
|
methods: {
|
|
methods: {
|
|
- ...mapMutations(["updateExamQuestionAnswer"]),
|
|
|
|
|
|
+ ...mapMutations(["updateExamQuestion"]),
|
|
prepareData() {
|
|
prepareData() {
|
|
const questionNumber = this.question.body.split(/_{5,}/).length - 1;
|
|
const questionNumber = this.question.body.split(/_{5,}/).length - 1;
|
|
|
|
|
|
- this.stuAnswer =
|
|
|
|
- this.examQuestion.stuAnswer || "##".repeat(questionNumber - 1);
|
|
|
|
|
|
+ this.studentAnswer =
|
|
|
|
+ this.examQuestion.studentAnswer || "##".repeat(questionNumber - 1);
|
|
|
|
|
|
- const answers = this.stuAnswer.split("##");
|
|
|
|
|
|
+ const answers = this.studentAnswer.split("##");
|
|
this.questionBody = this.question.body.replace(
|
|
this.questionBody = this.question.body.replace(
|
|
/_{5,}/g,
|
|
/_{5,}/g,
|
|
() =>
|
|
() =>
|
|
@@ -67,11 +67,11 @@ export default {
|
|
"</span>"
|
|
"</span>"
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- async answerQuestion(examQuestionId, stuAnswer) {
|
|
|
|
|
|
+ async answerQuestion(examQuestionId, studentAnswer) {
|
|
await this.$http.put("/api/exam_question/" + examQuestionId, {
|
|
await this.$http.put("/api/exam_question/" + examQuestionId, {
|
|
- stuAnswer
|
|
|
|
|
|
+ studentAnswer
|
|
});
|
|
});
|
|
- this.updateExamQuestionAnswer({ examQuestionId, stuAnswer });
|
|
|
|
|
|
+ this.updateExamQuestion({ examQuestionId, studentAnswer });
|
|
},
|
|
},
|
|
inputAnswer: function() {
|
|
inputAnswer: function() {
|
|
const questionNumber = this.question.body.split(/_{5,}/).length - 1;
|
|
const questionNumber = this.question.body.split(/_{5,}/).length - 1;
|
|
@@ -79,8 +79,8 @@ export default {
|
|
document
|
|
document
|
|
.querySelectorAll(".option input")
|
|
.querySelectorAll(".option input")
|
|
.forEach(e => (ans += e.value + "##"));
|
|
.forEach(e => (ans += e.value + "##"));
|
|
- this.stuAnswer = ans.slice(0, -2);
|
|
|
|
- const answers = this.stuAnswer.split("##");
|
|
|
|
|
|
+ this.studentAnswer = ans.slice(0, -2);
|
|
|
|
+ const answers = this.studentAnswer.split("##");
|
|
this.questionBody = this.question.body.replace(
|
|
this.questionBody = this.question.body.replace(
|
|
/_{5,}/g,
|
|
/_{5,}/g,
|
|
() =>
|
|
() =>
|
|
@@ -90,8 +90,8 @@ export default {
|
|
);
|
|
);
|
|
},
|
|
},
|
|
submitAnswer() {
|
|
submitAnswer() {
|
|
- const realAnswer = this.stuAnswer.replace(/##/g, "").trim() || null;
|
|
|
|
- if (realAnswer !== this.examQuestion.stuAnswer) {
|
|
|
|
|
|
+ const realAnswer = this.studentAnswer.replace(/##/g, "").trim() || null;
|
|
|
|
+ if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
this.answerQuestion(this.examQuestion.id, realAnswer);
|
|
this.answerQuestion(this.examQuestion.id, realAnswer);
|
|
}
|
|
}
|
|
}
|
|
}
|