提交 82ecb589 authored 作者: lihuihui's avatar lihuihui

试题问题修改

上级 6387fbc7
......@@ -84,10 +84,7 @@ export default {
{ label: '单选题', value: 1 },
{ label: '多选题', value: 2 },
{ label: '问答题', value: 3 },
{ label: '案例题', value: 5 },
{ label: '判断题', value: 6 },
{ label: '实操题', value: 7 },
{ label: '情景题', value: 8 }
{ label: '判断题', value: 6 }
]
},
{
......@@ -125,6 +122,7 @@ export default {
remote: {
httpRequest: getAppList,
params: {
question_types: [1, 2, 3, 6],
permission: this.questionBank,
project_prefix: 'x1',
question_category: this.treeValue.id
......@@ -141,8 +139,9 @@ export default {
2: '中',
3: '难'
}
return data.data.reduce((a, b) => {
return data.data.reduce((a, b, index) => {
const type = b.question_type
b.order = index + 1
b.question_type = questionType[b.question_type]
b.question_difficulty = questionDifficulty[b.question_difficulty]
if (type !== 5 && type !== 7 && type !== 8) a.push(b)
......@@ -152,7 +151,7 @@ export default {
},
columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' },
{ label: '序号', prop: 'question_order' },
{ label: '序号', prop: 'order' },
{ label: '题目类型', prop: 'question_type' },
{ label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' },
......@@ -195,14 +194,14 @@ export default {
if (this.type !== 3) {
if (this.type === 1 || this.type === 2) {
options = [
{ option: '', checked: true },
{ option: '', checked: false },
{ option: '', checked: false }
{ option: '', checked: true, id: '0' },
{ option: '', checked: false, id: '0' },
{ option: '', checked: false, id: '0' }
]
} else {
options = [
{ option: '正确', checked: true },
{ option: '错误', checked: false }
{ option: '正确', checked: true, id: '0' },
{ option: '错误', checked: false, id: '0' }
]
}
data.question_options = options
......
<template>
<div class="radio-box">
<template v-for="(item, index) in option || datas">
<template v-for="(item, index) in datas">
<div class="opt" :key="index">
<el-checkbox v-model="checkboxValue" :label="index" @change="checkboxChange">
<el-tag>{{ A_Z()[index] }}</el-tag>
......@@ -44,7 +44,13 @@ export default {
}
},
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: {
add() {
......
<template>
<div>
<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=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>
</div>
</template>
......@@ -14,7 +14,7 @@ export default {
},
data() {
return {
radio: '0',
radio: 0,
datas: [
{
option: '正确',
......@@ -28,7 +28,10 @@ export default {
}
},
mounted() {
if (this.option) this.datas = this.option
if (this.option) {
this.datas = this.option
this.radio = this.datas.findIndex(item => item.checked)
}
},
methods: {
radioChange() {
......
......@@ -41,7 +41,10 @@ export default {
}
},
mounted() {
if (this.option) this.datas = this.option
if (this.option) {
this.datas = this.option
this.radioValue = this.datas.findIndex(item => item.checked)
}
},
methods: {
add() {
......
<template>
<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="resetForm('ruleForm')">保存主题目</el-button>
<el-button type="primary" @click="cacheQuestion">保存主题目</el-button>
</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-radio v-model="ruleForm.permission" label="1">我的题库</el-radio>
<el-radio v-model="ruleForm.permission" label="2">公共题库</el-radio>
......@@ -25,7 +25,7 @@
<el-input v-model="ruleForm.question_title"></el-input>
</el-form-item>
<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> -->
......@@ -68,7 +68,7 @@
<questions-chidren
:chidrenList="chidrenList"
@submitForm="submitForm"
@addChidren="drawer = true"
@cacheChidren="cacheQuestion"
></questions-chidren>
<el-drawer size="90%" title="新建试题" :visible.sync="drawer" direction="rtl" :before-close="handleCloseDrawer">
<add-chidren @haveQuestion="haveQuestion" @questionList="questionList" :dataForm="ruleForm"></add-chidren>
......@@ -135,6 +135,7 @@ export default {
}
},
created() {
this.ruleForm.question_type = this.questionTypeNumber
if (this.detailData) {
this.ruleForm = this.detailData
this.treeValue.name = this.detailData.question_category.category_name
......@@ -143,11 +144,15 @@ export default {
this.pointOptions.push(this.detailData.knowledge_point)
this.ruleForm.knowledge_point = this.detailData.knowledge_point.id
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() {
this.ruleForm.question_type = this.questionTypeNumber
this.getTreeList()
},
methods: {
......@@ -168,16 +173,20 @@ export default {
path: '/question/list'
})
})
window.localStorage.removeItem('cacheQuestion')
}
},
resetForm(formName) {
this.$refs[formName].validate(valid => {
if (valid) {
console.log(this.chidrenList)
} else {
console.log('error submit!!')
return false
}
cacheQuestion() {
const cacheData = {
form: this.ruleForm,
tree: this.treeValue,
pointOptions: this.pointOptions,
children: this.chidrenList
}
window.localStorage.cacheQuestion = JSON.stringify(cacheData)
this.$message({
message: '保存成功',
type: 'success'
})
},
questionTypeChange() {
......
<template>
<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">
<el-divider content-position="center" class="divider">子题目{{ index + 1 }}</el-divider>
<el-form-item style="text-align: right;">
<el-button type="primary" @click="$emit('addChidren')">添加子题目</el-button>
<el-form-item style="text-align: right;" v-if="!!!($route.query.type === 'view')">
<el-button type="primary" @click="$emit('cacheChidren')">保存子题目</el-button>
<el-button type="primary" @click="removeChidren(index)">删除子题目</el-button>
</el-form-item>
<el-form-item label="子题目类型" prop="child_question_type">
......@@ -19,7 +19,7 @@
<el-input v-model="ruleForm.question_title"></el-input>
</el-form-item>
<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 label="选项" prop="question_options" v-if="ruleForm.child_question_type != 3">
<!-- 单选题 -->
......@@ -30,10 +30,10 @@
<judgment ref="options" :option="ruleForm.question_options" v-if="ruleForm.child_question_type == 6"></judgment>
</el-form-item>
<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 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>
</div>
</el-form>
......
<template>
<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">
<detail v-if="Object.keys(detailData).length" :detailData="detailData" @questionType="questionType"></detail>
</template>
......@@ -10,7 +10,7 @@
<template v-if="$route.query.id">
<situation-question v-if="$route.query.id && Object.keys(detailData).length" :detailData="detailData" :questionTypeNumber="questionTypeNum" @questionType="questionType"></situation-question>
</template>
<situation-question v-else :questionTypeNumber="questionTypeNum" @questionType="questionType"></situation-question>
<situation-question v-else :questionTypeNumber="questionTypeNum" @questionType="questionType"></situation-question>
</template>
</app-card>
</template>
......@@ -27,6 +27,11 @@ export default {
detailData: {}
}
},
computed: {
cacheData() {
return window.localStorage.cacheQuestion
}
},
mounted() {
if (this.$route.query.id) {
questionDetail(this.$route.query.id).then(res => {
......
......@@ -16,7 +16,7 @@
>新建试题</el-button
>
<el-button type="primary" icon="el-icon-plus" @click="visible = 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>
<template v-slot:table-x="{ row }">
<el-button type="text" @click="handleSettings(row)">编辑</el-button>
......@@ -136,7 +136,8 @@ export default {
2: '中',
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_difficulty = questionDifficulty[b.question_difficulty]
a.push(b)
......@@ -146,7 +147,7 @@ export default {
},
columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' },
{ label: '序号', prop: 'question_order' },
{ label: '序号', prop: 'order' },
{ label: '题目类型', prop: 'question_type' },
{ label: '试题分类', prop: 'question_category.category_name' },
{ label: '题目标题', prop: 'question_title' },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论