|
@@ -2,7 +2,7 @@
|
|
|
<div class="question-view">
|
|
|
<div class="question-body" v-html="question.body"></div>
|
|
|
<div class="ops">
|
|
|
- <div class="stu-answer"> {{stuAnswer}}</div>
|
|
|
+ <div class="stu-answer">{{stuAnswer}}</div>
|
|
|
<div class="score">({{question.questionScore}}分)</div>
|
|
|
</div>
|
|
|
<div v-for="(option, index) in question.options" :key="option.id" class="option" @click="answerQuestion(examQuestion.id, optionName[index])">
|
|
@@ -30,7 +30,33 @@ export default {
|
|
|
question: Object,
|
|
|
examQuestion: Object
|
|
|
},
|
|
|
+ created: function() {
|
|
|
+ window.addEventListener("keyup", this.keyup);
|
|
|
+ },
|
|
|
+ destroyed() {
|
|
|
+ window.removeEventListener("keyup", this.keyup);
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ keyup(e) {
|
|
|
+ // console.log(e);
|
|
|
+ // console.log(document.activeElement.type);
|
|
|
+ if (
|
|
|
+ ["BODY", "A", "BUTTON", "DIV"].includes(
|
|
|
+ document.activeElement.tagName
|
|
|
+ ) ||
|
|
|
+ (["INPUT"].includes(document.activeElement.tagName) &&
|
|
|
+ ["checkbox", "radio"].includes(document.activeElement.type))
|
|
|
+ ) {
|
|
|
+ if (
|
|
|
+ ["KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG"]
|
|
|
+ .slice(0, this.question.options.length)
|
|
|
+ .includes(e.code)
|
|
|
+ ) {
|
|
|
+ this.stuAnswer = e.code[3];
|
|
|
+ this.answerQuestion(this.examQuestion.id, this.stuAnswer);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
answerQuestion: function(examQuestionId, stuAnswer) {
|
|
|
this.stuAnswer = stuAnswer;
|
|
|
this.$http.put("/api/exam_question/" + examQuestionId, { stuAnswer });
|
|
@@ -70,6 +96,7 @@ export default {
|
|
|
width: 100px;
|
|
|
border-bottom: 1px solid black;
|
|
|
text-align: center;
|
|
|
+ height: 20px;
|
|
|
}
|
|
|
|
|
|
.option {
|