TopicAnswer.vue 1.6 KB

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