提交 a07bd999 authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 882b76e0
<template>
<container :title="chapter.name" v-loading="loading">
<template v-slot:header-aside v-if="isSubmited">正确率:{{detail.score}}%</template>
<template v-slot:header-aside v-if="isSubmited">正确率:{{ detail.score }}%</template>
<div class="exam">
<div class="exam-form">
<el-form :disabled="isSubmited">
......@@ -15,7 +15,7 @@
></exam-item>
<div class="exam-buttons">
<el-tooltip effect="dark" content="提交之后就不能修改了哦" placement="right">
<el-button type="primary" :loading="submitLoading" @click="onSubmit">{{submitText}}</el-button>
<el-button type="primary" :loading="submitLoading" @click="onSubmit">{{ submitText }}</el-button>
</el-tooltip>
</div>
</el-form>
......@@ -60,9 +60,7 @@ export default {
chapter: {
immediate: true,
handler(data) {
this.questions = data.homework
? this.genQuenstions(data.homework.questions)
: []
this.questions = data.homework ? this.genQuenstions(data.homework.questions) : []
}
}
},
......@@ -91,8 +89,7 @@ export default {
},
// 是否提交
isSubmited() {
// return this.detail ? !!this.detail.work_contents : false
return false
return this.detail ? !!this.detail.work_contents : false
},
// 提交按钮文本
submitText() {
......@@ -111,16 +108,13 @@ export default {
const parseAnswers = JSON.parse(this.detail.work_contents)
// 设置答案
this.questions = this.questions.map(item => {
const found = parseAnswers.find(
answer => answer.question_id === item.id
)
const found = parseAnswers.find(answer => answer.question_id === item.id)
if (found) {
const selectedIds = found.options.reduce((result, item) => {
item.selected && result.push(item.id)
return result
}, [])
item.user_answer =
item.question_type === 2 ? selectedIds : selectedIds[0]
item.user_answer = item.question_type === 2 ? selectedIds : selectedIds[0]
}
return item
})
......@@ -153,9 +147,7 @@ export default {
temp = {
formModel: {
id: item.id,
user_answer: item.user_answer
? Base64.decode(item.user_answer)
: '',
user_answer: item.user_answer ? Base64.decode(item.user_answer) : '',
attachments: item.attachments || ''
}
}
......@@ -165,9 +157,7 @@ export default {
item,
{
content: item.question_content,
options: item.question_options
? JSON.parse(item.question_options)
: []
options: item.question_options ? JSON.parse(item.question_options) : []
},
temp
)
......@@ -193,9 +183,7 @@ export default {
return
}
// 计算答题时间
const duration = Math.floor(
(new Date().getTime() - this.startTime) / 1000
)
const duration = Math.floor((new Date().getTime() - this.startTime) / 1000)
// 答案数据
const data = this.handleSubmitData()
// 计算分数
......@@ -225,9 +213,7 @@ export default {
// 选择的项
const answers = item.formModel.user_answer
// 是否选中该项
const selected = Array.isArray(answers)
? answers.includes(option.id)
: option.id === answers
const selected = Array.isArray(answers) ? answers.includes(option.id) : option.id === answers
// 是否选择正确
if (option.checked !== selected && isCorrect) {
isCorrect = false
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论