BooleanQuestionView.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="question-view">
  3. <div class="question-body" v-html="question.body"></div>
  4. <div class="ops">
  5. <div class="stu-answer"> {{stuAnswer}}</div>
  6. <i-button @click="resetQuestion(examQuestion.id)">重置</i-button>
  7. <div class="score">({{question.questionScore}}分)</div>
  8. </div>
  9. <div @click="answerQuestion(examQuestion.id, '正确')">
  10. <input type="radio" name="question" value="正确" :checked="stuAnswer === '正确'" />
  11. <span class="question-options">正确</span>
  12. </div>
  13. <div @click="answerQuestion(examQuestion.id, '错误')">
  14. <input type="radio" name="question" value="错误" :checked="stuAnswer === '错误'" />
  15. <span class="question-options">错误</span>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "BooleanQuestionView",
  22. data() {
  23. return {
  24. stuAnswer: this.examQuestion.stuAnswer
  25. };
  26. },
  27. props: {
  28. question: Object,
  29. examQuestion: Object
  30. },
  31. methods: {
  32. answerQuestion: function(examQuestionId, stuAnswer) {
  33. this.stuAnswer = stuAnswer;
  34. this.$http.put("/api/exam_question/" + examQuestionId, { stuAnswer });
  35. },
  36. resetQuestion: function(examQuestionId) {
  37. this.stuAnswer = null;
  38. this.$http.put("/api/exam_question/" + examQuestionId, {
  39. stuAnswer: null
  40. });
  41. }
  42. },
  43. watch: {}
  44. };
  45. </script>
  46. <style scoped>
  47. .question-view {
  48. display: block;
  49. }
  50. .ops {
  51. display: flex;
  52. align-items: flex-end;
  53. }
  54. .stu-answer {
  55. width: 100px;
  56. border-bottom: 1px solid black;
  57. }
  58. .option {
  59. display: flex;
  60. }
  61. .question-options {
  62. text-align: left;
  63. padding-left: 10px;
  64. }
  65. </style>