BUG:【教学管理】新建试卷时添加实训题,分类不正确。顺便把班级管理里的评价查询按钮去掉。

This commit is contained in:
fan 2022-12-30 13:21:37 +08:00
parent d4b05c8ed6
commit b97a155b24
3 changed files with 298 additions and 271 deletions

View File

@ -1,20 +1,20 @@
import request from '@/utils/request'
import request from '@/utils/request';
/** 创建对应课程考题 */
export function createExam(data) {
return request({
url: `/api/exam`,
method: 'post',
data: data,
})
data: data
});
}
/** 获取试卷详情 */
export function getExamLessonDetail(examId) {
return request({
url: `/api/exam/${examId}`,
method: 'get',
})
method: 'get'
});
}
/** 获取试卷列表 */
@ -22,32 +22,32 @@ export function getExamList(data) {
return request({
url: '/api/exam/list',
method: 'get',
params: data,
})
params: data
});
}
/** 删除试卷 */
export function deleteExam(data) {
return request({
url: `/api/exam/${data.id}`,
method: 'delete',
})
method: 'delete'
});
}
/** 设置试卷下架 */
export function setExamEfficacy(data) {
return request({
url: `/api/exam/${data.id}/offLine`,
method: 'put',
})
method: 'put'
});
}
/** 设置试卷上架 */
export function setExamEffectivey(data) {
return request({
url: `/api/exam/${data.id}/onLine`,
method: 'put',
})
method: 'put'
});
}
/** 更新考试规则*/
@ -55,62 +55,62 @@ export function updateExamRules(data) {
return request({
url: `/api/exam/${data.id}`,
method: 'put',
data: data,
})
data: data
});
}
/** 查询本项目下的考试列表 */
export function getExamListProject(params) {
return request({
url: `/api/exam/paged/loginProject`,
method: 'get',
params,
})
params
});
}
/** 查询本项目下的考试列表不分页 */
export function getExamListProjectUnpage(params) {
return request({
url: `/api/exam/list/loginProject`,
methods: 'get',
params,
})
params
});
}
/** 查询班级关联的自己创建的试卷 */
export function getExamListSelfByClassId(params) {
return request({
url: `/api/exam/list/org/self`,
method: 'get',
params,
})
params
});
}
/** 根据地图ID和prdType查询试卷列表 */
export function getExamListByMapIdAndPrdType(mapId, prdType) {
return request({
url: `/api/exam/list/${mapId}`,
method: 'get',
params: { prdType: prdType },
})
params: { prdType: prdType }
});
}
/** 更新试卷规则 */
export function updateExamRule(data) {
return request({
url: `/api/exam/update/rules`,
method: 'put',
data: data,
})
data: data
});
}
/** 检查并更新【规则数据异常】状态 */
export function checkAndUpdateAbnormal(mapId) {
return request({
url: `/api/exam/checkAndUpdateAbnormal/${mapId}`,
method: 'put',
})
method: 'put'
});
}
/** 重新生成考试规则 */
export function regenerateRule(mapId) {
return request({
url: `/api/exam/regenerateRules/${mapId}`,
method: 'put',
})
method: 'put'
});
}
/**
@ -135,8 +135,8 @@ export function getPapaerListOfOrg({ orgId, ...data }) {
return request({
url: `/api/v2/paper/composition/find/page/for/${orgId}`,
method: 'POST',
data,
})
data
});
}
export function getAllPapaerListOfOrg({ ...data }) {
@ -144,8 +144,8 @@ export function getAllPapaerListOfOrg({ ...data }) {
return request({
url: `/api/v2/paper/composition/manage/paging`,
method: 'POST',
data,
})
data
});
}
/**
@ -172,8 +172,8 @@ export function createPaper(data) {
return request({
url: `/api/v2/paper/composition/${data.orgId}`,
method: 'POST',
data,
})
data
});
}
/**
@ -200,8 +200,8 @@ export function editPaper(data) {
return request({
url: `/api/v2/paper/composition`,
method: 'PUT',
data,
})
data
});
}
/**
@ -210,8 +210,8 @@ export function editPaper(data) {
export function getPaperDetail(pcId) {
return request({
url: `/api/v2/paper/composition/${pcId}`,
method: 'GET',
})
method: 'GET'
});
}
/**
@ -224,8 +224,8 @@ export function getQuestionAmount(data) {
return request({
url: `/api/v2/paper/${data.orgId}/question/count`,
method: 'POST',
data,
})
data
});
}
/**
@ -234,8 +234,8 @@ export function getQuestionAmount(data) {
export function lockPaper(pcId) {
return request({
url: `/api/v2/paper/composition/${pcId}/lock`,
method: 'PUT',
})
method: 'PUT'
});
}
/**
@ -244,8 +244,8 @@ export function lockPaper(pcId) {
export function invalidPaper(pcId) {
return request({
url: `/api/v2/paper/composition/${pcId}/invalid`,
method: 'PUT',
})
method: 'PUT'
});
}
/**
@ -254,8 +254,8 @@ export function invalidPaper(pcId) {
export function deletePaper(pcId) {
return request({
url: `/api/v2/paper/composition/${pcId}`,
method: 'DELETE',
})
method: 'DELETE'
});
}
/**
@ -264,16 +264,16 @@ export function deletePaper(pcId) {
export function generateExam(pcId) {
return request({
url: `/api/v2/paper/${pcId}`,
method: 'POST',
})
method: 'POST'
});
}
/** 删除用户试卷 */
export function deleteUserExam(param) {
return request({
url: `/api/v2/paper/user/${puId}`,
method: 'method',
})
method: 'method'
});
}
/**
@ -282,16 +282,16 @@ export function deleteUserExam(param) {
export function getUserExamInfo(puId) {
return request({
url: `/api/v2/paper/user/${puId}`,
method: 'GET',
})
method: 'GET'
});
}
/** 加载用户试卷试题 */
export function loadQuestion({ type, questionId, puId }) {
return request({
url: `/api/v2/paper/user/question/${type}/${questionId}/${puId}`,
method: 'GET',
})
method: 'GET'
});
}
/**
@ -307,8 +307,8 @@ export function submitAnswer(data) {
return request({
url: `/api/v2/paper/user/question/answer`,
method: 'POST',
data,
})
data
});
}
/**
@ -317,8 +317,8 @@ export function submitAnswer(data) {
export function submitPaper(puId) {
return request({
url: `/api/v2/paper/user/${puId}/submit`,
method: 'POST',
})
method: 'POST'
});
}
/**
@ -328,6 +328,19 @@ export function queryPaperList(data) {
return request({
url: `/api/v2/paper/composition/find/list`,
method: 'POST',
data,
})
data
});
}
/**
* 获取标签分类
* @param {Number} ordId 组织id
* @param {Number} groupType 1-理论题 2-实训题
* @param {Number} subType 1-选择题 2-多选题 3-判断题 4-单操 5-场景
*/
export function queryTagList(data) {
return request({
url: `/api/v2/paper/question/label`,
method: 'POST',
data
});
}

