TextQuestionView.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div class="question-view">
  3. <question-body :questionBody="question.body" :examQuestionId="examQuestion.id"></question-body>
  4. <div class="ops">
  5. <div class="score">({{examQuestion.questionScore}}分)</div>
  6. </div>
  7. <div class="option">
  8. <textarea v-model="studentAnswer" class="stu-answer" @blur="answerQuestion" type="text" />
  9. </div>
  10. <div class="reset">
  11. <i-button type="warning" size="large" @click="() => this.answerQuestion(null)">重置答案</i-button>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import QuestionBody from "./QuestionBody";
  17. import { createNamespacedHelpers } from "vuex";
  18. const { mapMutations } = createNamespacedHelpers("examingHomeModule");
  19. export default {
  20. name: "TextQuestionView",
  21. data() {
  22. return {
  23. studentAnswer: this.examQuestion.studentAnswer
  24. };
  25. },
  26. props: {
  27. question: Object,
  28. examQuestion: Object
  29. },
  30. methods: {
  31. ...mapMutations(["updateExamQuestion"]),
  32. async answerQuestion(reset) {
  33. if (reset === null) {
  34. this.studentAnswer = null;
  35. }
  36. const order = this.examQuestion.order;
  37. const studentAnswer = this.studentAnswer;
  38. await this.$http.post(
  39. "/api/ecs_oe_student/examQuestion/submitQuestionAnswer",
  40. [
  41. {
  42. order: order,
  43. studentAnswer: studentAnswer
  44. }
  45. ]
  46. );
  47. this.updateExamQuestion({
  48. order: order,
  49. studentAnswer: studentAnswer
  50. });
  51. }
  52. },
  53. watch: {
  54. examQuestion(cur, prev) {
  55. this.studentAnswer = this.examQuestion.studentAnswer;
  56. }
  57. },
  58. components: {
  59. QuestionBody
  60. }
  61. };
  62. </script>
  63. <style scoped>
  64. .question-view {
  65. display: grid;
  66. grid-row-gap: 10px;
  67. }
  68. .question-body {
  69. font-size: 18px;
  70. margin-bottom: 10px;
  71. }
  72. .ops {
  73. display: flex;
  74. align-items: flex-end;
  75. }
  76. .stu-answer {
  77. width: 500px;
  78. min-height: 300px;
  79. }
  80. .option {
  81. display: flex;
  82. }
  83. .question-options {
  84. text-align: left;
  85. }
  86. </style>