考试管理

This commit is contained in:
Yuan 2022-10-17 14:29:21 +08:00
parent 5e634f08f8
commit e6ae8750da
4 changed files with 87 additions and 87 deletions

View File

@ -148,10 +148,18 @@ export function getPapaerListOfOrg({ orgId, ...data }) {
* @param {Number} data.validDuration 考试时长 * @param {Number} data.validDuration 考试时长
* @param {String} data.passScore 及格分 * @param {String} data.passScore 及格分
* @param {String} data.fullScore 满分 * @param {String} data.fullScore 满分
* @param {Object} data.ruleList 规则列表
* @param {Object} data.ruleList.id 规则id
* @param {Object} data.ruleList.pcId 试卷蓝图ID
* @param {Object} data.ruleList.type 试题类型
* @param {Object} data.ruleList.subtype 规则类型
* @param {Object} data.ruleList.tags 标签
* @param {Object} data.ruleList.amount 数量
* @param {Object} data.ruleList.score 每题分值
*/ */
export function createPaper(data) { export function createPaper(data) {
return request({ return request({
url: `/api/v2/paper/composition/`, url: `/api/v2/paper/composition/${data.orgId}`,
method: 'POST', method: 'POST',
data, data,
}) })
@ -167,10 +175,18 @@ export function createPaper(data) {
* @param {Number} data.validDuration 考试时长 * @param {Number} data.validDuration 考试时长
* @param {String} data.passScore 及格分 * @param {String} data.passScore 及格分
* @param {String} data.fullScore 满分 * @param {String} data.fullScore 满分
* @param {Object} data.ruleList 规则列表
* @param {Object} data.ruleList.id 规则id
* @param {Object} data.ruleList.pcId 试卷蓝图ID
* @param {Object} data.ruleList.type 试题类型
* @param {Object} data.ruleList.subtype 规则类型
* @param {Object} data.ruleList.tags 标签
* @param {Object} data.ruleList.amount 数量
* @param {Object} data.ruleList.score 每题分值
*/ */
export function editPaperBasic(data) { export function editPaper(data) {
return request({ return request({
url: `/api/v2/paper/composition/basic`, url: `/api/v2/paper/composition`,
method: 'PUT', method: 'PUT',
data, data,
}) })
@ -186,48 +202,15 @@ export function getPaperDetail(pcId) {
}) })
} }
/** /**
* @param {Number} params.orgId * @param {Number} data.orgId
* @param {Number} params.subtype * @param {Number} data.subtype
* @param {Array<String>} params.tags * @param {Array<String>} data.tags
*/ */
export function getQuestionAmount(params) { export function getQuestionAmount(data) {
return request({ return request({
url: ``, url: `/api/v2/paper/${data.orgId}/question/count`,
method: 'GET',
params,
})
}
/**
* 试卷蓝图添加规则
* @param {Number} pcId 试卷蓝图ID
* @param {Number} type 试题类型(1-理论题2-实训题)
* @param {Number} subtype 规则类型 (理论题(1-单选题2-多选题3-判断题);实训题(4-单操实训5-场景实训))
* @param {Number} score 每题分值
* @param {Number} amount 题目数量
*/
export function addPaperRule(data) {
return request({
url: `/api/v2/paper/composition/rule`,
method: 'POST', method: 'POST',
data, data,
}) })
} }
/**
* 更新(保存)试卷蓝图的规则
* @param {Number} id 规则ID
* @param {Number} pcId 试卷蓝图ID
* @param {Number} type 试题类型(1-理论题2-实训题)
* @param {Number} subtype 规则类型 (理论题(1-单选题2-多选题3-判断题);实训题(4-单操实训5-场景实训))
* @param {Number} score 每题分值
* @param {Number} amount 题目数量
*/
export function editPaperRule(data) {
return request({
url: `/api/v2/paper/composition/rule`,
method: 'PUT',
data,
})
}

View File

@ -8,7 +8,12 @@
> >
<el-form ref="form" :model="form" :rules="rules" label-width="140px"> <el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-form-item label="试题类型" prop="type"> <el-form-item label="试题类型" prop="type">
<el-select v-model="form.type" placeholder="请选择试题类型" style="width:240px;"> <el-select
v-model="form.type"
placeholder="请选择试题类型"
style="width:240px;"
@change="getQuestionAmount"
>
<el-option <el-option
v-for="item in types" v-for="item in types"
:key="item.value" :key="item.value"
@ -18,7 +23,12 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="规则类型" prop="subtype"> <el-form-item label="规则类型" prop="subtype">
<el-select v-model="form.subtype" placeholder="请选择规则类型" style="width:240px;"> <el-select
v-model="form.subtype"
placeholder="请选择规则类型"
style="width:240px;"
@change="getQuestionAmount"
>
<el-option <el-option
v-for="item in subtypes" v-for="item in subtypes"
:key="item.value" :key="item.value"
@ -27,17 +37,18 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="标签" prop="tags"> <el-form-item label="标签" prop="tags">
<el-select v-model="form.tags" disabled></el-select> <el-select v-model="form.tags"></el-select>
</el-form-item> --> </el-form-item>
<el-form-item label="题目数量" prop="amount"> <el-form-item label="题目数量" prop="amount">
<el-input-number <el-input-number
v-model="form.amount" v-model="form.amount"
:precision="0" :precision="0"
:min="0" :min="0"
:max="this.topicNum"
style="width: calc(100% - 280px); float: left; margin-right: 10px;" style="width: calc(100% - 280px); float: left; margin-right: 10px;"
/> />
<span style="width: 190px; float: left;" <span v-if="this.form.type === 1" style="width: 190px; float: left;"
>{{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }}</span >{{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }}</span
> >
</el-form-item> </el-form-item>
@ -53,6 +64,7 @@
</template> </template>
<script> <script>
import { getQuestionAmount } from '@/api/management/exam'
export default { export default {
name: 'EditRule', name: 'EditRule',
props: {}, props: {},
@ -81,9 +93,9 @@ export default {
message(new Error(this.$t('publish.inputQuestionNumberError'))) message(new Error(this.$t('publish.inputQuestionNumberError')))
} else if (!Number(value)) { } else if (!Number(value)) {
message(new Error(this.$t('publish.inputValidNumber'))) message(new Error(this.$t('publish.inputValidNumber')))
} /* else if (Number(value) > this.topicNum) { } else if (Number(value) > this.topicNum && this.form.type === 1) {
message(new Error(this.$t('publish.inputNumberError'))) message(new Error(this.$t('publish.inputNumberError')))
} */ else { } else {
message() message()
} }
}, 100) }, 100)
@ -97,6 +109,7 @@ export default {
} }
return { return {
form: { form: {
id: '',
type: '', type: '',
subtype: '', subtype: '',
tags: [], tags: [],
@ -113,7 +126,9 @@ export default {
}, },
} }
}, },
created() {}, created() {
},
mounted() {}, mounted() {},
methods: { methods: {
show(detail) { show(detail) {
@ -127,16 +142,30 @@ export default {
subtype: detail.subtype, subtype: detail.subtype,
amount: detail.amount, amount: detail.amount,
score: detail.score, score: detail.score,
id: detail.id || '',
} }
this.topicNum = detail.topicNum
} else { } else {
this.isEditMode = false this.isEditMode = false
} }
}) })
}, },
getQuestionAmount() {
if (!(this.form.type && this.form.subtype)) return
if (this.form.type === 2) return //
const param = {
orgId: this.$store.state.user.companyId,
groupType: this.form.type,
subType: this.form.subtype,
}
getQuestionAmount(param).then(resp => {
this.topicNum = resp.data
})
},
handleOk() { handleOk() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.$emit('submit', this.form, this.isEditMode) this.$emit('submit', { ...this.form, topicNum: this.topicNum }, this.isEditMode)
this.handleCancel() this.handleCancel()
} }
}) })

