|
@@ -2,16 +2,16 @@
|
|
<div class="question-view">
|
|
<div class="question-view">
|
|
<question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
|
|
<question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
|
|
<div class="ops">
|
|
<div class="ops">
|
|
- <div class="stu-answer"> {{studentAnswer}}</div>
|
|
|
|
|
|
+ <div class="stu-answer"> {{oldIndexToABCD}}</div>
|
|
<div class="score">({{examQuestion.questionScore}}分)</div>
|
|
<div class="score">({{examQuestion.questionScore}}分)</div>
|
|
</div>
|
|
</div>
|
|
- <div v-for="(option, index) in question.questionOptionList" :key="option.id" class="option" @click="toggleAnswer(index)">
|
|
|
|
- <input type="checkbox" name="question" value="optionName[index]" :checked="studentAnswer && studentAnswer.includes(optionName[index])" />
|
|
|
|
|
|
+ <div v-for="(option, index) in newQuestionOptions" :key="index" class="option" @click="toggleAnswer(option.oldIndex)">
|
|
|
|
+ <input type="checkbox" name="question" value="option.oldIndex" :checked="studentAnswer && studentAnswer.includes(option.oldIndex)" />
|
|
<span style="padding: 0 10px;">{{optionName[index]}}: </span>
|
|
<span style="padding: 0 10px;">{{optionName[index]}}: </span>
|
|
- <span class="question-options" v-html="option.body"></span>
|
|
|
|
|
|
+ <span class="question-options" v-html="option.value.body"></span>
|
|
</div>
|
|
</div>
|
|
<div class="reset">
|
|
<div class="reset">
|
|
- <i-button type="warning" size="large" @click="() => answerQuestion(examQuestion.id, null)">重置答案</i-button>
|
|
|
|
|
|
+ <i-button type="warning" size="large" @click="() => answerQuestion(null)">重置答案</i-button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
@@ -26,6 +26,7 @@ export default {
|
|
name: "MultipleQuestionView",
|
|
name: "MultipleQuestionView",
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ questionBody: this.question.body,
|
|
optionName,
|
|
optionName,
|
|
studentAnswer: this.examQuestion.studentAnswer || ""
|
|
studentAnswer: this.examQuestion.studentAnswer || ""
|
|
};
|
|
};
|
|
@@ -41,13 +42,11 @@ export default {
|
|
window.removeEventListener("keyup", this.keyup);
|
|
window.removeEventListener("keyup", this.keyup);
|
|
},
|
|
},
|
|
beforeUpdate() {
|
|
beforeUpdate() {
|
|
- this.answerQuestion(this.examQuestion.id, this.studentAnswer);
|
|
|
|
|
|
+ this.answerQuestion(this.studentAnswer);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
...mapMutations(["updateExamQuestion"]),
|
|
...mapMutations(["updateExamQuestion"]),
|
|
keyup(e) {
|
|
keyup(e) {
|
|
- // console.log(e);
|
|
|
|
- // console.log(document.activeElement.type);
|
|
|
|
if (
|
|
if (
|
|
["BODY", "A", "BUTTON", "DIV"].includes(
|
|
["BODY", "A", "BUTTON", "DIV"].includes(
|
|
document.activeElement.tagName
|
|
document.activeElement.tagName
|
|
@@ -60,11 +59,17 @@ export default {
|
|
.slice(0, this.question.questionOptionList.length)
|
|
.slice(0, this.question.questionOptionList.length)
|
|
.includes(e.code)
|
|
.includes(e.code)
|
|
) {
|
|
) {
|
|
- if (this.studentAnswer.includes(e.code[3])) {
|
|
|
|
- this.studentAnswer = this.studentAnswer.replace(e.code[3], "");
|
|
|
|
|
|
+ const selectedOldIndex =
|
|
|
|
+ "" +
|
|
|
|
+ this.newQuestionOptions.find(v => v.name == e.code[3]).oldIndex;
|
|
|
|
+ if (this.studentAnswer.includes(selectedOldIndex)) {
|
|
|
|
+ this.studentAnswer = this.studentAnswer.replace(
|
|
|
|
+ selectedOldIndex,
|
|
|
|
+ ""
|
|
|
|
+ );
|
|
} else {
|
|
} else {
|
|
this.studentAnswer = this.studentAnswer
|
|
this.studentAnswer = this.studentAnswer
|
|
- .concat(e.code[3])
|
|
|
|
|
|
+ .concat(selectedOldIndex)
|
|
.split("")
|
|
.split("")
|
|
.sort()
|
|
.sort()
|
|
.join("");
|
|
.join("");
|
|
@@ -72,33 +77,23 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- toggleAnswer: function(index) {
|
|
|
|
- if (this.studentAnswer.includes(optionName[index])) {
|
|
|
|
- this.studentAnswer = this.studentAnswer.replace(optionName[index], "");
|
|
|
|
|
|
+ toggleAnswer: function(selectedOldIndex) {
|
|
|
|
+ if (this.studentAnswer.includes(selectedOldIndex)) {
|
|
|
|
+ this.studentAnswer = this.studentAnswer.replace(selectedOldIndex, "");
|
|
} else {
|
|
} else {
|
|
this.studentAnswer = this.studentAnswer
|
|
this.studentAnswer = this.studentAnswer
|
|
- .concat(optionName[index])
|
|
|
|
|
|
+ .concat(selectedOldIndex)
|
|
.split("")
|
|
.split("")
|
|
.sort()
|
|
.sort()
|
|
.join("");
|
|
.join("");
|
|
}
|
|
}
|
|
- // this.answerQuestion(this.examQuestion.id, this.studentAnswer);
|
|
|
|
},
|
|
},
|
|
- async answerQuestion(examQuestionId, studentAnswer) {
|
|
|
|
|
|
+ async answerQuestion(studentAnswer) {
|
|
let realAnswer = studentAnswer;
|
|
let realAnswer = studentAnswer;
|
|
if (studentAnswer === "") {
|
|
if (studentAnswer === "") {
|
|
realAnswer = null;
|
|
realAnswer = null;
|
|
}
|
|
}
|
|
if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
if (realAnswer !== this.examQuestion.studentAnswer) {
|
|
- // await this.$http.post(
|
|
|
|
- // "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
|
|
|
|
- // [
|
|
|
|
- // {
|
|
|
|
- // order: this.examQuestion.order,
|
|
|
|
- // studentAnswer: realAnswer
|
|
|
|
- // }
|
|
|
|
- // ]
|
|
|
|
- // );
|
|
|
|
this.updateExamQuestion({
|
|
this.updateExamQuestion({
|
|
order: this.$route.params.order,
|
|
order: this.$route.params.order,
|
|
studentAnswer: realAnswer
|
|
studentAnswer: realAnswer
|
|
@@ -111,6 +106,28 @@ export default {
|
|
this.studentAnswer = this.examQuestion.studentAnswer || "";
|
|
this.studentAnswer = this.examQuestion.studentAnswer || "";
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ newQuestionOptions() {
|
|
|
|
+ return this.question.questionOptionList.map((v, i) => {
|
|
|
|
+ return {
|
|
|
|
+ value: this.question.questionOptionList[
|
|
|
|
+ this.examQuestion.optionPermutation[i]
|
|
|
|
+ ],
|
|
|
|
+ oldIndex: "" + this.examQuestion.optionPermutation[i],
|
|
|
|
+ name: optionName[i]
|
|
|
|
+ };
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ oldIndexToABCD() {
|
|
|
|
+ return (
|
|
|
|
+ this.examQuestion.studentAnswer &&
|
|
|
|
+ this.newQuestionOptions
|
|
|
|
+ .filter(v => this.examQuestion.studentAnswer.includes(v.oldIndex))
|
|
|
|
+ .map(v => v.name)
|
|
|
|
+ .join("")
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ },
|
|
components: {
|
|
components: {
|
|
QuestionBody
|
|
QuestionBody
|
|
}
|
|
}
|