question-answer.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view class="questionBankAnswer-jiexi">
  3. <!--如果答对加class=dui-->
  4. <view class="questionBankAnswer-jiexi-daan"
  5. :class="[answer_type(timu_order-1) == 1 ? 'dui' : 'cuo',current_timu.type == 5 ? 'jianda' : '']">
  6. <view class="questionBankAnswer-jiexi-daan-flex">
  7. <view class="dui_jd_b">{{current_timu.type == 5 ? '参考答案' : '正确答案'}}</view>
  8. <view class="questionBankAnswer-jiexi-daan-flex-dui"
  9. v-if="current_timu.right_answer == 1 || current_timu.right_answer == 0">
  10. {{ current_timu.right_answer == 1 ? '对' : '错' }}
  11. </view>
  12. <view v-else-if="current_timu.type != 4" class="questionBankAnswer-jiexi-daan-flex-dui"
  13. :style="{'font-size':(current_timu.type > 3 ?'16px':'30px')}">
  14. <uc-parse :node="current_timu.right_answer"></uc-parse>
  15. </view>
  16. <view v-else-if="current_timu.type == 4" class="questionBankAnswer-jiexi-daan-flex-dui"
  17. :style="{'font-size':(current_timu.type > 3 ?'16px':'30px')}"
  18. v-html="current_timu.right_answer.split('|').join(',')">
  19. </view>
  20. </view>
  21. <view class="questionBankAnswer-jiexi-flex" v-if="myAnswer">
  22. <view v-if="current_timu.type != 5" class="questionBankAnswer-jiexi-daan-line"></view>
  23. <view class="questionBankAnswer-jiexi-daan-flex">
  24. <view>我的答案</view>
  25. <view style="word-break: break-all;"
  26. :class="[(copy_post_answer_right[current_timu.id] || answer_type(timu_order-1) == 1)?'questionBankAnswer-jiexi-daan-flex-dui':'questionBankAnswer-jiexi-daan-flex-cuo']"
  27. :style="{'font-size':(current_timu.type > 3 ?'16px':'30px')}">{{myAnswer}}
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="questionBankAnswer-jiexi-jx" v-if="current_timu.area != '' && current_timu.area != null">
  33. <view class="questionBankAnswer-jiexi-jx-title">试题解析</view>
  34. <view>
  35. <uc-parse :node="current_timu.area"></uc-parse>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. props: {
  43. timu_order: {
  44. type: Number,
  45. default: 0
  46. },
  47. show_beiti: {
  48. type: Boolean,
  49. default: true,
  50. },
  51. current_timu: {
  52. type: Object,
  53. default: function() {
  54. return {}
  55. },
  56. },
  57. timu_list: {
  58. type: Array,
  59. default: function() {
  60. return [];
  61. },
  62. },
  63. copy_post_answer_right: {
  64. type: Object,
  65. default: function() {
  66. return {}
  67. },
  68. },
  69. },
  70. data() {
  71. return {
  72. myAnswer: ''
  73. }
  74. },
  75. methods: {
  76. //我的答案处的背景颜色
  77. answer_type(index) {
  78. if (this.show_beiti || this.timu_list[index].state == 2) {
  79. return 1
  80. }
  81. return 0
  82. },
  83. my_answer(copy_user_answer) {
  84. let answers = copy_user_answer[this.current_timu.id] || [];
  85. if (this.current_timu.type <= 3) {
  86. let answer = '';
  87. if (answers && answers.length > 0) {
  88. for (let i = 0, leng = answers.length; i < leng; i++) {
  89. if (answers[i].active) {
  90. answer += answers[i].answer_code
  91. }
  92. }
  93. }
  94. if (answer === '1') {
  95. answer = '对'
  96. } else if (answer === '0') {
  97. answer = '错'
  98. }
  99. this.myAnswer = answer
  100. } else {
  101. if (answers && answers.length == 0) {
  102. this.myAnswer = ''
  103. // || (this.current_timu.my_answer_arr || []).join(',')
  104. } else {
  105. this.myAnswer = answers.join(',')
  106. }
  107. }
  108. },
  109. }
  110. }
  111. </script>
  112. <style>
  113. </style>