理论题目管理调整

This commit is contained in:
dong 2022-10-13 18:14:56 +08:00
parent 8ceca6ba90
commit 3554c6c3c5
8 changed files with 166 additions and 104 deletions

View File

@ -3,16 +3,26 @@ import request from '@/utils/request';
// 分页查询理论试题
export function listQuestionPage(params) {
return request({
url: `/api/questionBank/questions/paging`,
// url: `/api/questionBank/questions/paging`,
url: `/api/question/org/paging`,
method: 'get',
params
});
}
// 标签列表
export function getLableList() {
return request({
url: `/api/question/org/lable`,
method: 'get'
});
}
// 创建题目
export function createQuestion(data) {
return request({
url: `/api/questionBank/questions`,
// url: `/api/questionBank/questions`,
url: `/api/question/org`,
method: 'post',
data
});
@ -21,15 +31,18 @@ export function createQuestion(data) {
// 删除题目
export function deleteQuestion(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}`,
method: 'delete'
// url: `/api/questionBank/questions/${questionId}`,
url: `/api/question/org`,
method: 'delete',
data: [questionId]
});
}
// 更新题目
export function updateOption(data) {
return request({
url: `/api/questionBank/questions/${data.id}`,
// url: `/api/questionBank/questions/${data.id}`,
url: `/api/question/org/${data.id}`,
method: 'put',
data
});
@ -38,8 +51,17 @@ export function updateOption(data) {
// 获取题目信息
export function getQuestionInfo(questionId) {
return request({
url: `/api/questionBank/questions/${questionId}`,
// url: `/api/questionBank/questions/${questionId}`,
url: `/api/question/org/${questionId}`,
method: 'get'
});
}
// 题库批量导入
export function importQuestion(data) {
return request({
url: `/api/question/org/import`,
method: 'post',
data
});
}

View File

@ -1618,16 +1618,6 @@ export const asyncRouter = [
path: 'examManage',
component: OrgExamManage,
hidden: true
},
{
path: 'questionCreate',
component: QuestionCreatePage,
hidden: true
},
{
path: 'questionUpdate/:questionId',
component: QuestionUpdatePage,
hidden: true
}
]
},
@ -1641,6 +1631,11 @@ export const asyncRouter = [
component: QuestionUpdatePage,
hidden: true
},
{ // 理论题目管理-导入
path: 'preTheoryImport',
component: PreTheoryImport,
hidden: true
},
{ // 出题规则管理
path: 'questionsRuleManage',
hidden: true,

View File

@ -28,7 +28,7 @@ export default {
queryForm: {
reset: true,
labelWidth: '80px',
leftSpan: 16,
leftSpan: 17,
queryObject: {
type: {
type: 'select',
@ -40,14 +40,14 @@ export default {
topic: {
type: 'text',
label: '题 目'
},
companyId: {
type: 'select',
label: '单位',
config: {
data: []
}
}
// companyId: {
// type: 'select',
// label: '',
// config: {
// data: []
// }
// }
}
},
queryList: {
@ -59,6 +59,16 @@ export default {
title: '题 目',
prop: 'topic'
},
{
title: '标 签',
prop: 'tags',
type: 'tagMore',
width: '200',
columnValue: (row) => { return this.lableTags(row); },
tagType: (row) => {
return '';
}
},
{
title: '类 型',
prop: 'type',
@ -84,7 +94,7 @@ export default {
prop: 'companyId',
width: '100',
type: 'tag',
columnValue: (row) => { return this.getCompanyName(row.companyId); },
columnValue: (row) => { return this.getCompanyName(row.orgId); },
tagType: (row) => { return ''; }
},
{
@ -112,7 +122,7 @@ export default {
actions: [
{ text: '添 加', handler: this.doCreate },
{ text: '导 入', fileType: 'file', handler: this.importQuestionBank },
{ text: '试卷规则管理', handler: this.questionsRuleManage},
// { text: '', handler: this.questionsRuleManage},
{ text: '模板导出', handler: this.exportTemplate}
]
}
@ -127,7 +137,7 @@ export default {
this.companyList = [];
getCompanyList().then(resp => {
resp.data.forEach(item => {
this.queryForm.queryObject.companyId.config.data.push({ value: item.id, label: item.name });
// this.queryForm.queryObject.companyId.config.data.push({ value: item.id, label: item.name });
this.companyMap[item.id] = item.name;
});
});
@ -163,6 +173,10 @@ export default {
this.$refs.detail.doShow({index, row});
},
lableTags(row) {
return row.tags ? row.tags.split(',') : '';
},
answerTags(row) {
const answer = [];
row.optionList.forEach((el, i) => {
@ -228,26 +242,29 @@ export default {
const dataList = convertSheetToList(wb.Sheets[index], true);
let questionTypeIndex;
let topicIndex;
let tagsIndex;
let option1Index;
let option2Index;
let option3Index;
let option4Index;
let answerIndex;
dataList.forEach((item, index) => {
dataList.forEach((item, ii) => {
if (item[0] === '题型') {
questionTypeIndex = index;
questionTypeIndex = ii;
} else if (item[0] === '题目') {
topicIndex = index;
topicIndex = ii;
} else if (item[0] === '标签') {
tagsIndex = ii;
} else if ( item[0] === '选项' && item[1] === 'A') {
option1Index = index;
option1Index = ii;
} else if (!item[0] && item[1] === 'B') {
option2Index = index;
option2Index = ii;
} else if (!item[0] && item[1] === 'C') {
option3Index = index;
option3Index = ii;
} else if (!item[0] && item[1] === 'D') {
option4Index = index;
option4Index = ii;
} else if (item[0] === '答案') {
answerIndex = index;
answerIndex = ii;
}
});
if (questionTypeIndex || questionTypeIndex === 0) {
@ -256,6 +273,7 @@ export default {
const param = {
type: questionTypeMap[item],
topic: dataList[topicIndex][index],
tags: dataList[tagsIndex][index],
optionList: []
};
if (param.type === 'fill') {
@ -283,7 +301,7 @@ export default {
}
}
that.$store.dispatch('race/setPreTheoryData', questionList).then(() => {
that.$router.push({ path: `/system/preTheoryImport`});
that.$router.push({ path: `/teaching/preTheoryImport`});
}).catch((e) => {
that.$message.error('导入题库失败!');
});
@ -313,12 +331,12 @@ export default {
},
exportTemplate() {
const wb = XLSX.utils.book_new();
const data1 = [{A: '序号', B: '题型', C:'题目', D:'答案', E: '', F: '', G: '', H: ''}];
const data2 = [{A: '', B: '', C:'', D:'', E: 'A', F: 'B', G: 'C', H: 'D'}];
const data3 = [{A: '1', B: '判断', C:'题目一', D:'√', E: '', F: '', G: '', H: ''}];
const data4 = [{A: '2', B: '判断', C:'题目二', D:'×', E: '', F: '', G: '', H: ''}];
const data5 = [{A: '3', B: '单选', C:'题目三', D:'A', E: '选项A', F: '选项B', G: '选项C', H: '选项D'}];
const data6 = [{A: '4', B: '多选', C:'题目四', D:'ABCD', E: '选项A', F: '选项B', G: '选项C', H: '选项D'}];
const data1 = [{A: '序号', B: '题型', C:'题目', D:'标签', E:'答案', F: '选项', G: '', H: '', I: ''}];
const data2 = [{A: '', B: '', C:'', D:'', E: '', F: 'A', G: 'B', H: 'C', I: 'D'}];
const data3 = [{A: '1', B: '判断', C:'题目一', D:'信号机,道岔', E:'√', F: '', G: '', H: '', I: ''}];
const data4 = [{A: '2', B: '判断', C:'题目二', D:'重点', E:'×', F: '', G: '', H: '', I: ''}];
const data5 = [{A: '3', B: '单选', C:'题目三', D:'测试,检验', E:'A', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
const data6 = [{A: '4', B: '多选', C:'题目四', D:'', E:'ABCD', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
// const data7 = [{A: '5', B: '', C:'', D:'&&&&', E: '', F: '', G: '', H: ''}];
// const data8 = [{A: '6', B: '', C:'', D:'', E: '', F: '', G: '', H: ''}];
// const data = [...data1, ...data2, ...data3, ...data4, ...data5, ...data6, ...data7, ...data8];
@ -326,8 +344,8 @@ export default {
const ws = XLSX.utils.json_to_sheet(data, {skipHeader:true});
ws['!merges'] = [
{
s: {c: 4, r: 0},
e: {c: 7, r: 0}
s: {c: 5, r: 0},
e: {c: 8, r: 0}
},
{
s: {c: 0, r: 0},
@ -344,6 +362,10 @@ export default {
{
s: {c: 3, r: 0},
e: {c: 3, r: 1}
},
{
s: {c: 4, r: 0},
e: {c: 4, r: 1}
}
];
ws['!cols'] = [
@ -354,6 +376,7 @@ export default {
{width: 15},
{width: 15},
{width: 15},
{width: 15},
{width: 15}
];
XLSX.utils.book_append_sheet(wb, ws, 'file');

View File

@ -71,6 +71,7 @@ export default {
handler:function(newV, oldV) {
if (this.type === 'judge' || this.type === 'select') {
this.active = this.optionList.findIndex(ele => ele.correct);
this.$emit('change', this.active);
} else if (this.type === 'multi') {
this.activeList = [];
this.optionList.forEach((el, i) => {
@ -78,13 +79,16 @@ export default {
this.activeList.push(i);
}
});
this.$emit('change', this.activeList);
} else if (this.type === 'fill') {
this.answerList = [];
this.optionList.forEach(el => {
this.answerList.push(el.content);
});
this.$emit('change', this.answerList);
} else if (this.type === 'answer') {
this.answer = (this.optionList[0] || {content: ''}).content;
this.$emit('change', this.answer);
}
}
}

View File

@ -1,62 +1,38 @@
<template>
<div style="text-align: center;padding: 10px;">
<div style="margin-top: 10px;margin-bottom: 10px;display: flex;justify-content: space-between;">
<div style="display: inline-block;font-size: 14px;">
<!-- <div style="display: inline-block;font-size: 14px;">
<span>单位</span>
<el-select v-model="companyId" placeholder="请选择单位" clearable size="mini" style="margin-left: 10px;">
<el-option v-for="it in companyList" :key="it.id" :label="it.name" :value="it.id" />
</el-select>
</div>
</div> -->
<div style="display: inline-block;">
<el-button
v-loading="loading"
size="mini"
type="primary"
@click="doSave"
>保存</el-button>
<el-button
size="mini"
type="danger"
@click="doCancel"
>取消</el-button>
<el-button v-loading="loading" size="mini" type="primary" @click="doSave">保存</el-button>
<el-button size="mini" type="danger" @click="doCancel">取消</el-button>
</div>
</div>
<el-table
:data="tableData"
border
style="width: 100%"
>
<el-table-column
prop="topic"
label="题目"
/>
<el-table-column prop="type" label="类型" width="100">
<el-table :data="tableData" border style="width: 100%">
<el-table-column prop="topic" label="题目" />
<el-table-column prop="tags" label="标签" width="200">
<template slot-scope="scope">
<el-tag
type="primary"
disable-transitions
>{{ $ConstSelect.translate(scope.row.type, 'QuestionTypeList') }}</el-tag>
<el-tag v-for="item in getTagesArr(scope.row.tags)" :key="item" type="primary" disable-transitions style="margin-right: 10px;">{{ item }}</el-tag>
</template>
</el-table-column>
<el-table-column
prop="answer"
label="答案"
>
<el-table-column prop="type" label="类型" width="100">
<template slot-scope="scope">
<el-tag type="primary" disable-transitions>{{ $ConstSelect.translate(scope.row.type, 'QuestionTypeList') }}</el-tag>
</template>
</el-table-column>
<el-table-column prop="answer" label="答案">
<template slot-scope="scope">
<el-tag v-for="(answer, index) in answerTags(scope.row)" :key="index" type="primary" style="margin-right: 10px;">{{ answer }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<el-button
size="mini"
@click="edit(scope.$index, scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="danger"
@click="doDelete(scope.$index, scope.row)"
>删除</el-button>
<el-button size="mini" @click="edit(scope.$index, scope.row)">编辑</el-button>
<el-button size="mini" type="danger" @click="doDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
@ -73,9 +49,10 @@
</template>
<script>
import { UrlConfig } from '@/scripts/ConstDic';
import { importQuestionBand } from '@/api/race';
import { getCompanyList } from '@/api/company';
// import { UrlConfig } from '@/scripts/ConstDic';
// import { importQuestionBand } from '@/api/race';
import { importQuestion } from '@/api/questionBank.js';
// import { getCompanyList } from '@/api/company';
export default {
data() {
return {
@ -98,14 +75,18 @@ export default {
mounted() {
this.handlePreDataPaging();
this.loading = false;
getCompanyList().then(resp => {
this.companyList = resp.data;
});
// getCompanyList().then(resp => {
// this.companyList = resp.data;
// });
},
methods: {
getTagesArr(tags) {
return tags ? tags.split(',') : '';
},
edit(index, row) {
const number = (this.currentPage - 1) * this.pageSize + index;
this.$router.push({path: `${UrlConfig.bank.questionUpdate}/${number}`, query:{ draft: true }});
// this.$router.push({path: `${UrlConfig.bank.questionUpdate}/${number}`, query:{ draft: true }});
this.$router.push({path: `/teaching/questionUpdate/${number}`, query:{ draft: true }});
},
handlePreDataPaging() {
const preData = this.$store.state.race.preTheoryData;
@ -193,7 +174,8 @@ export default {
break;
}
});
importQuestionBand(this.$store.state.race.preTheoryData, this.companyId).then(resp => {
// importQuestionBand(this.$store.state.race.preTheoryData, this.companyId).then(resp => {
importQuestion(this.$store.state.race.preTheoryData).then(resp => {
this.$store.dispatch('race/setPreTheoryData', []);
// this.$message.success('!');
this.$alert(`<strong>本次导入:</strong><br><strong>${judgeNum}道判断题;</strong><br><strong>${selectNum}道选择题;</strong><br><strong>${multiNum}道多选题;</strong><br>`, '导入题库成功!', {

View File

@ -2,7 +2,7 @@
<div class="page">
<div class="page__container">
<el-card class="page__container-body">
<question-form ref="info" :option="formModel" :remove="true" @modify="doModify" @companyIdChange="companyIdChange" />
<question-form ref="info" :option="formModel" :remove="true" @modify="doModify" @companyIdChange="companyIdChange" @tagsChange="tagsChange" />
</el-card>
<div class="page__container-footer">
<el-button type="primary" :is-create="true" @click="create"> </el-button>
@ -31,10 +31,12 @@ export default {
id: '',
topic: '',
type: 'select',
answer: 0,
tags: '',
answer: '',
optionList: []
},
companyId: null
companyId: null,
tagsArr: []
};
},
computed: {
@ -62,10 +64,14 @@ export default {
companyIdChange(value) {
this.companyId = value;
},
tagsChange(list) {
this.tagsArr = list;
},
create() {
this.$refs.info.validate().then(valid => {
if (valid) {
this.formModel.companyId = parseInt(this.companyId);
// this.formModel.companyId = parseInt(this.companyId);
this.formModel.tags = this.tagsArr.join(',');
createQuestion(this.formModel).then(resp => {
authUtils.setSessionStorage(this.path, JSON.stringify({
type: this.formModel.type

View File

@ -11,6 +11,11 @@
<el-option v-for="it in QuestionTypeList" :key="it.value" :label="it.label" :value="it.value" />
</el-select>
</el-form-item>
<el-form-item label="标 签">
<el-select v-model="tagsArr" multiple filterable allow-create default-first-option placeholder="请选择标签" @change="tagsChange">
<el-option v-for="item in labelList" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="问 题" prop="topic">
<item-rich v-model="option.topic" @modify="onModify({model: option, prop: 'topic'})" />
</el-form-item>
@ -32,6 +37,7 @@ import ItemOptions from './item-options';
import ItemAnswer from './item-answer';
import { getCompanyList } from '@/api/company';
import { getSessionStorage } from '@/utils/auth';
import { getLableList } from '@/api/questionBank.js';
export default {
components: {
@ -60,7 +66,9 @@ export default {
data() {
return {
companyList: [],
companyId: null
companyId: null,
tagsArr: [],
labelList: []
};
},
computed: {
@ -111,7 +119,7 @@ export default {
return this.option.optionList;
},
QuestionTypeList() {
return this.$ConstSelect.QuestionTypeList;
return this.$ConstSelect.QuestionTypeList.filter(item => { return !['fill', 'answer'].includes(item.value); });
},
rules() {
return {
@ -119,10 +127,10 @@ export default {
{ required: true, message: '请输入试题内容', trigger: 'blur' }
],
type: [
{ required: true, message: '请输入试题类型', trigger: 'change' }
{ required: true, message: '请输入试题类型', trigger: 'blur' }
],
answer: [
{ required: true, message: '请选择正确答案', trigger: 'change' }
{ required: true, message: '请选择正确答案', trigger: 'blur' }
]
};
}
@ -133,6 +141,12 @@ export default {
this.companyList = resp.data;
});
},
created() {
getLableList().then(res => {
this.labelList = res.data || [];
}).catch(err => {
});
},
methods: {
validate() {
return new Promise((resolve, reject) => {
@ -144,6 +158,9 @@ export default {
companyIdChange(e) {
this.$emit('companyIdChange', e);
},
tagsChange(list) {
this.$emit('tagsChange', list);
},
onTypeChnage(type) {
if (this.templateMap[type] && !this.update) {
this.option.optionList = this.templateMap[type]();
@ -171,6 +188,11 @@ export default {
this.option.optionList[0] = {content: answer, correct:true};
}
}
if (Array.isArray(answer)) {
this.option.answer = answer.join(',');
} else {
this.option.answer = answer + '';
}
},
onModify(node) {
this.$emit('modify', node);

View File

@ -2,7 +2,7 @@
<div class="page">
<div class="page__container">
<el-card class="page__container-body">
<question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" @companyIdChange="companyIdChange" />
<question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" @companyIdChange="companyIdChange" @tagsChange="tagsChange" />
</el-card>
</div>
<div class="page__container-footer">
@ -30,10 +30,12 @@ export default {
id: '',
topic: '',
type: 'select',
answer: 0,
tags: '',
answer: '',
optionList: []
},
optionList: []
optionList: [],
tagsArr: []
};
},
computed: {
@ -55,11 +57,13 @@ export default {
setTimeout(() => {
this.formModel = deepAssign({}, this.$store.state.race.preTheoryData[this.questionId]);
this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
this.$refs.info.tagsArr = this.formModel.tags.split(',');
}, 500);
} else {
getQuestionInfo(this.questionId).then(resp => {
this.formModel = resp.data;
this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
this.$refs.info.tagsArr = this.formModel.tags.split(',');
});
}
},
@ -69,6 +73,9 @@ export default {
companyIdChange(value) {
this.companyId = value;
},
tagsChange(list) {
this.tagsArr = list;
},
doModify(node) {
this.$refs.rich.doShow(node);
},
@ -78,7 +85,8 @@ export default {
this.$store.state.race.preTheoryData[this.questionId] = this.formModel;
this.doBack();
} else if (valid) {
this.formModel.companyId = parseInt(this.companyId);
// this.formModel.companyId = parseInt(this.companyId);
this.formModel.tags = this.tagsArr.join(',');
updateOption(this.formModel).then(resp => {
this.doBack();
}).catch(error => {