123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <template>
- <view class="questionBankAnswer-content-menu" @tap="post_answer(item, index)" :class="{'active-bg': answerRightFlag, //// 用户答题完毕,正确答案显示,用户
- // 错误答案显示 !((copy_post_status[current_timu.id] || show_beiti) && item.right_flg)
- 'kaoshi': question_type == 'exam',
- 'error-bg':answerWrongFlag}">
-
- <view class="questionBankAnswer-content-num" :class="{'active': answerRightFlag, //// 用户答题完毕,正确答案显示,用户
- // 错误答案显示
- 'error':answerWrongFlag}">
- {{ item.answer_code === '1' ? 'A' : item.answer_code === '0' ? 'B' :
- item.answer_code }}
-
-
-
- <view class="questionBankAnswer-dui">
- <image v-if="answerRightFlag && question_type != 'exam'" :src="static_media.img01" class="questionBankAnswer-dui-img"></image>
-
- </view>
- </view>
- <view class="questionBankAnswer-content-txt">
- <uc-parse :node="getAsw(item.answer)"></uc-parse>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- question_type: {
- type: String,
- default: 'test'
- },
- type: {
- type: String,
- default: '-1'
- },
- item: {
- type: Object,
- default: function() {
- return {}
- },
- },
- index: {
- type: Number,
- default: -1
- },
- show_beiti: {
- type: Boolean,
- default: true,
- },
- current_timu: {
- type: Object,
- default: function() {
- return {}
- },
- },
- copy_user_answer: {
- type: Object,
- default: function() {
- return {}
- },
- },
- copy_post_status: {
- type: Object,
- default: function() {
- return {}
- },
- },
- timu_index: {
- type: Number,
- default: -1
- }
- },
- data() {
- return {
- answerRightFlag: false,
- answerWrongFlag: false,
- }
- },
- computed: {
- static_media() {
- return {
- img01: this.$myConfig.localMedia + '/static/img/dui.png',
- }
- },
- },
- created() {},
- methods: {
- getAsw(item) {
- item = item.replace(/^[A-Z]\./,'')
-
- return item
- },
- setAnswerStyle(copy_user_answer) {
- this.answerRightFlag = false
- this.answerWrongFlag = false
- this.computedError(this.index, copy_user_answer)
- this.computedActive(this.item, this.index, copy_user_answer)
- },
-
- computedError(index, copy_user_answer) {
- if (this.question_type == 'exam') {
- this.answerWrongFlag = false
- return
- } else if (copy_user_answer && copy_user_answer[this.current_timu.id] && copy_user_answer[this
- .current_timu.id][index]) {
- if (copy_user_answer[this.current_timu.id][index].error_flg && ((this.current_timu.type == 2 &&
- this.copy_post_status[this.current_timu.id]) || (this.current_timu.type == 1 || this
- .current_timu.type == 3))) {
- this.answerWrongFlag = true
- return
- }
- this.answerWrongFlag = false
- return
- }
- this.answerWrongFlag = false
- },
-
- computedActive(item, index, copy_user_answer) {
- if (this.question_type == 'exam') {
- if (copy_user_answer && copy_user_answer[this.current_timu.id] && copy_user_answer[this.current_timu
- .id][index].active) {
- this.answerRightFlag = true
- return
- } else {
- this.answerRightFlag = false
- return
- }
- } else if (this.show_beiti || this.copy_post_status[this.current_timu.id]) {
-
- if (item.right_flg) {
- this.answerRightFlag = true
- return
- }
- this.answerRightFlag = false
- return
- } else if (copy_user_answer && copy_user_answer[this.current_timu.id] && copy_user_answer[
- this.current_timu.id][index].active) {
-
- this.answerRightFlag = true
- return
- }
- this.answerRightFlag = false
- },
-
- post_answer(item, index) {
- let copy_user_answer_this = JSON.parse(JSON.stringify(this.copy_user_answer))
-
- if (this.show_beiti) {
- return;
- }
-
- if (this.current_timu.type == 1 || this.current_timu.type == 3) {
- this.$nextTick(() => {
- if (copy_user_answer_this[this.current_timu.id]) {
- for (let i = 0, leng = copy_user_answer_this[this.current_timu.id].length; i <
- leng; i++) {
- copy_user_answer_this[this.current_timu.id].splice(i, 1, {
- ...copy_user_answer_this[this.current_timu.id][i],
- active: false,
- error_flg: false
- })
- }
- if (this.current_timu.right_answer.toString().toLowerCase().replace(/\s/g, '').indexOf(
- item.answer_code.toString().toLowerCase().replace(/\s/g, '')) === -1) {
- copy_user_answer_this[this.current_timu.id].splice(index, 1, {
- ...copy_user_answer_this[this.current_timu.id][index],
- active: true,
- error_flg: true
- })
- } else {
- copy_user_answer_this[this.current_timu.id].splice(index, 1, {
- ...copy_user_answer_this[this.current_timu.id][index],
- active: true,
- error_flg: false
- })
- }
- }
- this.$emit('set_copy_user_answer', copy_user_answer_this)
- this.$emit('post_answer_req', true)
- });
- } else if (this.current_timu.type == 2) {
-
- if (copy_user_answer_this[this.current_timu.id]) {
- this.$emit('set_sub_button_style', 'is_duoxuan_sub', false)
- if (copy_user_answer_this[this.current_timu.id][index]) {
- if (copy_user_answer_this[this.current_timu.id][index].active) {
- copy_user_answer_this[this.current_timu.id].splice(index, 1, {
- ...copy_user_answer_this[this.current_timu.id][index],
- active: false,
- error_flg: false
- })
- } else {
- if (this.current_timu.right_answer.toString().toLowerCase().replace(/\s/g, '').indexOf(item
- .answer_code.toString().toLowerCase().replace(/\s/g, '')) === -1) {
- copy_user_answer_this[this.current_timu.id].splice(index, 1, {
- ...copy_user_answer_this[this.current_timu.id][index],
- active: true,
- error_flg: true
- })
- } else {
- copy_user_answer_this[this.current_timu.id].splice(index, 1, {
- ...copy_user_answer_this[this.current_timu.id][index],
- active: true,
- error_flg: false
- })
- }
- }
- }
- }
- this.$emit('set_copy_user_answer', copy_user_answer_this)
- }
- },
- }
- }
- </script>
|