理论题目导入和导出功能
This commit is contained in:
parent
248661e0d7
commit
01f9a2abaa
@ -10,6 +10,14 @@ export function listQuestionPage(params) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询所有理论试题
|
||||||
|
export function listQuestionAll() {
|
||||||
|
return request({
|
||||||
|
url: `/api/question/org`,
|
||||||
|
method: 'get'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 标签列表
|
// 标签列表
|
||||||
export function getLabelList() {
|
export function getLabelList() {
|
||||||
return request({
|
return request({
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import { UrlConfig } from '@/scripts/ConstDic';
|
// import { UrlConfig } from '@/scripts/ConstDic';
|
||||||
import { listQuestionPage, deleteQuestion, getLabelList } from '@/api/questionBank.js';
|
import { listQuestionPage, deleteQuestion, getLabelList, listQuestionAll } from '@/api/questionBank.js';
|
||||||
import DialogDetail from './dialog-detail';
|
import DialogDetail from './dialog-detail';
|
||||||
import PreviewAnswer from './previewAnswer';
|
import PreviewAnswer from './previewAnswer';
|
||||||
import { convertSheetToList } from '@/jmapNew/theme/parser/util.js';
|
import { convertSheetToList } from '@/jmapNew/theme/parser/util.js';
|
||||||
@ -134,7 +134,7 @@ export default {
|
|||||||
{ text: '添 加', handler: this.doCreate },
|
{ text: '添 加', handler: this.doCreate },
|
||||||
{ text: '导 入', fileType: 'file', handler: this.importQuestionBank },
|
{ text: '导 入', fileType: 'file', handler: this.importQuestionBank },
|
||||||
// { text: '试卷规则管理', handler: this.questionsRuleManage},
|
// { text: '试卷规则管理', handler: this.questionsRuleManage},
|
||||||
{ text: '模板导出', handler: this.exportTemplate}
|
{ text: '导出', handler: this.exportTemplate}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -239,11 +239,11 @@ export default {
|
|||||||
},
|
},
|
||||||
handleImport(file) {
|
handleImport(file) {
|
||||||
const questionTypeMap = {
|
const questionTypeMap = {
|
||||||
'单选': 'select',
|
'单选题': 'select',
|
||||||
'多选': 'multi',
|
'多选题': 'multi',
|
||||||
'判断': 'judge',
|
'判断题': 'judge',
|
||||||
'填空': 'fill',
|
'填空题': 'fill',
|
||||||
'问答': 'answer'
|
'问答题': 'answer'
|
||||||
};
|
};
|
||||||
if (file) {
|
if (file) {
|
||||||
try {
|
try {
|
||||||
@ -274,29 +274,35 @@ export default {
|
|||||||
let option2Index;
|
let option2Index;
|
||||||
let option3Index;
|
let option3Index;
|
||||||
let option4Index;
|
let option4Index;
|
||||||
|
let option5Index;
|
||||||
|
let option6Index;
|
||||||
let answerIndex;
|
let answerIndex;
|
||||||
dataList.forEach((item, ii) => {
|
dataList.forEach((item, ii) => {
|
||||||
if (item[0] === '题型') {
|
if (!item[0] && !item[1] && item[2] === '题型(必填)') {
|
||||||
questionTypeIndex = ii;
|
questionTypeIndex = ii;
|
||||||
} else if (item[0] === '题目') {
|
} else if (!item[0] && !item[1] && item[2] === '题干(必填)') {
|
||||||
topicIndex = ii;
|
topicIndex = ii;
|
||||||
} else if (item[0] === '标签') {
|
} else if (!item[0] && !item[1] && item[2] === '标签') {
|
||||||
tagsIndex = ii;
|
tagsIndex = ii;
|
||||||
} else if ( item[0] === '选项' && item[1] === 'A') {
|
} else if (!item[0] && !item[1] && item[2] === '选项A(必填)') {
|
||||||
option1Index = ii;
|
option1Index = ii;
|
||||||
} else if (!item[0] && item[1] === 'B') {
|
} else if (!item[0] && !item[1] && item[2] === '选项B(必填)') {
|
||||||
option2Index = ii;
|
option2Index = ii;
|
||||||
} else if (!item[0] && item[1] === 'C') {
|
} else if (!item[0] && !item[1] && item[2] === '选项C') {
|
||||||
option3Index = ii;
|
option3Index = ii;
|
||||||
} else if (!item[0] && item[1] === 'D') {
|
} else if (!item[0] && !item[1] && item[2] === '选项D') {
|
||||||
option4Index = ii;
|
option4Index = ii;
|
||||||
} else if (item[0] === '答案') {
|
} else if (!item[0] && !item[1] && item[2] === '选项E') {
|
||||||
|
option5Index = ii;
|
||||||
|
} else if (!item[0] && !item[1] && item[2] === '选项F') {
|
||||||
|
option6Index = ii;
|
||||||
|
} else if (!item[0] && !item[1] && item[2] === '正确答案(必填)') {
|
||||||
answerIndex = ii;
|
answerIndex = ii;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (questionTypeIndex || questionTypeIndex === 0) {
|
if (questionTypeIndex || questionTypeIndex === 0) {
|
||||||
dataList[questionTypeIndex].forEach((item, index) => {
|
dataList[questionTypeIndex].forEach((item, index) => {
|
||||||
if (item && item !== '题型') {
|
if (item && item !== '题型(必填)') {
|
||||||
const param = {
|
const param = {
|
||||||
type: questionTypeMap[item],
|
type: questionTypeMap[item],
|
||||||
topic: dataList[topicIndex][index],
|
topic: dataList[topicIndex][index],
|
||||||
@ -320,6 +326,12 @@ export default {
|
|||||||
if (dataList[option4Index][index]) {
|
if (dataList[option4Index][index]) {
|
||||||
param.optionList.push({content:dataList[option4Index][index], correct: dataList[answerIndex][index].includes('D')});
|
param.optionList.push({content:dataList[option4Index][index], correct: dataList[answerIndex][index].includes('D')});
|
||||||
}
|
}
|
||||||
|
if (dataList[option5Index][index]) {
|
||||||
|
param.optionList.push({content:dataList[option5Index][index], correct: dataList[answerIndex][index].includes('E')});
|
||||||
|
}
|
||||||
|
if (dataList[option6Index][index]) {
|
||||||
|
param.optionList.push({content:dataList[option6Index][index], correct: dataList[answerIndex][index].includes('F')});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
param.id = questionList.length;
|
param.id = questionList.length;
|
||||||
questionList.push(param);
|
questionList.push(param);
|
||||||
@ -358,56 +370,117 @@ export default {
|
|||||||
},
|
},
|
||||||
exportTemplate() {
|
exportTemplate() {
|
||||||
const wb = XLSX.utils.book_new();
|
const wb = XLSX.utils.book_new();
|
||||||
const data1 = [{A: '序号', B: '题型', C:'题目', D:'标签', E:'答案', F: '选项', G: '', H: '', I: ''}];
|
const data1 = [{A: '理论试题导入模板', B: '', C:'', D:'', E:'', F: '', G: '', H: '', I: '', J: '', K: ''}];
|
||||||
const data2 = [{A: '', B: '', C:'', D:'', E: '', F: 'A', G: 'B', H: 'C', I: 'D'}];
|
const data2 = [{A: '说明:1、本表第一行(标示蓝色底内容)所对应的任何一列不能修改删除;\n 2、支持批量导入的题型:单选题,多选题,判断题,题型不能自定义,只能按照表格提供的进行录入;\n 3、【判断题】在选项A中可填写√ 或正确,选项B中填写× 或错误,答案填写A或B\n 4、【分类】多个分类项使用空格隔开', B: '', C:'', D:'', E:'', F: '', G: '', H: '', I: '', J: '', K: ''}];
|
||||||
const data3 = [{A: '1', B: '判断', C:'题目一', D:'信号机,道岔', E:'√', F: '', G: '', H: '', I: ''}];
|
const data3 = [{A: '序号', B: '题干(必填)', C:'题型(必填)', D:'选项A(必填)', E:'选项B(必填)', F: '选项C', G: '选项D', H: '选项E', I: '选项F', J: '正确答案(必填)', K: '标签'}];
|
||||||
const data4 = [{A: '2', B: '判断', C:'题目二', D:'重点', E:'×', F: '', G: '', H: '', I: ''}];
|
const data = [...data1, ...data2, ...data3];
|
||||||
const data5 = [{A: '3', B: '单选', C:'题目三', D:'测试,检验', E:'A', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
|
const mapType = {
|
||||||
const data6 = [{A: '4', B: '多选', C:'题目四', D:'', E:'ABCD', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
|
select: '单选题',
|
||||||
// const data7 = [{A: '5', B: '填空', C:'题目五', D:'第一空答案&&第二空答案&&第三空答案', E: '', F: '', G: '', H: ''}];
|
multi: '多选题',
|
||||||
// const data8 = [{A: '6', B: '问答', C:'题目六', D:'问答题答案', E: '', F: '', G: '', H: '问答题答案'}];
|
judge: '判断题',
|
||||||
// const data = [...data1, ...data2, ...data3, ...data4, ...data5, ...data6, ...data7, ...data8];
|
fill: '填空题',
|
||||||
const data = [...data1, ...data2, ...data3, ...data4, ...data5, ...data6];
|
answer: '问答题'
|
||||||
const ws = XLSX.utils.json_to_sheet(data, {skipHeader:true});
|
};
|
||||||
ws['!merges'] = [
|
listQuestionAll().then(res => {
|
||||||
{
|
console.log(res, '---res===');
|
||||||
s: {c: 5, r: 0},
|
res.data.forEach((item, index) => {
|
||||||
e: {c: 8, r: 0}
|
let as = item.answer;
|
||||||
},
|
const arr = ['select', 'multi', 'judge'];
|
||||||
{
|
if (arr.includes(item.type)) {
|
||||||
s: {c: 0, r: 0},
|
as = [];
|
||||||
e: {c: 0, r: 1}
|
item.optionList.forEach((it, ind) => {
|
||||||
},
|
if (it.correct) {
|
||||||
{
|
as.push(this.$asc2chart(ind + 65));
|
||||||
s: {c: 1, r: 0},
|
}
|
||||||
e: {c: 1, r: 1}
|
});
|
||||||
},
|
as = as.join(',');
|
||||||
{
|
}
|
||||||
s: {c: 2, r: 0},
|
const obj = {
|
||||||
e: {c: 2, r: 1}
|
A: index + 1,
|
||||||
},
|
B: item.topic,
|
||||||
{
|
C: mapType[item.type] || '',
|
||||||
s: {c: 3, r: 0},
|
D: item.optionList[0].content,
|
||||||
e: {c: 3, r: 1}
|
E: item.optionList[1].content,
|
||||||
},
|
F: item.optionList[2] ? item.optionList[2].content : '',
|
||||||
{
|
G: item.optionList[3] ? item.optionList[3].content : '',
|
||||||
s: {c: 4, r: 0},
|
H: item.optionList[4] ? item.optionList[4].content : '',
|
||||||
e: {c: 4, r: 1}
|
I: item.optionList[5] ? item.optionList[5].content : '',
|
||||||
}
|
J: as,
|
||||||
];
|
K: item.tags
|
||||||
ws['!cols'] = [
|
};
|
||||||
{width: 10},
|
data.push(obj);
|
||||||
{width: 10},
|
});
|
||||||
{width: 50},
|
const ws = XLSX.utils.json_to_sheet(data, {skipHeader:true});
|
||||||
{width: 15},
|
ws['!merges'] = [
|
||||||
{width: 15},
|
{
|
||||||
{width: 15},
|
s: {c: 0, r: 0},
|
||||||
{width: 15},
|
e: {c: 10, r: 0}
|
||||||
{width: 15},
|
},
|
||||||
{width: 15}
|
{
|
||||||
];
|
s: {c: 0, r: 1},
|
||||||
XLSX.utils.book_append_sheet(wb, ws, 'file');
|
e: {c: 10, r: 1}
|
||||||
XLSX.writeFile(wb, '题库模板' + '.xlsx');
|
},
|
||||||
|
{
|
||||||
|
s: {c: 0, r: 2},
|
||||||
|
e: {c: 0, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 1, r: 2},
|
||||||
|
e: {c: 1, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 2, r: 2},
|
||||||
|
e: {c: 2, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 3, r: 2},
|
||||||
|
e: {c: 3, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 4, r: 2},
|
||||||
|
e: {c: 4, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 5, r: 2},
|
||||||
|
e: {c: 5, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 6, r: 2},
|
||||||
|
e: {c: 6, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 7, r: 2},
|
||||||
|
e: {c: 7, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 8, r: 2},
|
||||||
|
e: {c: 8, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 9, r: 2},
|
||||||
|
e: {c: 9, r: 2}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
s: {c: 10, r: 2},
|
||||||
|
e: {c: 10, r: 2}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
ws['!cols'] = [
|
||||||
|
{width: 10},
|
||||||
|
{width: 50},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15},
|
||||||
|
{width: 15}
|
||||||
|
];
|
||||||
|
XLSX.utils.book_append_sheet(wb, ws, 'file');
|
||||||
|
XLSX.writeFile(wb, '题库模板' + '.xlsx');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-if="type=='judge'">
|
<template v-if="type=='judge'">
|
||||||
<el-radio-group v-model="active" @change="onChange">
|
<el-radio-group v-model="active" @change="onChange">
|
||||||
<el-radio :label="0"> √ </el-radio>
|
<!-- <el-radio :label="0"> √ </el-radio>
|
||||||
<el-radio :label="1"> × </el-radio>
|
<el-radio :label="1"> × </el-radio> -->
|
||||||
|
<el-radio v-for="(el,i) in optionList" :key="i" :label="i"> {{ el.content }} </el-radio>
|
||||||
</el-radio-group>
|
</el-radio-group>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="type=='multi'">
|
<template v-if="type=='multi'">
|
||||||
|
@ -13,7 +13,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-table :data="tableData" border style="width: 100%">
|
<el-table :data="tableData" border style="width: 100%">
|
||||||
<el-table-column prop="topic" label="题目" />
|
<el-table-column prop="topic" label="题目">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<div v-html="scope.row.topic" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="tags" label="标签" width="200">
|
<el-table-column prop="tags" label="标签" width="200">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag v-for="item in getTagesArr(scope.row.tags)" :key="item" type="primary" disable-transitions style="margin-right: 10px;">{{ item }}</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>
|
||||||
|
Loading…
Reference in New Issue
Block a user