TopicAnswer.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <div class="cont-item-detail">
  3. <h4 class="cont-part-title">
  4. {{ data.answerType === "student" ? "学生答案" : "答案" }}
  5. </h4>
  6. <div
  7. v-if="data.structType === STRUCT_TYPES.BOOLEAN_CHOICE"
  8. class="cont-part-body"
  9. >
  10. {{ data.answer ? "对" : "错" }}
  11. </div>
  12. <div
  13. v-else-if="data.structType === STRUCT_TYPES.FILL_BLANK"
  14. class="cont-part-body"
  15. >
  16. <p v-for="(cont, cindex) in data.body" :key="cindex">
  17. <rich-text :text-json="cont"></rich-text>
  18. </p>
  19. </div>
  20. <div
  21. v-else-if="data.structType === STRUCT_TYPES.TEXT"
  22. class="cont-part-body"
  23. >
  24. <p v-for="(cont, cindex) in data.body" :key="cindex">
  25. <rich-text :text-json="cont"></rich-text>
  26. </p>
  27. </div>
  28. <div v-else class="cont-part-body">
  29. {{ answer }}
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import RichText from "./RichText.vue";
  35. export default {
  36. name: "topic-answer",
  37. components: { RichText },
  38. props: {
  39. data: {
  40. type: Object,
  41. default() {
  42. return {};
  43. },
  44. },
  45. },
  46. data() {
  47. return {
  48. STRUCT_TYPES: {
  49. SINGLE_CHOICE: 1,
  50. MULTIPLE_CHOICE: 2,
  51. BOOLEAN_CHOICE: 3,
  52. FILL_BLANK: 4,
  53. TEXT: 5,
  54. NESTED: 6,
  55. LISTENING: 7,
  56. MATCHES: 8,
  57. },
  58. optionNames: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
  59. };
  60. },
  61. computed: {
  62. answer() {
  63. const SELECT_TYPES = [
  64. this.STRUCT_TYPES.SINGLE_CHOICE,
  65. this.STRUCT_TYPES.MULTIPLE_CHOICE,
  66. ];
  67. return SELECT_TYPES.includes(this.data.structType)
  68. ? this.data.body.map((item) => this.optionNames[item - 1]).join("")
  69. : "";
  70. },
  71. },
  72. methods: {},
  73. };
  74. </script>