|
@@ -4,6 +4,7 @@
|
|
|
:visible.sync="dialogVisible"
|
|
:visible.sync="dialogVisible"
|
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
|
:close-on-press-escape="false"
|
|
:close-on-press-escape="false"
|
|
|
|
|
+ :show-close="false"
|
|
|
append-to-body
|
|
append-to-body
|
|
|
fullscreen
|
|
fullscreen
|
|
|
class="dialog test-dialog"
|
|
class="dialog test-dialog"
|
|
@@ -35,21 +36,21 @@
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="answer">
|
|
<div class="answer">
|
|
|
- <el-radio-group v-if="item.questionType === '单选题'" v-model="item.answer">
|
|
|
|
|
|
|
+ <el-radio-group v-if="item.questionType === '单选题'" v-model="item.answer" @change="goNext">
|
|
|
<el-radio
|
|
<el-radio
|
|
|
v-for="(o, i) in item.options"
|
|
v-for="(o, i) in item.options"
|
|
|
:key="`${index}${i}`"
|
|
:key="`${index}${i}`"
|
|
|
:label="o.label"
|
|
:label="o.label"
|
|
|
>{{ `${o.label}.${o.value}` }}</el-radio>
|
|
>{{ `${o.label}.${o.value}` }}</el-radio>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
|
- <el-checkbox-group v-else-if="item.questionType === '多选题'" v-model="item.answer">
|
|
|
|
|
|
|
+ <el-checkbox-group v-else-if="item.questionType === '多选题'" v-model="item.answer" @change="changeOptions">
|
|
|
<el-checkbox
|
|
<el-checkbox
|
|
|
v-for="(o, i) in item.options"
|
|
v-for="(o, i) in item.options"
|
|
|
:key="`${index}${i}`"
|
|
:key="`${index}${i}`"
|
|
|
:label="o.label"
|
|
:label="o.label"
|
|
|
- >{{ o.value }}</el-checkbox>
|
|
|
|
|
|
|
+ >{{ `${o.label}.${o.value}` }}</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
|
- <el-radio-group v-else-if="item.questionType === '判断题'" v-model="item.answer">
|
|
|
|
|
|
|
+ <el-radio-group v-else-if="item.questionType === '判断题'" v-model="item.answer" @change="goNext">
|
|
|
<el-radio-button label="√">√</el-radio-button>
|
|
<el-radio-button label="√">√</el-radio-button>
|
|
|
<el-radio-button label="×">×</el-radio-button>
|
|
<el-radio-button label="×">×</el-radio-button>
|
|
|
</el-radio-group>
|
|
</el-radio-group>
|
|
@@ -99,8 +100,6 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-import ActionUtils from '@/utils/action'
|
|
|
|
|
-import { paperTypeOptions } from '../constants'
|
|
|
|
|
export default {
|
|
export default {
|
|
|
components: {
|
|
components: {
|
|
|
IbpsImage: () => import('@/business/platform/file/image')
|
|
IbpsImage: () => import('@/business/platform/file/image')
|
|
@@ -110,11 +109,11 @@ export default {
|
|
|
type: Boolean,
|
|
type: Boolean,
|
|
|
default: false
|
|
default: false
|
|
|
},
|
|
},
|
|
|
- id: {
|
|
|
|
|
|
|
+ paperId: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: ''
|
|
default: ''
|
|
|
},
|
|
},
|
|
|
- parentId: {
|
|
|
|
|
|
|
+ id: {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: ''
|
|
default: ''
|
|
|
}
|
|
}
|
|
@@ -122,7 +121,6 @@ export default {
|
|
|
data () {
|
|
data () {
|
|
|
const { userId } = this.$store.getters || {}
|
|
const { userId } = this.$store.getters || {}
|
|
|
return {
|
|
return {
|
|
|
- paperTypeOptions,
|
|
|
|
|
title: '参加考试',
|
|
title: '参加考试',
|
|
|
dialogVisible: this.visible,
|
|
dialogVisible: this.visible,
|
|
|
toolbars: [
|
|
toolbars: [
|
|
@@ -153,7 +151,8 @@ export default {
|
|
|
{ key: 'cancel', label: '退出' }
|
|
{ key: 'cancel', label: '退出' }
|
|
|
],
|
|
],
|
|
|
questionList: [],
|
|
questionList: [],
|
|
|
- showIndex: 1
|
|
|
|
|
|
|
+ showIndex: 1,
|
|
|
|
|
+ userId
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
@@ -171,15 +170,12 @@ export default {
|
|
|
showIndex: {
|
|
showIndex: {
|
|
|
handler (val, oldVal) {
|
|
handler (val, oldVal) {
|
|
|
const temp = this.questionList[oldVal - 1]
|
|
const temp = this.questionList[oldVal - 1]
|
|
|
- if (temp.questionType === '填空题') {
|
|
|
|
|
|
|
+ if (['填空题'].includes(temp.questionType)) {
|
|
|
temp.answer = temp.options.map(item => item.answer)
|
|
temp.answer = temp.options.map(item => item.answer)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- created () {
|
|
|
|
|
- // this.getQuestionData()
|
|
|
|
|
- },
|
|
|
|
|
mounted () {
|
|
mounted () {
|
|
|
this.loadData()
|
|
this.loadData()
|
|
|
// 监听键盘事件
|
|
// 监听键盘事件
|
|
@@ -191,7 +187,7 @@ export default {
|
|
|
methods: {
|
|
methods: {
|
|
|
// 获取题库数据
|
|
// 获取题库数据
|
|
|
async loadData () {
|
|
async loadData () {
|
|
|
- if (!this.parentId) {
|
|
|
|
|
|
|
+ if (!this.paperId) {
|
|
|
this.$message.error('获取题目信息失败,请重试!')
|
|
this.$message.error('获取题目信息失败,请重试!')
|
|
|
this.closeDialog()
|
|
this.closeDialog()
|
|
|
return
|
|
return
|
|
@@ -218,7 +214,7 @@ export default {
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
getQuestionData () {
|
|
getQuestionData () {
|
|
|
- const sql = `select id_ as questionId, ti_gan_ as stem, ti_xing_ as questionType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as options, xuan_xiang_shu_ as optionsLength, fen_zhi_ as score, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, zheng_que_da_an_ as rightKey from t_questions where parent_id_ = '${this.parentId}' and zhuang_tai_ = '启用' order by field(ti_xing_, '单选题', '多选题', '判断题', '填空题', '简答题')`
|
|
|
|
|
|
|
+ const sql = `select id_ as questionId, ti_gan_ as stem, ti_xing_ as questionType, fu_tu_ as img, xuan_xiang_lei_xi as optionType, da_an_ as options, xuan_xiang_shu_ as optionsLength, fen_zhi_ as score, ping_fen_fang_shi as rateType, ping_fen_ren_ as rater, zheng_que_da_an_ as rightKey from t_questions where parent_id_ = '${this.paperId}' and zhuang_tai_ = '启用' order by field(ti_xing_, '单选题', '多选题', '判断题', '填空题', '简答题')`
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
this.$common.request('sql', sql).then(res => {
|
|
this.$common.request('sql', sql).then(res => {
|
|
|
const { data = [] } = res.variables || {}
|
|
const { data = [] } = res.variables || {}
|
|
@@ -244,7 +240,7 @@ export default {
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
item.img = item.img ? JSON.parse(item.img) : ''
|
|
item.img = item.img ? JSON.parse(item.img) : ''
|
|
|
- item.answer = null
|
|
|
|
|
|
|
+ item.answer = item.questionType === '多选题' ? [] : null
|
|
|
})
|
|
})
|
|
|
resolve(data)
|
|
resolve(data)
|
|
|
}).catch(error => {
|
|
}).catch(error => {
|
|
@@ -257,19 +253,27 @@ export default {
|
|
|
this.questionList.forEach(item => {
|
|
this.questionList.forEach(item => {
|
|
|
if (item.questionType === '填空题') {
|
|
if (item.questionType === '填空题') {
|
|
|
finished.push(item.answer && !item.answer.some(i => i === '' || i === null))
|
|
finished.push(item.answer && !item.answer.some(i => i === '' || i === null))
|
|
|
|
|
+ } else if (item.questionType === '多选题') {
|
|
|
|
|
+ finished.push(item.answer.some(i => i) && true)
|
|
|
} else {
|
|
} else {
|
|
|
- finished.push(item.answer && 1)
|
|
|
|
|
|
|
+ finished.push(item.answer && true)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
// const finished = this.questionList.filter(item => (item.questionType !== '填空题' && item.answer) || (item.questionType === '填空题' && item.answer && !item.answer.some(i => i === '' || i === null))).length
|
|
// 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 finishedCount = finished.filter(i => i).length
|
|
|
- return parseInt(finishedCount / this.questionList.length * 100)
|
|
|
|
|
|
|
+ const progress = parseFloat(finishedCount / this.questionList.length * 100)
|
|
|
|
|
+ return progress ? progress > 100 ? 100 : progress : 0
|
|
|
|
|
+ },
|
|
|
|
|
+ changeOptions (val) {
|
|
|
|
|
+ this.questionList[this.showIndex - 1].answer = val
|
|
|
},
|
|
},
|
|
|
setClassName (item, index) {
|
|
setClassName (item, index) {
|
|
|
const result = []
|
|
const result = []
|
|
|
if (item.answer) {
|
|
if (item.answer) {
|
|
|
// 填空题且未填写所有答案
|
|
// 填空题且未填写所有答案
|
|
|
- if (item.questionType === '填空题' && (item.options.every(i => !i.answer))) {
|
|
|
|
|
|
|
+ if (['填空题'].includes(item.questionType) && (item.options.every(i => !i.answer))) {
|
|
|
|
|
+ result.push('')
|
|
|
|
|
+ } else if (['多选题'].includes(item.questionType) && !item.answer.length) {
|
|
|
result.push('')
|
|
result.push('')
|
|
|
} else if (item.questionType === '填空题' && (item.options.some(i => !i.answer))) {
|
|
} else if (item.questionType === '填空题' && (item.options.some(i => !i.answer))) {
|
|
|
result.push('incomplete')
|
|
result.push('incomplete')
|
|
@@ -295,22 +299,32 @@ export default {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
this.showIndex++
|
|
this.showIndex++
|
|
|
|
|
+ } else if (event.keyCode === 27 || event.key === 'Esc') {
|
|
|
|
|
+ this.closeDialog()
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ goNext () {
|
|
|
|
|
+ if (this.showIndex === this.questionList.length) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this.showIndex++
|
|
|
|
|
+ },
|
|
|
getScore ({ questionType, answer, rightKey, score }) {
|
|
getScore ({ questionType, answer, rightKey, score }) {
|
|
|
if (questionType === '多选题') {
|
|
if (questionType === '多选题') {
|
|
|
- const temp = JSON.parse(rightKey)
|
|
|
|
|
|
|
+ const temp = rightKey.split(',')
|
|
|
return answer.length === temp.length && answer.every(i => temp.includes(i)) ? score : 0
|
|
return answer.length === temp.length && answer.every(i => temp.includes(i)) ? score : 0
|
|
|
} else {
|
|
} else {
|
|
|
return answer === rightKey ? score : 0
|
|
return answer === rightKey ? score : 0
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
handleSubmit () {
|
|
handleSubmit () {
|
|
|
- console.log(this.questionList)
|
|
|
|
|
let incompleteList = []
|
|
let incompleteList = []
|
|
|
this.questionList.forEach((item, index) => {
|
|
this.questionList.forEach((item, index) => {
|
|
|
if (item.questionType === '填空题') {
|
|
if (item.questionType === '填空题') {
|
|
|
- const t = item.answer && item.answer.some(i => i === '' || i === null)
|
|
|
|
|
|
|
+ const t = item.answer && !item.answer.some(i => i === '' || i === null)
|
|
|
|
|
+ incompleteList.push(!t ? index + 1 : '')
|
|
|
|
|
+ } else if (item.questionType === '多选题') {
|
|
|
|
|
+ const t = item.answer && item.answer.length
|
|
|
incompleteList.push(!t ? index + 1 : '')
|
|
incompleteList.push(!t ? index + 1 : '')
|
|
|
} else {
|
|
} else {
|
|
|
incompleteList.push(!item.answer ? index + 1 : '')
|
|
incompleteList.push(!item.answer ? index + 1 : '')
|
|
@@ -326,27 +340,31 @@ export default {
|
|
|
closeOnClickModal: false
|
|
closeOnClickModal: false
|
|
|
}).then(() => {
|
|
}).then(() => {
|
|
|
const submitData = []
|
|
const submitData = []
|
|
|
|
|
+ const time = this.$common.getDateNow(19)
|
|
|
this.questionList.forEach((item, index) => {
|
|
this.questionList.forEach((item, index) => {
|
|
|
const autoType = ['单选题', '多选题', '判断题'].includes(item.questionType)
|
|
const autoType = ['单选题', '多选题', '判断题'].includes(item.questionType)
|
|
|
const multipleType = ['多选题', '填空题'].includes(item.questionType)
|
|
const multipleType = ['多选题', '填空题'].includes(item.questionType)
|
|
|
|
|
+ const selectType = ['多选题', '单选题'].includes(item.questionType)
|
|
|
submitData.push({
|
|
submitData.push({
|
|
|
- parent_id_: this.parentId,
|
|
|
|
|
|
|
+ parent_id_: this.id,
|
|
|
ti_mu_id_: item.questionId,
|
|
ti_mu_id_: item.questionId,
|
|
|
ti_gan_: item.stem,
|
|
ti_gan_: item.stem,
|
|
|
ti_xing_: item.questionType,
|
|
ti_xing_: item.questionType,
|
|
|
fen_zhi_: item.score,
|
|
fen_zhi_: item.score,
|
|
|
fu_tu_: item.img,
|
|
fu_tu_: item.img,
|
|
|
xuan_xiang_lei_xi: item.optionType,
|
|
xuan_xiang_lei_xi: item.optionType,
|
|
|
- xuan_xiang_: item.options,
|
|
|
|
|
|
|
+ xuan_xiang_: selectType ? JSON.stringify(item.options) : '',
|
|
|
can_kao_da_an_: item.rightKey,
|
|
can_kao_da_an_: item.rightKey,
|
|
|
ping_fen_fang_shi: item.rateType,
|
|
ping_fen_fang_shi: item.rateType,
|
|
|
ping_fen_ren_: item.rater,
|
|
ping_fen_ren_: item.rater,
|
|
|
- hui_da_: multipleType ? JSON.stringify(item.answer) : item.answer,
|
|
|
|
|
|
|
+ hui_da_: multipleType && item.answer && item.answer.length ? JSON.stringify(item.answer) : item.answer,
|
|
|
shi_fou_yi_yue_: autoType ? '是' : '否',
|
|
shi_fou_yi_yue_: autoType ? '是' : '否',
|
|
|
|
|
+ ping_yue_shi_jian: autoType ? time : '',
|
|
|
de_fen_: autoType ? this.getScore(item) : '',
|
|
de_fen_: autoType ? this.getScore(item) : '',
|
|
|
jie_xi_: ''
|
|
jie_xi_: ''
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
+ // console.log(submitData)
|
|
|
this.submitForm(submitData)
|
|
this.submitForm(submitData)
|
|
|
}).catch(() => {})
|
|
}).catch(() => {})
|
|
|
},
|
|
},
|
|
@@ -355,6 +373,7 @@ export default {
|
|
|
tableName: 't_examination_detail',
|
|
tableName: 't_examination_detail',
|
|
|
paramWhere: data
|
|
paramWhere: data
|
|
|
}
|
|
}
|
|
|
|
|
+ const isAllReviewed = !data.some(i => i.shi_fou_yi_yue_ === '否')
|
|
|
const updateParams = {
|
|
const updateParams = {
|
|
|
tableName: 't_examination',
|
|
tableName: 't_examination',
|
|
|
updList: [
|
|
updList: [
|
|
@@ -364,8 +383,9 @@ export default {
|
|
|
},
|
|
},
|
|
|
param: {
|
|
param: {
|
|
|
jie_shu_shi_jian_: this.$common.getDateNow(19),
|
|
jie_shu_shi_jian_: this.$common.getDateNow(19),
|
|
|
- ti_ku_zong_fen_: data.reduce((sum, item) => sum + parseInt(item.fen_zhi_), 0),
|
|
|
|
|
- zhuang_tai_: '已完成',
|
|
|
|
|
|
|
+ ti_ku_zong_fen_: data.reduce((sum, item) => sum + parseFloat(item.fen_zhi_), 0),
|
|
|
|
|
+ zhuang_tai_: isAllReviewed ? '已完成' : '已交卷',
|
|
|
|
|
+ de_fen_: isAllReviewed ? data.reduce((sum, item) => sum + parseFloat(item.de_fen_), 0) : '',
|
|
|
// sheng_yu_shi_chan: ''
|
|
// sheng_yu_shi_chan: ''
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -394,7 +414,7 @@ export default {
|
|
|
width: 1080px;
|
|
width: 1080px;
|
|
|
margin: 0 auto;
|
|
margin: 0 auto;
|
|
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
|
- .el-radio {
|
|
|
|
|
|
|
+ .el-radio, .el-checkbox {
|
|
|
display: block;
|
|
display: block;
|
|
|
margin-bottom: 10px;
|
|
margin-bottom: 10px;
|
|
|
}
|
|
}
|
|
@@ -489,36 +509,6 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- // .active {
|
|
|
|
|
- // background-color: #409EFF;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #409EFF;
|
|
|
|
|
- // &:hover {
|
|
|
|
|
- // background-color: #66b1ff;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #66b1ff;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // .incomplete {
|
|
|
|
|
- // background-color: #E6A23C;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #E6A23C;
|
|
|
|
|
- // &:hover {
|
|
|
|
|
- // background-color: #E6A23C;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #E6A23C;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // .finished {
|
|
|
|
|
- // background-color: #67C23A;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #67C23A;
|
|
|
|
|
- // &:hover {
|
|
|
|
|
- // background-color: #85ce61;
|
|
|
|
|
- // color: #fff;
|
|
|
|
|
- // border-color: #85ce61;
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|