提交 15bafdeb authored 作者: pengxiaohui's avatar pengxiaohui
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
type: 'config', type: 'config',
config: { config: {
enabled_ip_limit: this.config.enabled_ip_limit, enabled_ip_limit: this.config.enabled_ip_limit,
ip_limits: this.config.ip_limits, ip_limits: this.config.ip_limits.toString(),
enabled_promise: this.config.enabled_promise, enabled_promise: this.config.enabled_promise,
enabled_lock: this.config.enabled_lock, enabled_lock: this.config.enabled_lock,
max_login_times: this.config.max_login_times, max_login_times: this.config.max_login_times,
...@@ -132,7 +132,7 @@ export default { ...@@ -132,7 +132,7 @@ export default {
getExamPaperDetail(params).then(res => { getExamPaperDetail(params).then(res => {
const config = JSON.parse(res.data.exam_info.config) const config = JSON.parse(res.data.exam_info.config)
this.config.enabled_ip_limit = config.enabled_ip_limit this.config.enabled_ip_limit = config.enabled_ip_limit
this.config.ip_limits = config.ip_limits this.config.ip_limits = config.ip_limits.toString()
this.config.enabled_promise = config.enabled_promise this.config.enabled_promise = config.enabled_promise
this.config.enabled_lock = config.enabled_lock this.config.enabled_lock = config.enabled_lock
this.config.max_login_times = config.max_login_times this.config.max_login_times = config.max_login_times
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
<el-dropdown-item @click.native="dialogVisible = true" :disabled="this.multipleSelection.length === 0" <el-dropdown-item @click.native="dialogVisible = true" :disabled="this.multipleSelection.length === 0"
>转移考生</el-dropdown-item >转移考生</el-dropdown-item
> >
<el-dropdown-item @click.native="exportDetail" :disabled="this.multipleSelection.length === 0" <el-dropdown-item @click.native="exportDetail">导出明细</el-dropdown-item>
>导出明细</el-dropdown-item
>
<el-dropdown-item @click.native="delStudent" :disabled="this.multipleSelection.length === 0" <el-dropdown-item @click.native="delStudent" :disabled="this.multipleSelection.length === 0"
>删除考生</el-dropdown-item >删除考生</el-dropdown-item
> >
...@@ -113,13 +111,13 @@ export default { ...@@ -113,13 +111,13 @@ export default {
columns: [ columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' }, { type: 'selection', minWidth: '50px', fixed: 'left' },
{ {
label: '考生状态', label: '试卷状态',
prop: 'sheet.status', prop: 'sheet.status',
computed({ row }) { computed({ row }) {
if (row.sheet.status === 0) { if (row.sheet.status === 0) {
return '未提交' return '未提交'
} else if (row.sheet.status === 1) { } else if (row.sheet.status === 1) {
return '已提交' return '待批阅'
} else if (row.sheet.status === 2) { } else if (row.sheet.status === 2) {
return '已批改' return '已批改'
} }
......
...@@ -55,3 +55,16 @@ export function updateQuestion(id, data) { ...@@ -55,3 +55,16 @@ export function updateQuestion(id, data) {
export function questionDetail(id) { export function questionDetail(id) {
return httpRequest.get(`/api/qbs/admin/v1/question/${id}`) return httpRequest.get(`/api/qbs/admin/v1/question/${id}`)
} }
/**
* 导入题
*/
export function importQuestion(data) {
return httpRequest({
url: '/api/qbs/admin/v1/question/import/x1',
method: 'post',
headers: { 'Content-Type': 'multipart/form-data' },
timeout: 900000,
data,
withCredentials: true
})
}
...@@ -84,10 +84,7 @@ export default { ...@@ -84,10 +84,7 @@ export default {
{ label: '单选题', value: 1 }, { label: '单选题', value: 1 },
{ label: '多选题', value: 2 }, { label: '多选题', value: 2 },
{ label: '问答题', value: 3 }, { label: '问答题', value: 3 },
{ label: '案例题', value: 5 }, { label: '判断题', value: 6 }
{ label: '判断题', value: 6 },
{ label: '实操题', value: 7 },
{ label: '情景题', value: 8 }
] ]
}, },
{ {
...@@ -125,6 +122,7 @@ export default { ...@@ -125,6 +122,7 @@ export default {
remote: { remote: {
httpRequest: getAppList, httpRequest: getAppList,
params: { params: {
question_types: [1, 2, 3, 6],
permission: this.questionBank, permission: this.questionBank,
project_prefix: 'x1', project_prefix: 'x1',
question_category: this.treeValue.id question_category: this.treeValue.id
...@@ -141,8 +139,9 @@ export default { ...@@ -141,8 +139,9 @@ export default {
2: '中', 2: '中',
3: '难' 3: '难'
} }
return data.data.reduce((a, b) => { return data.data.reduce((a, b, index) => {
const type = b.question_type const type = b.question_type
b.order = index + 1
b.question_type = questionType[b.question_type] b.question_type = questionType[b.question_type]
b.question_difficulty = questionDifficulty[b.question_difficulty] b.question_difficulty = questionDifficulty[b.question_difficulty]
if (type !== 5 && type !== 7 && type !== 8) a.push(b) if (type !== 5 && type !== 7 && type !== 8) a.push(b)
...@@ -152,7 +151,7 @@ export default { ...@@ -152,7 +151,7 @@ export default {
}, },
columns: [ columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' }, { type: 'selection', minWidth: '50px', fixed: 'left' },
{ label: '序号', prop: 'question_order' }, { label: '序号', prop: 'order' },
{ label: '题目类型', prop: 'question_type' }, { label: '题目类型', prop: 'question_type' },
{ label: '试题分类', prop: 'question_category.category_name' }, { label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' }, { label: '题目标题', prop: 'question_title' },
...@@ -195,14 +194,14 @@ export default { ...@@ -195,14 +194,14 @@ export default {
if (this.type !== 3) { if (this.type !== 3) {
if (this.type === 1 || this.type === 2) { if (this.type === 1 || this.type === 2) {
options = [ options = [
{ option: '', checked: true }, { option: '', checked: true, id: '0' },
{ option: '', checked: false }, { option: '', checked: false, id: '0' },
{ option: '', checked: false } { option: '', checked: false, id: '0' }
] ]
} else { } else {
options = [ options = [
{ option: '正确', checked: true }, { option: '正确', checked: true, id: '0' },
{ option: '错误', checked: false } { option: '错误', checked: false, id: '0' }
] ]
} }
data.question_options = options data.question_options = options
......
<template> <template>
<div class="radio-box"> <div class="radio-box">
<template v-for="(item, index) in option || datas"> <template v-for="(item, index) in datas">
<div class="opt" :key="index"> <div class="opt" :key="index">
<el-checkbox v-model="checkboxValue" :label="index" @change="checkboxChange"> <el-checkbox v-model="checkboxValue" :label="index" @change="checkboxChange">
<el-tag>{{ A_Z()[index] }}</el-tag> <el-tag>{{ A_Z()[index] }}</el-tag>
...@@ -44,7 +44,13 @@ export default { ...@@ -44,7 +44,13 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.option) this.datas = this.option if (this.option) {
this.datas = this.option
this.checkboxValue = [0]
this.datas.forEach((item, index) => {
if (item.checked) this.checkboxValue.push(index)
})
}
}, },
methods: { methods: {
add() { add() {
......
<template> <template>
<div> <div>
<el-radio v-model="radio" label="0" @change="radioChange"><i class="el-icon-check"></i></el-radio> <el-radio v-model="radio" :label=0 @change="radioChange"><i class="el-icon-check"></i></el-radio>
<el-radio v-model="radio" label="1" @change="radioChange"><i class="el-icon-close"></i></el-radio> <el-radio v-model="radio" :label=1 @change="radioChange"><i class="el-icon-close"></i></el-radio>
</div> </div>
</template> </template>
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
}, },
data() { data() {
return { return {
radio: '0', radio: 0,
datas: [ datas: [
{ {
option: '正确', option: '正确',
...@@ -28,7 +28,10 @@ export default { ...@@ -28,7 +28,10 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.option) this.datas = this.option if (this.option) {
this.datas = this.option
this.radio = this.datas.findIndex(item => item.checked)
}
}, },
methods: { methods: {
radioChange() { radioChange() {
......
...@@ -41,7 +41,10 @@ export default { ...@@ -41,7 +41,10 @@ export default {
} }
}, },
mounted() { mounted() {
if (this.option) this.datas = this.option if (this.option) {
this.datas = this.option
this.radioValue = this.datas.findIndex(item => item.checked)
}
}, },
methods: { methods: {
add() { add() {
......
<template> <template>
<div> <div>
<div class="tool-btn"> <div class="tool-btn" v-if="!!!($route.query.type === 'view')">
<el-button type="primary" @click="drawer = true">添加子题目</el-button> <el-button type="primary" @click="drawer = true">添加子题目</el-button>
<el-button type="primary" @click="resetForm('ruleForm')">保存主题目</el-button> <el-button type="primary" @click="cacheQuestion">保存主题目</el-button>
</div> </div>
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> <el-form :disabled="!!($route.query.type === 'view')" :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<el-form-item label="题库范围" prop="permission"> <el-form-item label="题库范围" prop="permission">
<el-radio v-model="ruleForm.permission" label="1">我的题库</el-radio> <el-radio v-model="ruleForm.permission" label="1">我的题库</el-radio>
<el-radio v-model="ruleForm.permission" label="2">公共题库</el-radio> <el-radio v-model="ruleForm.permission" label="2">公共题库</el-radio>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<el-input v-model="ruleForm.question_title"></el-input> <el-input v-model="ruleForm.question_title"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="公共题干" prop="common_content"> <el-form-item label="公共题干" prop="common_content">
<v-editor v-model="ruleForm.common_content"></v-editor> <v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.common_content"></v-editor>
</el-form-item> </el-form-item>
<!-- </el-form-item> --> <!-- </el-form-item> -->
<!-- <el-form-item> --> <!-- <el-form-item> -->
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
<questions-chidren <questions-chidren
:chidrenList="chidrenList" :chidrenList="chidrenList"
@submitForm="submitForm" @submitForm="submitForm"
@addChidren="drawer = true" @cacheChidren="cacheQuestion"
></questions-chidren> ></questions-chidren>
<el-drawer size="90%" title="新建试题" :visible.sync="drawer" direction="rtl" :before-close="handleCloseDrawer"> <el-drawer size="90%" title="新建试题" :visible.sync="drawer" direction="rtl" :before-close="handleCloseDrawer">
<add-chidren @haveQuestion="haveQuestion" @questionList="questionList" :dataForm="ruleForm"></add-chidren> <add-chidren @haveQuestion="haveQuestion" @questionList="questionList" :dataForm="ruleForm"></add-chidren>
...@@ -135,6 +135,7 @@ export default { ...@@ -135,6 +135,7 @@ export default {
} }
}, },
created() { created() {
this.ruleForm.question_type = this.questionTypeNumber
if (this.detailData) { if (this.detailData) {
this.ruleForm = this.detailData this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name this.treeValue.name = this.detailData.question_category.category_name
...@@ -143,11 +144,15 @@ export default { ...@@ -143,11 +144,15 @@ export default {
this.pointOptions.push(this.detailData.knowledge_point) this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
this.chidrenList = this.ruleForm.children this.chidrenList = this.ruleForm.children
console.log(this.ruleForm, '123') } else {
const cacheData = window.localStorage.cacheQuestion
if (cacheData) this.ruleForm = JSON.parse(cacheData).form
this.treeValue = JSON.parse(cacheData).tree
this.pointOptions = JSON.parse(cacheData).pointOptions
this.chidrenList = JSON.parse(cacheData).children
} }
}, },
mounted() { mounted() {
this.ruleForm.question_type = this.questionTypeNumber
this.getTreeList() this.getTreeList()
}, },
methods: { methods: {
...@@ -168,16 +173,20 @@ export default { ...@@ -168,16 +173,20 @@ export default {
path: '/question/list' path: '/question/list'
}) })
}) })
window.localStorage.removeItem('cacheQuestion')
} }
}, },
resetForm(formName) { cacheQuestion() {
this.$refs[formName].validate(valid => { const cacheData = {
if (valid) { form: this.ruleForm,
console.log(this.chidrenList) tree: this.treeValue,
} else { pointOptions: this.pointOptions,
console.log('error submit!!') children: this.chidrenList
return false
} }
window.localStorage.cacheQuestion = JSON.stringify(cacheData)
this.$message({
message: '保存成功',
type: 'success'
}) })
}, },
questionTypeChange() { questionTypeChange() {
......
<template> <template>
<div> <div>
<el-form :model="data" ref="ruleForm" label-width="100px" class="demo-ruleForm"> <el-form :disabled="!!($route.query.type === 'view')" :model="data" ref="ruleForm" label-width="100px" class="demo-ruleForm">
<div v-for="(ruleForm, index) in dataList" :key="index"> <div v-for="(ruleForm, index) in dataList" :key="index">
<el-divider content-position="center" class="divider">子题目{{ index + 1 }}</el-divider> <el-divider content-position="center" class="divider">子题目{{ index + 1 }}</el-divider>
<el-form-item style="text-align: right;"> <el-form-item style="text-align: right;" v-if="!!!($route.query.type === 'view')">
<el-button type="primary" @click="$emit('addChidren')">添加子题目</el-button> <el-button type="primary" @click="$emit('cacheChidren')">保存子题目</el-button>
<el-button type="primary" @click="removeChidren(index)">删除子题目</el-button> <el-button type="primary" @click="removeChidren(index)">删除子题目</el-button>
</el-form-item> </el-form-item>
<el-form-item label="子题目类型" prop="child_question_type"> <el-form-item label="子题目类型" prop="child_question_type">
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<el-input v-model="ruleForm.question_title"></el-input> <el-input v-model="ruleForm.question_title"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="子题目内容" prop="question_content"> <el-form-item label="子题目内容" prop="question_content">
<v-editor v-model="ruleForm.question_content"></v-editor> <v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_content"></v-editor>
</el-form-item> </el-form-item>
<el-form-item label="选项" prop="question_options" v-if="ruleForm.child_question_type != 3"> <el-form-item label="选项" prop="question_options" v-if="ruleForm.child_question_type != 3">
<!-- 单选题 --> <!-- 单选题 -->
...@@ -30,10 +30,10 @@ ...@@ -30,10 +30,10 @@
<judgment ref="options" :option="ruleForm.question_options" v-if="ruleForm.child_question_type == 6"></judgment> <judgment ref="options" :option="ruleForm.question_options" v-if="ruleForm.child_question_type == 6"></judgment>
</el-form-item> </el-form-item>
<el-form-item label="子题目解析" prop="question_analysis"> <el-form-item label="子题目解析" prop="question_analysis">
<v-editor v-model="ruleForm.question_analysis"></v-editor> <v-editor :disabled="!!($route.query.type === 'view')" v-model="ruleForm.question_analysis"></v-editor>
</el-form-item> </el-form-item>
<el-form-item style="text-align: center;" v-if="index + 1 == dataList.length"> <el-form-item style="text-align: center;" v-if="index + 1 == dataList.length">
<el-button type="primary" @click="submitForm">保存</el-button> <el-button v-if="!!!($route.query.type === 'view')" type="primary" @click="submitForm">保存</el-button>
</el-form-item> </el-form-item>
</div> </div>
</el-form> </el-form>
......
<template>
<el-dialog v-bind="$attrs" v-on="$listeners">
<el-upload
style="text-align: center"
class="file-import"
ref="upload"
action="#"
:auto-upload="false"
:file-list="fileList"
:limit="1"
:before-upload="beforeUpload"
:http-request="fetchFileUpload"
accept=".xls,.xlsx"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
</el-upload>
<div style="text-align: center">
<el-button size="mini" @click="cancel">取消</el-button>
<el-button type="primary" size="mini" @click="submitUpload" style="margin-right: 5px"> 确认提交</el-button>
</div>
</el-dialog>
</template>
<script>
import { splitStrLast } from '@/utils/util'
import { importQuestion } from '../api'
export default {
props: {
id: {
type: String,
default: ''
}
},
data() {
return {
fileList: []
}
},
methods: {
beforeUpload(file) {
const suffix = splitStrLast(file.name, '.')
if (!['xlsx', 'xls'].includes(suffix)) {
this.$message.error('只能上传excel文件')
return false
} else {
return true
}
},
fetchFileUpload(data) {
importQuestion({ file: data.file, exam_id: this.id }).then(res => {
if (res.code === 0) {
this.$message.success('导入数据成功')
history.go(0)
}
})
},
submitUpload() {
this.$refs.upload.submit()
},
cancel() {
this.$router.push({
name: 'teacher'
})
}
}
}
</script>
<template> <template>
<app-card> <app-card>
<template v-if="[1, 2, 3, 6].includes(questionTypeNum)"> <template v-if="[1, 2, 3, 6].includes(questionTypeNum) && !cacheData">
<template v-if="$route.query.id"> <template v-if="$route.query.id">
<detail v-if="Object.keys(detailData).length" :detailData="detailData" @questionType="questionType"></detail> <detail v-if="Object.keys(detailData).length" :detailData="detailData" @questionType="questionType"></detail>
</template> </template>
...@@ -27,6 +27,11 @@ export default { ...@@ -27,6 +27,11 @@ export default {
detailData: {} detailData: {}
} }
}, },
computed: {
cacheData() {
return window.localStorage.cacheQuestion
}
},
mounted() { mounted() {
if (this.$route.query.id) { if (this.$route.query.id) {
questionDetail(this.$route.query.id).then(res => { questionDetail(this.$route.query.id).then(res => {
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<el-button type="primary" icon="el-icon-plus" @click="$router.push({ path: '/question/create' })" <el-button type="primary" icon="el-icon-plus" @click="$router.push({ path: '/question/create' })"
>新建试题</el-button >新建试题</el-button
> >
<el-button type="primary" icon="el-icon-plus" @click="visible = true">批量导入试题</el-button> <el-button type="primary" icon="el-icon-plus" @click="importDialogVisible = true">批量导入试题</el-button>
<el-button type="primary" icon="el-icon-plus" @click="deleteQuestion()">批量删除</el-button> <el-button type="primary" icon="el-icon-plus" @click="handleDelete()">批量删除</el-button>
</div> </div>
<template v-slot:table-x="{ row }"> <template v-slot:table-x="{ row }">
<el-button type="text" @click="handleSettings(row)">编辑</el-button> <el-button type="text" @click="handleSettings(row)">编辑</el-button>
...@@ -36,15 +36,18 @@ ...@@ -36,15 +36,18 @@
</span> </span>
</el-dialog> </el-dialog>
</app-list> </app-list>
<import-question :visible.sync="importDialogVisible" />
</app-card> </app-card>
</template> </template>
<script> <script>
import { getAppList, getQuestionCategory, deleteQuestion } from '../api' import { getAppList, getQuestionCategory, deleteQuestion } from '../api'
import importQuestion from '../components/importQuestion.vue'
export default { export default {
components: { importQuestion },
data() { data() {
return { return {
importDialogVisible: false,
deleteQuestions: [], deleteQuestions: [],
dialogVisible: false, dialogVisible: false,
visible: false, visible: false,
...@@ -136,7 +139,8 @@ export default { ...@@ -136,7 +139,8 @@ export default {
2: '中', 2: '中',
3: '难' 3: '难'
} }
return data.data.reduce((a, b) => { return data.data.reduce((a, b, index) => {
b.order = index + 1
b.question_type = questionType[b.question_type] b.question_type = questionType[b.question_type]
b.question_difficulty = questionDifficulty[b.question_difficulty] b.question_difficulty = questionDifficulty[b.question_difficulty]
a.push(b) a.push(b)
...@@ -146,7 +150,7 @@ export default { ...@@ -146,7 +150,7 @@ export default {
}, },
columns: [ columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' }, { type: 'selection', minWidth: '50px', fixed: 'left' },
{ label: '序号', prop: 'question_order' }, { label: '序号', prop: 'order' },
{ label: '题目类型', prop: 'question_type' }, { label: '题目类型', prop: 'question_type' },
{ label: '试题分类', prop: 'question_category.category_name' }, { label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' }, { label: '题目标题', prop: 'question_title' },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论