yujialong 4 months ago
parent 87b03ed8b6
commit 016dd0a9ab
  1. 3
      src/pages/ques/detail/index.vue
  2. 276
      src/pages/testPaper/detail/index.vue
  3. 9
      src/pages/testPaper/detail/manual.vue
  4. 80
      src/pages/testPaper/detail/repeatQues.vue

@ -711,7 +711,8 @@ export default {
margin-bottom: 15px; margin-bottom: 15px;
} }
.el-radio { .el-radio,
.el-checkbox {
margin-right: 15px; margin-right: 15px;
} }

@ -310,6 +310,11 @@ export default {
detailType: '', detailType: '',
difficultSelected: false, difficultSelected: false,
repeatVisible: false,
repeatQues: [],
tempForm: {},
}; };
}, },
computed: { computed: {
@ -671,137 +676,186 @@ export default {
item.examQuestions.splice(i, 1) item.examQuestions.splice(i, 1)
this.calcDifficult() this.calcDifficult()
}, },
//
hasRepeatQues (list) {
const result = list.filter(e => {
if (e.questionType !== 'fill_blank' && e.questionType !== 'essay') {
// ++
const opts = e.questionAnswerVersionsList
//
const first = opts[0].optionText
const someOpt = opts.every(n => n.optionText === first)
return e.questionType === e.questionType && e.stem === e.stem && someOpt
} else {
// /+
return (e.questionType === e.questionType && e.stem === e.stem)
}
})
//
if (result.length) {
this.repeatVisible = true
this.repeatQues = result
return true
}
return false
},
//
submit (status) {
if (status) {
// 稿
if (!this.form.name) return Util.warningMsg('请输入试卷名称')
this.validForm(status)
} else {
this.$refs.form.validate(async (valid) => {
if (valid) {
this.validForm(status)
}
})
}
},
//
async saveTestPaper () {
try {
await this.$post(this.api.saveExamPaper, this.tempForm)
Util.successMsg('保存成功')
this.submiting = false
this.back()
} catch (e) {
this.submiting = false
}
},
// //
async submit (status) { async validForm (status) {
if (this.submiting) return false if (this.submiting) return false
this.$refs.form.validate(async (valid) => { const { isCopy } = this //
if (valid) { const form = _.cloneDeep(this.form)
const { isCopy } = this // const paper = form.paperOutline
const form = _.cloneDeep(this.form) const allQues = []
if (isNaN(form.suggestTime) || form.suggestTime < 1 || form.suggestTime % 1) return Util.warningMsg('估计用时请输入正整数')
const paper = form.paperOutline //
let invalid = 0 if (!status) {
for (const i in paper) { if (isNaN(form.suggestTime) || form.suggestTime < 1 || form.suggestTime % 1) return Util.warningMsg('估计用时请输入正整数')
const e = paper[i] let invalid = 0
if (!e.questionType) { for (const i in paper) {
Util.warningMsg('请选择题型') const e = paper[i]
invalid = 1 if (!e.questionType) {
break Util.warningMsg('请选择题型')
} invalid = 1
if (!e.questionNum) { break
Util.warningMsg('请输入目标题数') }
invalid = 1 if (!e.questionNum) {
break Util.warningMsg('请输入目标题数')
} invalid = 1
if (!e.targetScore) { break
Util.warningMsg('请输入目标分值') }
invalid = 1 if (!e.targetScore) {
break Util.warningMsg('请输入目标分值')
} invalid = 1
break
}
const chineseNum = this.arabicToChinese(+i + 1) const chineseNum = this.arabicToChinese(+i + 1)
// //
if (+e.questionNum !== e.examQuestions.length) { if (+e.questionNum !== e.examQuestions.length) {
Util.warningMsg(`${chineseNum}大题的小题总数跟目标题数不一致,请重新修改`) Util.warningMsg(`${chineseNum}大题的小题总数跟目标题数不一致,请重新修改`)
invalid = 1 invalid = 1
break break
} }
// //
if (e.questionType === 'fill_blank') { if (e.questionType === 'fill_blank') {
let totalScore = 0 let totalScore = 0
e.examQuestions.map(n => { e.examQuestions.map(n => {
const stem = document.querySelector(`#stem` + n.questionVersionId) const stem = document.querySelector(`#stem` + n.questionVersionId)
if (stem) { if (stem) {
const inputs = stem.querySelectorAll('.fill-input') const inputs = stem.querySelectorAll('.fill-input')
if (inputs) { if (inputs) {
for (const e of inputs) { for (const e of inputs) {
totalScore = Decimal(totalScore).add(e.value || 0).toNumber() totalScore = Decimal(totalScore).add(e.value || 0).toNumber()
}
} }
} }
})
if (+e.targetScore !== totalScore) {
Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`)
invalid = 1
break
} }
} else if (+e.targetScore !== e.examQuestions.reduce((e, j) => (e += +j.score), 0)) { })
//
if (+e.targetScore !== totalScore) {
Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`) Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`)
invalid = 1 invalid = 1
break break
} }
} else if (+e.targetScore !== e.examQuestions.reduce((e, j) => (e += +j.score), 0)) {
//
Util.warningMsg(`${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`)
invalid = 1
break
}
// //
if (e.examQuestions.some(e => !e.status || e.isDel)) { if (e.examQuestions.some(e => !e.status || e.isDel)) {
Util.warningMsg(`当前试卷存在已被删除或已被禁用的试题,请进行相应调整 `) Util.warningMsg(`当前试卷存在已被删除或已被禁用的试题,请进行相应调整 `)
invalid = 1 invalid = 1
break break
}
} }
if (invalid) return false allQues.push(...e.examQuestions)
}
if (invalid) return false
}
this.submiting = true this.submiting = true
form.particularYear = +(dayjs(form.particularYear).format('YYYY'))
form.libraryId = this.libraryId
form.questionCount = this.questionCount
form.remarks = this.$refs.remarks.getUEContent()
form.score = this.score
form.status = status
paper.map(e => { form.particularYear = +(dayjs(form.particularYear).format('YYYY'))
// id form.libraryId = this.libraryId
if (isCopy) { form.questionCount = this.questionCount
e.paperId = '' form.remarks = this.$refs.remarks.getUEContent()
e.outlineId = '' form.score = this.score
} form.status = status
e.targetScore = +e.targetScore
paper.map(e => {
e.examQuestions = e.examQuestions.map((n, j) => { // id
// if (isCopy) {
if (n.questionType === 'fill_blank') { e.paperId = ''
const stem = document.querySelector(`#stem` + n.questionVersionId) e.outlineId = ''
const scores = [] }
if (stem) { e.targetScore = +e.targetScore
const inputs = stem.querySelectorAll('.fill-input')
if (inputs) { e.examQuestions = e.examQuestions.map((n, j) => {
for (const e of inputs) { //
scores.push(e.value) if (n.questionType === 'fill_blank') {
} const stem = document.querySelector(`#stem` + n.questionVersionId)
} const scores = []
if (stem) {
const inputs = stem.querySelectorAll('.fill-input')
if (inputs) {
for (const e of inputs) {
scores.push(e.value)
} }
n.jsonText = JSON.stringify({
questionVersionId: n.questionVersionId,
scores
})
}
return {
questionVersionId: n.questionVersionId,
serialNumber: n.serialNumber,
score: +n.score,
jsonText: n.jsonText,
paperId: !isCopy && this.paperId || '',
outlineId: !isCopy && e.outlineId || '',
} }
}
n.jsonText = JSON.stringify({
questionVersionId: n.questionVersionId,
scores
}) })
})
if (typeof form.classificationId === 'object') form.classificationId = form.classificationId[form.classificationId.length - 1]
form.questionType = [...new Set(paper.map(e => e.questionType))].join('、') //
form.createSource = 1
if (isCopy) form.paperId = ''
// debugger
try {
await this.$post(this.api.saveExamPaper, form)
Util.successMsg('保存成功')
this.submiting = false
this.back()
} catch (e) {
this.submiting = false
} }
} return {
questionVersionId: n.questionVersionId,
serialNumber: n.serialNumber,
score: +n.score,
jsonText: n.jsonText,
paperId: !isCopy && this.paperId || '',
outlineId: !isCopy && e.outlineId || '',
}
})
}) })
if (typeof form.classificationId === 'object') form.classificationId = form.classificationId[form.classificationId.length - 1]
form.questionType = [...new Set(paper.map(e => e.questionType))].join('、') //
form.createSource = 1
if (isCopy) form.paperId = ''
this.tempForm = form
// debugger
// if (this.hasRepeatQues(allQues)) return false
this.saveTestPaper()
}, },
// //
back () { back () {

@ -27,7 +27,7 @@
</div> </div>
<!-- 题目 --> <!-- 题目 -->
<div class="item"> <div class="item">
<p class="total">单选题{{ ques.length }}道题</p> <p class="total">{{ questionTypeName }}{{ ques.length }}道题</p>
<div class="ques"> <div class="ques">
<div class="line"> <div class="line">
<el-checkbox v-model="quesAllCheck" @change="quesAllCheckChange"></el-checkbox> <el-checkbox v-model="quesAllCheck" @change="quesAllCheckChange"></el-checkbox>
@ -125,6 +125,10 @@ export default {
checkedLen () { checkedLen () {
return this.curCheckQues.length + this.checked.length return this.curCheckQues.length + this.checked.length
}, },
// name
questionTypeName () {
return this.questionType ? QuesConst.questionTypes.find(e => e.id === this.questionType).name : ''
},
// //
diaTitle () { diaTitle () {
const { curQuesIndex, curQues } = this.$parent const { curQuesIndex, curQues } = this.$parent
@ -391,8 +395,7 @@ export default {
.line { .line {
display: flex; display: flex;
align-items: center; margin: 8px 0;
margin: 5px 0;
} }
.serial { .serial {

@ -0,0 +1,80 @@
<template>
<el-dialog title="提示" :visible.sync="listVisible" width="800px" :close-on-click-modal="false">
<el-alert title="以下试题在试卷中疑似出现重复,是否要继续发布!" type="warning" effect="dark" :closable="false">
</el-alert>
<el-table class="m-t-10" :data="list" stripe header-align="center" row-key="id">
<el-table-column prop="name" label="大题名称" align="center" width="90"></el-table-column>
<el-table-column prop="name" label="题号" align="center" width="60"></el-table-column>
<el-table-column prop="stem" label="题干" align="center" min-width="120" show-overflow-tooltip></el-table-column>
<el-table-column label="操作" align="center" width="240">
<template slot-scope="scope">
<el-button type="text">详情</el-button>
<el-button type="text">移除</el-button>
<el-button type="text">替换</el-button>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="check">检查一下</el-button>
<el-button @click="submit">继续发布</el-button>
</span>
</el-dialog>
</template>
<script>
import Setting from '@/setting'
import Util from '@/libs/util'
import _ from 'lodash'
export default {
props: ['visible', 'list'],
data () {
return {
listVisible: false,
// list: [],
submiting: false,
};
},
watch: {
visible () {
this.listVisible = this.visible
this.visible && this.init()
}
},
mounted () {
},
methods: {
init () {
},
//
async getList () {
try {
const res = await this.$post(this.api.examPaperTemplateList, {
pageNum: this.page,
pageSize: this.pageSize,
...this.filter
})
this.list = res.pageList.records
this.total = res.pageList.total
} catch (e) { }
},
//
async check () {
this.listVisible = false
},
//
async submit () {
if (this.submiting) return false
this.submiting = true
this.$parent.saveTestPaper()
},
//
closeDia () {
this.$emit('update:visible', false)
}
}
};
</script>
<style lang="scss" scoped></style>
Loading…
Cancel
Save