|
@@ -0,0 +1,71 @@
|
|
|
+<template>
|
|
|
+ <div class="question-view">
|
|
|
+ <div class="question-body" v-html="question.body"></div>
|
|
|
+ <div class="ops">
|
|
|
+ <div class="stu-answer"> {{stuAnswer}}</div>
|
|
|
+ <i-button @click="resetQuestion(examQuestion.id)">重置</i-button>
|
|
|
+ <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])">
|
|
|
+ <input type="radio" name="question" value="optionName[index]" :checked="stuAnswer === optionName[index]" />
|
|
|
+ <span>{{optionName[index]}}: </span>
|
|
|
+ <span class="question-options" v-html="option.content"></span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+const optionName = ["A", "B", "C", "D", "E", "F"];
|
|
|
+export default {
|
|
|
+ name: "SingleQuestionView",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ // question: null
|
|
|
+ optionName,
|
|
|
+ stuAnswer: this.examQuestion.stuAnswer
|
|
|
+ };
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ question: Object,
|
|
|
+ examQuestion: Object
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ answerQuestion: function(examQuestionId, stuAnswer) {
|
|
|
+ this.stuAnswer = stuAnswer;
|
|
|
+ this.$http.put("/api/exam_question/" + examQuestionId, { stuAnswer });
|
|
|
+ },
|
|
|
+ resetQuestion: function(examQuestionId) {
|
|
|
+ this.stuAnswer = null;
|
|
|
+ this.$http.put("/api/exam_question/" + examQuestionId, {
|
|
|
+ stuAnswer: null
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {}
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.question-view {
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+
|
|
|
+.ops {
|
|
|
+ display: flex;
|
|
|
+ align-items: flex-end;
|
|
|
+}
|
|
|
+
|
|
|
+.stu-answer {
|
|
|
+ width: 100px;
|
|
|
+ border-bottom: 1px solid black;
|
|
|
+}
|
|
|
+
|
|
|
+.option {
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+.question-options {
|
|
|
+ text-align: left;
|
|
|
+ padding-left: 10px;
|
|
|
+}
|
|
|
+</style>
|