|
|
@@ -80,15 +80,27 @@
|
|
|
@blur="textareaFocused = false"
|
|
|
/>
|
|
|
</template>
|
|
|
- <el-input
|
|
|
- v-else-if="item.questionType === '简答题'"
|
|
|
- v-model="item.answer"
|
|
|
- type="textarea"
|
|
|
- :autosize="{ minRows: 4, maxRows: 8 }"
|
|
|
- placeholder="请输入您的答案"
|
|
|
- @focus="textareaFocused = true"
|
|
|
- @blur="textareaFocused = false"
|
|
|
- />
|
|
|
+ <div v-else-if="item.questionType === '简答题'">
|
|
|
+ <el-input
|
|
|
+ v-model="item.answer"
|
|
|
+ type="textarea"
|
|
|
+ :autosize="{ minRows: 4, maxRows: 8 }"
|
|
|
+ placeholder="请输入您的答案"
|
|
|
+ @focus="textareaFocused = true"
|
|
|
+ @blur="textareaFocused = false"
|
|
|
+ />
|
|
|
+ <ibps-attachment
|
|
|
+ v-if="attachmentTF"
|
|
|
+ v-model="item.fuJian"
|
|
|
+ :download="true"
|
|
|
+ multiple
|
|
|
+ accept="*"
|
|
|
+ :readonly="false"
|
|
|
+ :limit="5"
|
|
|
+ :file-size="10 * 1024 * 1024"
|
|
|
+ style="width: 100%; margin-top: 10px; font-size: 14px"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -169,6 +181,8 @@ import { shuffle, round } from 'lodash'
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
+ IbpsAttachment: () =>
|
|
|
+ import('@/business/platform/file/attachment/selector'),
|
|
|
IbpsImage: () => import('@/business/platform/file/image')
|
|
|
},
|
|
|
props: {
|
|
|
@@ -235,7 +249,9 @@ export default {
|
|
|
showIndex: 1,
|
|
|
userId,
|
|
|
countdownNotify: false,
|
|
|
- textareaFocused: false // input 聚焦状态
|
|
|
+ textareaFocused: false, // input 聚焦状态
|
|
|
+ attachmentTF: false,
|
|
|
+ gapFillingAutomatic: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -266,15 +282,18 @@ export default {
|
|
|
},
|
|
|
showIndex: {
|
|
|
handler(val, oldVal) {
|
|
|
- this.pagination.currentPage = Math.ceil(val / this.pagination.pageSize)
|
|
|
- this.activeName = this.pagination.currentPage + ''
|
|
|
- const temp = this.questionList[oldVal - 1]
|
|
|
- if (['填空题'].includes(temp.questionType)) {
|
|
|
- temp.answer = temp.options.map((item) => item.answer)
|
|
|
- }
|
|
|
+ this.handleShowIndex(val, oldVal)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
+ created() {
|
|
|
+ this.attachmentTF =
|
|
|
+ this.$store.getters.setting?.examTag?.tagData?.attachmentTF || false
|
|
|
+
|
|
|
+ this.gapFillingAutomatic =
|
|
|
+ this.$store.getters.setting?.examTag?.tagData?.gapFillingAutomatic ||
|
|
|
+ false
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.loadData()
|
|
|
this.startCountdown()
|
|
|
@@ -290,6 +309,14 @@ export default {
|
|
|
// Watermark.set('', '')
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleShowIndex(val, oldVal) {
|
|
|
+ this.pagination.currentPage = Math.ceil(val / this.pagination.pageSize)
|
|
|
+ this.activeName = this.pagination.currentPage + ''
|
|
|
+ const temp = this.questionList[oldVal - 1]
|
|
|
+ if (['填空题'].includes(temp.questionType)) {
|
|
|
+ temp.answer = temp.options.map((item) => item.answer)
|
|
|
+ }
|
|
|
+ },
|
|
|
pageRange(pageNo) {
|
|
|
return {
|
|
|
start: (pageNo - 1) * this.pagination.pageSize + 1,
|
|
|
@@ -311,7 +338,6 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
this.questionList = await this.getQuestionData()
|
|
|
- // console.log(this.questionList)
|
|
|
// console.log(this.examData)
|
|
|
},
|
|
|
startCountdown() {
|
|
|
@@ -431,6 +457,7 @@ export default {
|
|
|
}
|
|
|
item.img = item.img ? JSON.parse(item.img) : ''
|
|
|
item.answer = item.questionType === '多选题' ? [] : null
|
|
|
+ item.fuJian = ''
|
|
|
})
|
|
|
this.loading = false
|
|
|
resolve(data)
|
|
|
@@ -445,16 +472,19 @@ export default {
|
|
|
const finished = []
|
|
|
this.questionList.forEach((item) => {
|
|
|
if (item.questionType === '填空题') {
|
|
|
- console.log('item.answer', item.answer, item.options, item.options.map((op) => op.answer))
|
|
|
finished.push(
|
|
|
- item.options && !item.options.some((i) => i.answer === '' || i.answer === null)
|
|
|
+ item.options &&
|
|
|
+ !item.options.some((i) => i.answer === '' || i.answer === null)
|
|
|
)
|
|
|
} else if (item.questionType === '多选题') {
|
|
|
finished.push(item.answer.some((i) => i) && true)
|
|
|
+ } else if (item.questionType === '简答题' && this.attachmentTF) {
|
|
|
+ finished.push((item.answer || item.fuJian) && true)
|
|
|
} else {
|
|
|
finished.push(item.answer && true)
|
|
|
}
|
|
|
})
|
|
|
+ // console.log(finished, 'finishedfinished')
|
|
|
// const finished = this.questionList.filter(item => (item.questionType !== '填空题' && item.answer) || (item.questionType === '填空题' && item.answer && !item.answer.some(i => i === '' || i === null))).length
|
|
|
const finishedCount = finished.filter((i) => i).length
|
|
|
const progress = round(
|
|
|
@@ -537,13 +567,24 @@ export default {
|
|
|
this.showIndex++
|
|
|
}, 200)
|
|
|
},
|
|
|
- getScore({ questionType, answer, rightKey, score }) {
|
|
|
+ getScore({ questionType, answer, rightKey, score, options }) {
|
|
|
if (questionType === '多选题') {
|
|
|
const temp = rightKey.split(',')
|
|
|
return answer.length === temp.length &&
|
|
|
answer.every((i) => temp.includes(i))
|
|
|
? score
|
|
|
: 0
|
|
|
+ } else if (questionType === '填空题') {
|
|
|
+ const rightKeyArr = JSON.parse(rightKey)
|
|
|
+ const goal = Number((score / rightKeyArr.length).toFixed(2))
|
|
|
+ let add = 0
|
|
|
+ options.forEach((item, i) => {
|
|
|
+ const mid = rightKeyArr[i].split(',')
|
|
|
+ if (mid.includes(item.answer)) {
|
|
|
+ add += goal
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return add
|
|
|
} else {
|
|
|
return answer === rightKey ? score : 0
|
|
|
}
|
|
|
@@ -554,11 +595,18 @@ export default {
|
|
|
this.questionList.forEach((item, index) => {
|
|
|
if (item.questionType === '填空题') {
|
|
|
const t =
|
|
|
- item.options && !item.options.some((i) => i.answer === '' || i.answer === null)
|
|
|
+ item.options &&
|
|
|
+ !item.options.some((i) => i.answer === '' || i.answer === null)
|
|
|
incompleteList.push(!t ? index + 1 : '')
|
|
|
} else if (item.questionType === '多选题') {
|
|
|
const t = item.answer && item.answer.length
|
|
|
incompleteList.push(!t ? index + 1 : '')
|
|
|
+ } else if (item.questionType === '简答题') {
|
|
|
+ if (this.attachmentTF) {
|
|
|
+ incompleteList.push(!item.answer && !item.fuJian ? index + 1 : '')
|
|
|
+ } else {
|
|
|
+ incompleteList.push(!item.answer ? index + 1 : '')
|
|
|
+ }
|
|
|
} else {
|
|
|
incompleteList.push(!item.answer ? index + 1 : '')
|
|
|
}
|
|
|
@@ -581,12 +629,19 @@ export default {
|
|
|
}
|
|
|
// 处理最后一题无法自动提交的bug
|
|
|
if (
|
|
|
- this.questionList[this.questionList.length - 1] !== '判断题' &&
|
|
|
- this.questionList[this.questionList.length - 1] !== '单选题'
|
|
|
+ this.questionList[this.questionList.length - 1].questionType !==
|
|
|
+ '判断题' &&
|
|
|
+ this.questionList[this.questionList.length - 1].questionType !==
|
|
|
+ '单选题'
|
|
|
) {
|
|
|
const temp = this.showIndex
|
|
|
if (this.showIndex !== this.questionList.length) {
|
|
|
this.showIndex = this.questionList.length
|
|
|
+ } else if (
|
|
|
+ this.showIndex === this.questionList.length &&
|
|
|
+ this.showIndex === 1
|
|
|
+ ) {
|
|
|
+ this.handleShowIndex(1, 1)
|
|
|
} else {
|
|
|
this.showIndex = 1
|
|
|
}
|
|
|
@@ -605,9 +660,13 @@ export default {
|
|
|
const autoType = ['单选题', '多选题', '判断题'].includes(
|
|
|
item.questionType
|
|
|
)
|
|
|
+ const autoFillType =
|
|
|
+ item.questionType === '填空题' &&
|
|
|
+ item.rateType === '自动' &&
|
|
|
+ this.gapFillingAutomatic
|
|
|
const multipleType = ['多选题', '填空题'].includes(item.questionType)
|
|
|
const selectType = ['多选题', '单选题'].includes(item.questionType)
|
|
|
- submitData.push({
|
|
|
+ let obj = {
|
|
|
parent_id_: this.id,
|
|
|
ti_mu_id_: item.questionId,
|
|
|
ti_gan_: item.stem,
|
|
|
@@ -624,13 +683,17 @@ export default {
|
|
|
multipleType && item.answer
|
|
|
? JSON.stringify(item.answer)
|
|
|
: item.answer,
|
|
|
- shi_fou_yi_yue_: autoType ? '是' : '否',
|
|
|
+ shi_fou_yi_yue_: autoType || autoFillType ? '是' : '否',
|
|
|
ping_yue_shi_jian: autoType ? time : '',
|
|
|
- de_fen_: autoType ? this.getScore(item) : '',
|
|
|
+ de_fen_: autoType || autoFillType ? this.getScore(item) : '',
|
|
|
jie_xi_: '',
|
|
|
nan_du_: item.questionLevel || 0,
|
|
|
da_an_jie_xi_: item.resolution || ''
|
|
|
- })
|
|
|
+ }
|
|
|
+ if (this.attachmentTF) {
|
|
|
+ obj['fu_jian_'] = item.fuJian || ''
|
|
|
+ }
|
|
|
+ submitData.push(obj)
|
|
|
})
|
|
|
return submitData
|
|
|
},
|