TrueOrFalse.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <div class="mta-true-or-false" v-if="pageData.name">
  3. <el-row class="mta-first-row" type="flex">
  4. <el-col>
  5. <span class="wrap-shitiIndex" v-if="!!shitiIndex">
  6. <span v-if="isYueDu">({{shitiIndex}})</span>
  7. <span v-else>{{shitiIndex}}.</span>
  8. </span>
  9. <!-- 试题题目 -->
  10. <div class="mta-SC-title" v-html="pageData.name"></div>
  11. <span class="mta-SC-score" v-if="getShowScore && !isYueDu">({{pageData.score}}分)</span>
  12. </el-col>
  13. </el-row>
  14. <el-row class="mta-two-row" type="flex" v-if='audioOptions' >
  15. <mta-bus-audio-player :checktimes="false" :options="audioOptions"></mta-bus-audio-player>
  16. </el-row>
  17. <el-row class="mta-two-row" type="flex">
  18. <el-col>
  19. <!-- 试题内容区域 -->
  20. <el-radio-group v-model="newRadioData" @change="selectChange"
  21. :class="{'showError': showError && typeCase === 'geren'}">
  22. <div class="mta-panduan-row">
  23. <el-radio label="1">正确</el-radio>
  24. </div>
  25. <div class="mta-panduan-row">
  26. <el-radio label="0">错误</el-radio>
  27. </div>
  28. </el-radio-group>
  29. <div class="mta-modal" v-if="getShowModel"></div>
  30. </el-col>
  31. </el-row>
  32. <mta-answer-area
  33. v-if="typeCase === 'geren' || typeCase === 'cuoti2' || typeCase === 'cuoti3' || typeCase === 'yulan'"
  34. :data="{
  35. showAnswer:showAnswer,
  36. analysis: pageData.answer
  37. }"
  38. ></mta-answer-area>
  39. </div>
  40. </template>
  41. <script>
  42. import {mapGetters} from 'vuex'
  43. import MtaAnswerArea from '@/components/client/QuestionsForCuoti/AnswerArea.vue'
  44. import MtaBusAudioPlayer from '@/components/custom/MtaBusAudioPlayer.vue';
  45. export default {
  46. name: "TrueOrFalse",
  47. props: {
  48. questionData: { // 单选题数据
  49. require: true,
  50. type: Object,
  51. },
  52. shitiIndex: { // 试题序号
  53. type: Number,
  54. default: 0
  55. },
  56. isYueDu: {
  57. type: Boolean,
  58. default: false
  59. },
  60. yuduIndex: {
  61. type: Number,
  62. },
  63. // 组件接环状态, kaoshi,geren,yulan,cuoti2
  64. typeCase: {
  65. type: String,
  66. default: 'kaoshi'
  67. },
  68. getShowModel: {
  69. type: Boolean,
  70. default: true
  71. }
  72. },
  73. components: {
  74. MtaAnswerArea,
  75. MtaBusAudioPlayer,
  76. },
  77. data() {
  78. return {
  79. // 页面渲染必须数据
  80. pageData: null,
  81. // 答案
  82. newRadioData: this.questionData.reply,
  83. showAnswer: null,
  84. // 错误
  85. showError: false,
  86. // 解析
  87. analysis: null,
  88. audioOptions: null,
  89. }
  90. },
  91. watch: {
  92. questionData: {
  93. handler(newVal, oldVal) {
  94. switch (this.typeCase) {
  95. case `kaoshi`:
  96. this.pageData = newVal;
  97. this.newRadioData = newVal.reply;
  98. break;
  99. case `geren`:
  100. this.pageData = newVal;
  101. // 答案
  102. this.newRadioData = newVal.reply;
  103. // 解析答案
  104. this.showAnswer = newVal.result === '0' ? '错误' : '正确';
  105. // 解析
  106. this.analysis = newVal.answer;
  107. // 错误是否显示
  108. this.showError = this.checkAnswer(newVal.result, newVal.reply);
  109. break;
  110. case `cuoti`:
  111. this.pageData = newVal;
  112. this.newRadioData = newVal.reply;
  113. break;
  114. case `yulan`:
  115. this.pageData = newVal;
  116. // this.newRadioData = newVal.result;
  117. this.newRadioData = null;
  118. // 解析答案
  119. this.showAnswer = newVal.result === '0' ? '错误' : '正确';
  120. // 解析
  121. this.analysis = newVal.answer;
  122. break;
  123. case `cuoti2`:
  124. this.pageData = newVal;
  125. // 单选题答案
  126. this.newRadioData = newVal.reply;
  127. // 解析答案
  128. this.showAnswer = newVal.reply === '0' ? '错误' : '正确';
  129. // 解析
  130. this.analysis = newVal.answer;
  131. break;
  132. case `cuoti3`:
  133. this.pageData = newVal;
  134. // 单选题答案
  135. this.newRadioData = newVal.reply;
  136. // 解析答案
  137. this.showAnswer = newVal.reply === '0' ? '错误' : '正确';
  138. // 解析
  139. this.analysis = newVal.answer;
  140. break;
  141. }
  142. let data = this.questionData;
  143. if (data.adjunct) {
  144. let arrItem = JSON.parse(data.adjunct);
  145. for (const item of arrItem) {
  146. if (item.type === 'audio') {
  147. this.audioOptions = {};
  148. this.audioOptions.src = item.src;
  149. this.audioOptions.title = item.oriname.split('.')[0];
  150. this.audioOptions.autoplay = false;
  151. this.audioOptions.dragable = item.dragable;
  152. this.audioOptions.playtimes = item.playtimes;
  153. }
  154. }
  155. }
  156. },
  157. immediate: true,
  158. deep: true
  159. },
  160. /* questionData: function (newVal, oldVal) {
  161. this.newRadioData = newVal.reply;
  162. },*/
  163. },
  164. computed: {
  165. ...mapGetters(['getShowScore']),
  166. },
  167. methods: {
  168. checkAnswer(result, reply) {
  169. return result !== reply
  170. },
  171. selectChange(val) {
  172. this.questionData.reply = val;
  173. this.pageData.reply = val;
  174. this.showError = this.checkAnswer(this.pageData.result, val);
  175. if (this.isYueDu) {
  176. this.$emit('reply', {
  177. paragraph: this.questionData.paragraph,
  178. type: 'panduan',
  179. stId: this.questionData.stId,
  180. data: this.newRadioData,
  181. number: this.yuduIndex,
  182. });
  183. } else {
  184. this.$emit('reply', {
  185. paragraph: this.questionData.paragraph,
  186. stId: this.questionData.stId,
  187. data: this.newRadioData,
  188. number: this.shitiIndex - 1,
  189. });
  190. }
  191. }
  192. },
  193. }
  194. </script>