View File

@ -37,7 +37,7 @@ import ExamFrom from './examFrom'
import { getPaperDetail } from '@/api/management/exam' import { getPaperDetail } from '@/api/management/exam'
import { UrlConfig } from '@/scripts/ConstDic' import { UrlConfig } from '@/scripts/ConstDic'
import { createPaper, editPaperBasic, addPaperRule, editPaperRule } from '@/api/management/exam' import { createPaper, editPaper } from '@/api/management/exam'
export default { export default {
name: 'ExamRule', name: 'ExamRule',
@ -75,7 +75,7 @@ export default {
}, },
}, },
created() { created() {
if (this.$route.params.paperId != 0) { if (this.isEditMode) {
getPaperDetail(this.$route.params.paperId).then(res => { getPaperDetail(this.$route.params.paperId).then(res => {
this.examData = { this.examData = {
name: res.data.name, name: res.data.name,
@ -106,37 +106,33 @@ export default {
.catch(() => {}) .catch(() => {})
}, },
submit() { submit() {
console.log('step1 data: ', JSON.stringify(this.examData))
console.log('orgId:', this.orgId)
console.log('isEditMode:', this.isEditMode)
console.log('ruleList:', JSON.stringify(this.ruleList))
const examData = { ...this.examData, ...{ orgId: this.orgId } }
const ruleData = this.ruleList
const scoreValid = this.$refs.rule.checkTotolScores() const scoreValid = this.$refs.rule.checkTotolScores()
if (!scoreValid) { if (!scoreValid) {
this.$message.warning('规则满分与试题定义不匹配') this.$message.warning('规则满分与试题定义不匹配')
return return
} }
const examData = { ...this.examData, ...{ orgId: this.orgId } }
const ruleData = this.ruleList
const uploadData = { ...examData, ruleList: ruleData }
console.log(JSON.stringify(uploadData))
const uploadMethodMap = { const uploadMethodMap = {
add: { add: createPaper,
exam: createPaper, edit: editPaper,
rules: addPaperRule,
},
edit: {
exam: editPaperBasic,
rules: editPaperRule,
},
} }
if (!this.isEditMode) { if (this.isEditMode) {
uploadMethodMap.add.exam(examData).then(res => { uploadData.id = this.$route.params.paperId
uploadMethodMap.add.rules() }
})
uploadMethodMap[this.$route.params.mode](uploadData).then(resp => {
if (resp.code === 200) {
this.$message.success(`${this.isEditMode ? '修改' : '创建'}成功`)
this.turnback()
} else { } else {
uploadMethodMap.edit.exam({ ...examData, id: this.$route.params.paperId }).then(res => { this.$message.error(resp.message)
uploadMethodMap.edit.rules() console.log(uploadData)
}) console.log(resp)
} }
})
}, },
turnback() { turnback() {
const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}` const path = `${this.$route.path.match(/(\/.*)\/examRule/)[1]}${UrlConfig.examRuleManage}`

View File

@ -22,9 +22,6 @@
<el-table-column prop="amount" label="题目数量" width="100"> <el-table-column prop="amount" label="题目数量" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.amount }}</span> <span>{{ scope.row.amount }}</span>
<!-- <el-tooltip v-if="checkNum(scope.row)" effect="dark" content="题库数量不足" placement="top">
<i class="el-icon-warning-outline"></i>
</el-tooltip> -->
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="score" :label="$t('publish.eachScore')" width="100" /> <el-table-column prop="score" :label="$t('publish.eachScore')" width="100" />
@ -35,8 +32,7 @@
</el-table-column> </el-table-column>
<el-table-column label="题库题数"> <el-table-column label="题库题数">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <span>{{ getTopicNum(scope.row) }}</span> --> <span>{{ scope.row.topicNum }}</span>
<span>N/A</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('global.operate')" width="100"> <el-table-column :label="$t('global.operate')" width="100">
@ -104,6 +100,7 @@ export default {
subtype: formData.subtype, subtype: formData.subtype,
amount: formData.amount, amount: formData.amount,
score: formData.score, score: formData.score,
topicNum: formData.topicNum,
} }
if (isEdit) { if (isEdit) {
this.$set(this.ruleList, this.editingIndex, data) this.$set(this.ruleList, this.editingIndex, data)
@ -138,11 +135,6 @@ export default {
}) })
}) })
}, },
getTopicNum(row) {
return this.operationTypeNums[row.trainingType]
? this.operationTypeNums[row.trainingType][row.operateType] || 0
: 0
},
checkTotolScores() { checkTotolScores() {
console.log(this.currentTotalScore === this.examData.fullScore) console.log(this.currentTotalScore === this.examData.fullScore)
return this.currentTotalScore === this.examData.fullScore return this.currentTotalScore === this.examData.fullScore