考试管理

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 {String} data.passScore 及格分
* @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) {
return request({
url: `/api/v2/paper/composition/`,
url: `/api/v2/paper/composition/${data.orgId}`,
method: 'POST',
data,
})
@ -167,10 +175,18 @@ export function createPaper(data) {
* @param {Number} data.validDuration 考试时长
* @param {String} data.passScore 及格分
* @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({
url: `/api/v2/paper/composition/basic`,
url: `/api/v2/paper/composition`,
method: 'PUT',
data,
})
@ -186,48 +202,15 @@ export function getPaperDetail(pcId) {
})
}
/**
* @param {Number} params.orgId
* @param {Number} params.subtype
* @param {Array<String>} params.tags
/**
* @param {Number} data.orgId
* @param {Number} data.subtype
* @param {Array<String>} data.tags
*/
export function getQuestionAmount(params) {
export function getQuestionAmount(data) {
return request({
url: ``,
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`,
url: `/api/v2/paper/${data.orgId}/question/count`,
method: 'POST',
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-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
v-for="item in types"
:key="item.value"
@ -18,7 +23,12 @@
</el-select>
</el-form-item>
<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
v-for="item in subtypes"
:key="item.value"
@ -27,17 +37,18 @@
></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="标签" prop="tags">
<el-select v-model="form.tags" disabled></el-select>
</el-form-item> -->
<el-form-item label="标签" prop="tags">
<el-select v-model="form.tags"></el-select>
</el-form-item>
<el-form-item label="题目数量" prop="amount">
<el-input-number
v-model="form.amount"
:precision="0"
:min="0"
:max="this.topicNum"
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
>
</el-form-item>
@ -53,6 +64,7 @@
</template>
<script>
import { getQuestionAmount } from '@/api/management/exam'
export default {
name: 'EditRule',
props: {},
@ -81,9 +93,9 @@ export default {
message(new Error(this.$t('publish.inputQuestionNumberError')))
} else if (!Number(value)) {
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')))
} */ else {
} else {
message()
}
}, 100)
@ -97,6 +109,7 @@ export default {
}
return {
form: {
id: '',
type: '',
subtype: '',
tags: [],
@ -113,7 +126,9 @@ export default {
},
}
},
created() {},
created() {
},
mounted() {},
methods: {
show(detail) {
@ -127,16 +142,30 @@ export default {
subtype: detail.subtype,
amount: detail.amount,
score: detail.score,
id: detail.id || '',
}
this.topicNum = detail.topicNum
} else {
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() {
this.$refs['form'].validate(valid => {
if (valid) {
this.$emit('submit', this.form, this.isEditMode)
this.$emit('submit', { ...this.form, topicNum: this.topicNum }, this.isEditMode)
this.handleCancel()
}
})

View File

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

View File

@ -22,9 +22,6 @@
<el-table-column prop="amount" label="题目数量" width="100">
<template slot-scope="scope">
<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>
</el-table-column>
<el-table-column prop="score" :label="$t('publish.eachScore')" width="100" />
@ -35,8 +32,7 @@
</el-table-column>
<el-table-column label="题库题数">
<template slot-scope="scope">
<!-- <span>{{ getTopicNum(scope.row) }}</span> -->
<span>N/A</span>
<span>{{ scope.row.topicNum }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('global.operate')" width="100">
@ -104,6 +100,7 @@ export default {
subtype: formData.subtype,
amount: formData.amount,
score: formData.score,
topicNum: formData.topicNum,
}
if (isEdit) {
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() {
console.log(this.currentTotalScore === this.examData.fullScore)
return this.currentTotalScore === this.examData.fullScore