View File

@ -82,11 +82,11 @@ export default {
handleClick: this.handleStudentDetail,
type: 'primary'
},
{
name: '评价查询',
handleClick: this.handleGradeCheck,
type: 'primary'
},
// {
// name: '',
// handleClick: this.handleGradeCheck,
// type: 'primary'
// },
{
name: '时长查看',
handleClick: this.handleDurationView,

View File

@ -1,219 +1,233 @@
<template>
<el-dialog
v-dialogDrag
:title="title"
:visible.sync="dialogShow"
:before-close="handleCancel"
:close-on-click-modal="false"
>
<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;" @change="clearSubtype">
<el-option
v-for="item in types"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="规则类型" prop="subtype">
<el-select
v-model="form.subtype"
placeholder="请选择规则类型"
style="width:240px;"
@change="getQuestionAmount"
>
<el-option
v-for="item in subtypes"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="分类" required>
<el-select v-model="form.tags" @change="getQuestionAmount">
<el-option
v-for="item in labels"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="题目数量" prop="amount">
<el-input-number
v-model="form.amount"
:min="0"
style="width: calc(100% - 280px); float: left; margin-right: 10px;"
/>
<span v-if="this.form.type === 1" style="width: 190px; float: left;">
{{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }}
</span>
</el-form-item>
<el-form-item :label="$t('publish.scorePerQuestion')" prop="score">
<el-input-number v-model="form.score" :precision="0" :min="0" style="width:200px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleCancel">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" @click="handleOk">{{ $t('global.confirm') }}</el-button>
</div>
</el-dialog>
<el-dialog
v-dialogDrag
:title="title"
:visible.sync="dialogShow"
:before-close="handleCancel"
:close-on-click-modal="false"
>
<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;" @change="clearSubtype">
<el-option
v-for="item in types"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="规则类型" prop="subtype">
<el-select
v-model="form.subtype"
placeholder="请选择规则类型"
style="width:240px;"
@change="subTypesChange"
>
<el-option
v-for="item in subtypes"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="分类" required>
<el-select v-model="form.tags" @change="getQuestionAmount">
<el-option
v-for="item in labels"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="题目数量" prop="amount">
<el-input-number
v-model="form.amount"
:min="0"
style="width: calc(100% - 280px); float: left; margin-right: 10px;"
/>
<span style="width: 190px; float: left;">
{{ $t('publish.allNumberTipOne') }} {{ topicNum }} {{ $t('publish.allNumberTipTwo') }}
</span>
</el-form-item>
<el-form-item :label="$t('publish.scorePerQuestion')" prop="score">
<el-input-number v-model="form.score" :precision="0" :min="0" style="width:200px" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="handleCancel">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" @click="handleOk">{{ $t('global.confirm') }}</el-button>
</div>
</el-dialog>
</template>
<script>
import { getQuestionAmount } from '@/api/management/exam'
import { getLabelList } from '@/api/questionBank'
import { getQuestionAmount, queryTagList } from '@/api/management/exam';
export default {
name: 'EditRule',
props: {
ruleList: {
type: Array,
},
},
computed: {
types() {
return [{ value: 1, label: '理论题' }, { value: 2, label: '实训题' }]
},
subtypes() {
const data = {
'1': [{ value: 1, label: '单选题' }, { value: 2, label: '多选题' }, { value: 3, label: '判断题' }],
'2': [{ value: 4, label: '单操实训' }, { value: 5, label: '场景实训' }],
}
return data[this.form.type]
},
title() {
return this.isEditMode ? this.$t('publish.modifyRules') : this.$t('publish.addRules')
},
},
data() {
var number = (rule, value, message) => {
if (!value) {
return message(new Error(this.$t('publish.inputQuestionNumber')))
}
setTimeout(() => {
if (Number(value) == 0) {
message(new Error(this.$t('publish.inputQuestionNumberError')))
} else if (!Number(value)) {
message(new Error(this.$t('publish.inputValidNumber')))
} else if (Number(value) > this.topicNum && this.form.type === 1) {
message(new Error(this.$t('publish.inputNumberError')))
} else {
message()
}
}, 100)
}
var score = (rule, value, message) => {
if (!value) {
return message(new Error(this.$t('publish.inputScorePerQuestion')))
} else {
message()
}
}
const tagsValidator = (rule, value, message) => {
message()
}
return {
form: {
id: '',
type: '',
subtype: '',
tags: '',
amount: 1,
score: 1,
},
labels: [],
topicNum: 0,
index: -1,
dialogShow: false,
rules: {
type: [{ required: true, message: this.$t('publish.selectTestType'), trigger: 'change' }],
subtype: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
amount: [{ required: true, validator: number, trigger: 'blur' }],
score: [{ required: true, validator: score, trigger: 'blur' }],
tags: [{ validator: tagsValidator, trigger: 'blur' }],
},
}
},
created() {
getLabelList().then(resp => {
this.labels = [{ label: '无', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))]
})
},
mounted() {},
methods: {
show(detail) {
this.dialogShow = true
this.$nextTick(() => {
this.$refs.form.resetFields()
if (detail) {
this.isEditMode = true
this.index = detail.index
this.form = {
type: detail.type,
subtype: detail.subtype,
amount: detail.amount,
score: detail.score,
id: detail.id || '',
tags: detail.tags[0],
}
this.topicNum = detail.topicNum
} else {
this.isEditMode = false
}
})
},
isDuplicated() {
const isDuplicated =
name: 'EditRule',
props: {
ruleList: {
type: Array
}
},
data() {
var number = (rule, value, message) => {
if (!value) {
return message(new Error(this.$t('publish.inputQuestionNumber')));
}
setTimeout(() => {
if (Number(value) == 0) {
message(new Error(this.$t('publish.inputQuestionNumberError')));
} else if (!Number(value)) {
message(new Error(this.$t('publish.inputValidNumber')));
} else if (Number(value) > this.topicNum && this.form.type === 1) {
message(new Error(this.$t('publish.inputNumberError')));
} else {
message();
}
}, 100);
};
var score = (rule, value, message) => {
if (!value) {
return message(new Error(this.$t('publish.inputScorePerQuestion')));
} else {
message();
}
};
const tagsValidator = (rule, value, message) => {
message();
};
return {
form: {
id: '',
type: '',
subtype: '',
tags: '',
amount: 1,
score: 1
},
labels: [],
topicNum: 0,
index: -1,
dialogShow: false,
rules: {
type: [{ required: true, message: this.$t('publish.selectTestType'), trigger: 'change' }],
subtype: [{ required: true, message: '请选择规则类型', trigger: 'change' }],
amount: [{ required: true, validator: number, trigger: 'blur' }],
score: [{ required: true, validator: score, trigger: 'blur' }],
tags: [{ validator: tagsValidator, trigger: 'blur' }]
}
};
},
computed: {
types() {
return [{ value: 1, label: '理论题' }, { value: 2, label: '实训题' }];
},
subtypes() {
const data = {
'1': [{ value: 1, label: '单选题' }, { value: 2, label: '多选题' }, { value: 3, label: '判断题' }],
'2': [{ value: 4, label: '单操实训' }, { value: 5, label: '场景实训' }]
};
return data[this.form.type];
},
title() {
return this.isEditMode ? this.$t('publish.modifyRules') : this.$t('publish.addRules');
}
},
created() {
// getLabelList().then(resp => {
// this.labels = [{ label: '', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))];
// });
},
mounted() {},
methods: {
show(detail) {
this.dialogShow = true;
this.$nextTick(() => {
this.$refs.form.resetFields();
if (detail) {
this.isEditMode = true;
this.index = detail.index;
this.form = {
type: detail.type,
subtype: detail.subtype,
amount: detail.amount,
score: detail.score,
id: detail.id || '',
tags: detail.tags[0]
};
this.topicNum = detail.topicNum;
} else {
this.isEditMode = false;
}
});
},
isDuplicated() {
const isDuplicated =
this.ruleList.length > 0 &&
this.ruleList.some(
rule =>
rule.type === this.form.type &&
rule =>
rule.type === this.form.type &&
rule.subtype === this.form.subtype &&
rule.tags &&
this.form.tags &&
rule.tags.includes(this.form.tags)
)
return isDuplicated
},
getQuestionAmount(e) {
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,
}
if (this.form.tags !== '') param.tags = this.form.tags
getQuestionAmount(param).then(resp => {
this.topicNum = resp.data
})
},
clearSubtype() {
this.form.subtype = ''
},
handleOk() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.ruleList.length > 0 && !this.isEditMode) {
if (this.isDuplicated()) {
this.$message.warning('与已有规则重复, 请重新选择')
return
}
}
this.$emit('submit', { ...this.form, topicNum: this.topicNum }, this.isEditMode)
this.handleCancel()
}
})
},
handleCancel() {
this.topicNum = 0
this.dialogShow = false
},
},
}
);
return isDuplicated;
},
subTypesChange(val) {
const param = {
orgId: this.$store.state.user.companyId,
groupType: this.form.type,
subType: this.form.subtype
};
this.form.tags = '';
queryTagList(param).then(resp => {
this.labels = [{ label: '无', value: '' }, ...resp.data.map(item => ({ label: item, value: item }))];
});
this.getQuestionAmount();
},
getQuestionAmount(e) {
if (!(this.form.type && this.form.subtype)) return;
const param = {
orgId: this.$store.state.user.companyId,
groupType: this.form.type,
subType: this.form.subtype
};
if (this.form.tags !== '') {
param.tags = this.form.tags;
}
getQuestionAmount(param).then(resp => {
this.topicNum = resp.data;
});
},
clearSubtype() {
this.form.subtype = '';
this.form.tags = '';
this.labels = [{ label: '无', value: '' }];
},
handleOk() {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.ruleList.length > 0 && !this.isEditMode) {
if (this.isDuplicated()) {
this.$message.warning('与已有规则重复, 请重新选择');
return;
}
}
this.$emit('submit', { ...this.form, topicNum: this.topicNum }, this.isEditMode);
this.handleCancel();
}
});
},
handleCancel() {
this.topicNum = 0;
this.dialogShow = false;
}
}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
/deep/ {