fuliqi
2024-07-08 c9180bba81b105f1932d45223de440f8dd5e3cd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<template>
  <div v-loading="qLoading" style="line-height:1.8">
    <div
      v-if="qType == 1 || qType == 2 || qType == 3 || qType == 4 || qType == 5 || qType == 6 || qType == 7 || qType == 8">
      <!-- 选择或语音 -->
      <div v-if="qType == 1 || qType == 6">
        <div class="q-title" v-html="question.title"/>
        <div class="q-content">
          <el-radio-group v-model="question.answer">
            <el-radio class="custom-radio" v-for="item in question.questionItemList" :key="item.prefix" :label="item.prefix " disabled>
              <span class="question-prefix">{{ item.prefix }}.</span>
              <span v-html="item.content" class="q-item-span-content"></span>
            </el-radio>
          </el-radio-group>
        </div>
      </div>
      <!-- 多选 -->
      <div v-else-if="qType == 2">
        <div class="q-title" v-html="question.title"/>
        <div class="q-content">
          <el-checkbox-group v-model="question.answerList">
            <el-checkbox v-for="item in question.questionItemList" :label="item.prefix" :key="item.prefix" disabled>
              <span class="question-prefix">{{ item.prefix }}.</span>
              <span v-html="item.content" class="q-item-span-content"></span>
            </el-checkbox>
          </el-checkbox-group>
        </div>
      </div>
      <!-- 判断 -->
      <div v-else-if="qType == 3">
        <div class="q-title" v-html="question.title" style="display: inline;margin-right: 10px" />
        <span style="padding-right: 10px;">(</span>
        <el-radio-group v-model="question.answer">
          <el-radio v-for="item in question.questionItemList" :key="item.prefix" :label="item.prefix " disabled>
            <span v-html="item.content" class="q-item-span-content"></span>
          </el-radio>
        </el-radio-group>
        <span style="padding-left: 10px;">)</span>
      </div>
      <!-- 填空 -->
      <div v-else-if="qType == 4">
        <div class="q-title" v-html="question.title"/>
        <div v-if="question.answerList !== null">
          <el-form-item :label="item.prefix" :key="item.prefix" v-for="item in question.questionItemList"
                        label-width="50px"
                        style="margin-top: 10px;margin-bottom: 10px;">
            <el-input v-model="question.answerList[item.prefix - 1]" disabled/>
          </el-form-item>
        </div>
      </div>
      <!-- 简答、计算、分析 -->
      <div v-else-if="qType == 5 || qType == 7 || qType == 8">
        <div class="q-title" v-html="question.title"/>
        <div class="rich-text-box">
          <div v-html="question.answer"></div>
        </div>
      </div>
      <div class="question-answer-show-item" style="margin-top: 15px">
        <span class="question-show-item">结果:</span>
        <el-tag :type="rightTagFormatter(question.right)">
          {{ rightTextFormatter(question.right) }}
        </el-tag>
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item">总分:</span>
        <span>{{ question.questionScore }}</span>
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item">得分:</span>
        <span>{{ question.score }}</span>
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item">难度:</span>
        <el-rate disabled v-model="question.difficult" class="question-show-item"></el-rate>
      </div>
      <br/>
      <div class="question-answer-show-item" style="line-height: 1.8">
        <span class="question-show-item">解析:</span>
        <span v-html="question.analyze" class="q-item-span-content"/>
      </div>
      <div class="question-answer-show-item">
        <span class="question-show-item">正确答案:</span>
        <!-- 选择、多选、简答、语音、计算、分析 -->
        <span v-if="qType == 1 || qType == 2 || qType == 5 || qType == 6 || qType == 7 || qType == 8"
              v-html="question.questionAnswer" class="q-item-span-content"/>
        <!-- 判断 -->
        <span v-if="qType == 3" v-html="trueFalseFormatter(question)" class="q-item-span-content"/>
        <!-- 填空 -->
        <span v-if="qType == 4">{{ question.questionAnswer }}</span>
      </div>
      <span style="color:#ECAB3C;">{{ '批改:' }}</span>
      <el-input-number size="mini" v-model="question.score" :precision="1" :min="0"
                       :max="parseFloat(question.questionScore)" @change="updateRight"></el-input-number>
    </div>
    <div v-else>
    </div>
  </div>
 
</template>
 
<script>
import { mapState, mapGetters } from 'vuex'
 
export default {
  name: 'QuestionShow',
  props: {
    question: {
      type: Object,
      default: function () {
        return {}
      }
    },
    answer: {
      type: Array,
      default: function () {
        return {}
      }
    },
    qLoading: {
      type: Boolean,
      default: false
    },
    qType: {
      type: Number,
      default: 0
    }
  },
  methods: {
    updateRight () {
      // 当score变化时,检查它是否等于questionScore
      this.question.right = this.question.score === parseFloat(this.question.questionScore)
      const foundAnswer = this.answer.find(answer => answer.itemOrder === this.question.itemOrder)
      if (foundAnswer) {
        foundAnswer.right = this.question.right
      }
    },
    trueFalseFormatter (question) {
      return question.questionItemList.filter(d => d.prefix === question.questionAnswer)[0].content
    },
    rightTagFormatter (status) {
      return this.enumFormat(this.rightTag, status)
    },
    rightTextFormatter (status) {
      return this.enumFormat(this.rightEnum, status)
    }
  },
  computed: {
    ...mapGetters('enumItem', ['enumFormat']),
    ...mapState('enumItem', {
      rightEnum: state => state.exam.question.answer.doRightEnum,
      rightTag: state => state.exam.question.answer.doRightTag
    })
  }
}
</script>
 
<style scoped>
 
/deep/ .el-checkbox__input.is-disabled + .el-checkbox__label {
  color: #606266
}
 
/deep/ .el-checkbox__input.is-disabled.is-checked + .el-checkbox__label {
  color: #606266
}
 
/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner:after {
  border-color: #606266
}
 
/deep/ .el-radio__input.is-disabled + span.el-radio__label {
  color: #606266
}
 
/deep/ .el-radio__input.is-disabled.is-checked .el-radio__inner::after {
  background-color: #606266;
}
 
/deep/ .el-radio__input.is-disabled .el-radio__inner, .el-radio__input.is-disabled.is-checked .el-radio__inner {
  border-color: #606266
}
 
/deep/ .el-input.is-disabled .el-input__inner, textarea:disabled {
  color: #606266
}
 
/deep/ .el-range-editor.is-disabled input {
  color: #606266
}
 
.rich-text-box {
  border: 1px solid #ccc; /* 添加边框 */
  padding: 10px ; /* 添加内边距以提供空间 */
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
</style>