提交 f9d72fca authored 作者: matian's avatar matian

代码更新

上级 c8c0fca7
...@@ -6,3 +6,21 @@ import httpRequest from '@/utils/axios' ...@@ -6,3 +6,21 @@ import httpRequest from '@/utils/axios'
export function getKnowledge(params) { export function getKnowledge(params) {
return httpRequest.get('/admin/v1/knowledge-point/search/x1', { params }) return httpRequest.get('/admin/v1/knowledge-point/search/x1', { params })
} }
/**
* 获取试卷列表
*/
export function getPaperList(params) {
return httpRequest.get('/api/qbs/admin/v1/question-papers/x1', { params })
}
/**
* 新建试卷
*/
export function createNewPaper(data) {
return httpRequest.post('/api/qbs/admin/v1/question-paper', data)
}
/**
* 获取试卷分类
*/
export function getPaperCategory(params) {
return httpRequest.get(`/api/qbs/admin/v1/question-category/tree/${params}`, { params })
}
<template> <template>
<div style="margin-top: 32px"> <div style="margin-top: 32px">
<el-row :gutter="60"> <el-row :gutter="20">
<!-- 试题列表 --> <!-- 试题列表 -->
<el-col :span="18"> <el-col :span="18">
<el-card id="questionMain" <el-card id="questionMain"
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
<el-button class="clearfix_add" type="primary" @click="addPaper">添加试题</el-button> <el-button class="clearfix_add" type="primary" @click="addPaper">添加试题</el-button>
</div> </div>
<!-- 题目列表 --> <!-- 题目列表 -->
<QuestionListItem <QuestionListItems
:questionList="questionList" :questionList="getSortQuestionList()"
ref="listItemRef" ref="listItemRef"
@handlePosition="handlePosition" @handlePosition="handlePosition"
@selectSubjectsChange="selectSubjectsChange" @selectSubjectsChange="selectSubjectsChange"
...@@ -21,18 +21,18 @@ ...@@ -21,18 +21,18 @@
/> />
<!-- 选题组卷无数据情况下显示 --> <!-- 选题组卷无数据情况下显示 -->
<div class="nonePaper" v-show="questionList.length === 0"> <div class="nonePaper" v-show="questionList.length === 0">
<el-result icon="info" subTitle="该试卷无试题,去添加试题吧"></el-result> <!-- <el-result icon="info" subTitle="该试卷无试题,去添加试题吧"></el-result> -->
</div> </div>
</el-card> </el-card>
</el-col> </el-col>
<!-- 题目序号列表 --> <!-- 题目序号列表 -->
<el-col :span="4" v-if="questionList.length > 0"> <el-col :span="4" v-if="getSortQuestionList().length > 0">
<el-card style="position: fixed"> <el-card style="position: fixed">
<div class="titleIndex"> <div class="titleIndex">
<ul> <ul>
<li v-for="(item, index) in questionList" :key="index" @click="titleClick(index)"> <li v-for="(item, index) in getSortQuestionList()" :key="index" @click="titleClick(index)">
<div :class="currentIndex === index + 1 ? `titleItem` : ''" class="item_index">{{ index + 1 }}</div> <div id="subNum" :class="currentIndex === index + 1 ? `titleItem` : ''">{{ index + 1 }}</div>
<div class="item_type">{{ questionType(item) }}</div> <div class="subType">{{ subType[item.question_type] }}</div>
</li> </li>
</ul> </ul>
<div style="margin-top: 10px; display: flex; justify-content: center; align-items: center"> <div style="margin-top: 10px; display: flex; justify-content: center; align-items: center">
...@@ -42,20 +42,19 @@ ...@@ -42,20 +42,19 @@
</el-card> </el-card>
</el-col> </el-col>
</el-row> </el-row>
<!-- 选题组卷弹框 --> <AutomaticPaper :visible.sync="visible" v-if="paperMode === '自动组卷'" />
<AutomaticPaper :visible.sync="visible" v-if="paperMode === '选题组卷'" />
<!-- 手动组卷弹框 -->
<addPaper :visible.sync="visible" v-else /> <addPaper :visible.sync="visible" v-else />
</div> </div>
</template> </template>
<script> <script>
import QuestionListItem from './QuestionListItems.vue' import QuestionListItems from './QuestionListItems.vue'
import AutomaticPaper from './AutomaticPaper.vue' import AutomaticPaper from './AutomaticPaper.vue'
import addPaper from './AddPaper.vue' import addPaper from './AddPaper.vue'
export default { export default {
components: { components: {
QuestionListItem, QuestionListItems,
addPaper, addPaper,
AutomaticPaper AutomaticPaper
}, },
...@@ -63,17 +62,24 @@ export default { ...@@ -63,17 +62,24 @@ export default {
paperMode: { paperMode: {
type: String, type: String,
default: '' default: ''
},
paperTotalScore: {
type: Number,
default: 0
} }
}, },
data() { data() {
return { return {
visible: false, // 控制增加试题弹框显示还是隐藏 visible: false, // 控制增加试题弹框显示还是隐藏
currentIndex: 1, currentIndex: 1,
selectQuestion: [], selectQuestion: [], // 选择的题
questionListed: [], // 处理好排序的试题列表
subType: {
// 匹配类型显示
1: '单',
2: '多',
3: '简',
5: '案',
6: '判',
7: '实',
8: '情'
},
questionList: [ questionList: [
{ {
question_title: '单选题', question_title: '单选题',
...@@ -96,8 +102,7 @@ export default { ...@@ -96,8 +102,7 @@ export default {
], ],
question_answer: '示向功能', question_answer: '示向功能',
group_id: '1001', group_id: '1001',
score: 2, score: 2
question_order: 2
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -125,8 +130,7 @@ export default { ...@@ -125,8 +130,7 @@ export default {
} }
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1002', group_id: '1002'
question_order: 1
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -149,8 +153,7 @@ export default { ...@@ -149,8 +153,7 @@ export default {
} }
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1003', group_id: '1003'
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -161,8 +164,7 @@ export default { ...@@ -161,8 +164,7 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1004', group_id: '1004',
score: 2, score: 2
question_order: 4
}, },
{ {
question_title: '案例题', question_title: '案例题',
...@@ -173,8 +175,7 @@ export default { ...@@ -173,8 +175,7 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1005', group_id: '1005',
score: 8, score: 8
question_order: 5
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -196,8 +197,7 @@ export default { ...@@ -196,8 +197,7 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1005', group_id: '1005',
score: 2, score: 2
question_order: 1
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -225,8 +225,7 @@ export default { ...@@ -225,8 +225,7 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1005', group_id: '1005',
score: 2, score: 2
question_order: 2
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -249,8 +248,7 @@ export default { ...@@ -249,8 +248,7 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1005', group_id: '1005',
score: 2, score: 2
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -261,21 +259,9 @@ export default { ...@@ -261,21 +259,9 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1005', group_id: '1005',
score: 2, score: 2
question_order: 4
},
{
question_title: '简答题',
question_content:
'<p>1111复购率在金融数字化营销中是反应用户对品牌忠诚度的一个重要指标,锡盟高钙奶是一家专门生产乳制品的企业,其中脱脂牛奶的销量一直不太理想,2021年一季度华北市场的脱脂牛奶交易笔数为12000笔,4000人实现二次购买,而这4000人当中2000人实现了三次购买。</p>',
question_type: 5,
is_parent: 0,
child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1005',
score: 2,
question_order: 5
}, },
{ {
question_title: '情景题', question_title: '情景题',
question_content: question_content:
...@@ -285,8 +271,7 @@ export default { ...@@ -285,8 +271,7 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1006', group_id: '1006',
score: 8, score: 8
question_order: 6
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -308,8 +293,7 @@ export default { ...@@ -308,8 +293,7 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1006', group_id: '1006',
score: 2, score: 2
question_order: 1
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -337,8 +321,7 @@ export default { ...@@ -337,8 +321,7 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1006', group_id: '1006',
score: 2, score: 2
question_order: 2
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -361,8 +344,7 @@ export default { ...@@ -361,8 +344,7 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1006', group_id: '1006',
score: 2, score: 2
question_order: 3
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -373,8 +355,7 @@ export default { ...@@ -373,8 +355,7 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1006', group_id: '1006',
score: 2, score: 2
question_order: 4
}, },
{ {
...@@ -386,8 +367,7 @@ export default { ...@@ -386,8 +367,7 @@ export default {
child_question_type: 0, child_question_type: 0,
question_answer: null, question_answer: null,
group_id: '1007', group_id: '1007',
score: 8, score: 8
question_order: 7
}, },
{ {
question_title: '单选题', question_title: '单选题',
...@@ -409,8 +389,7 @@ export default { ...@@ -409,8 +389,7 @@ export default {
], ],
question_answer: '2000', question_answer: '2000',
group_id: '1007', group_id: '1007',
score: 2, score: 2
question_order: 4
}, },
{ {
question_title: '多选题', question_title: '多选题',
...@@ -438,8 +417,7 @@ export default { ...@@ -438,8 +417,7 @@ export default {
], ],
question_answer: '示向功能、示向----', question_answer: '示向功能、示向----',
group_id: '1007', group_id: '1007',
score: 2, score: 2
question_order: 3
}, },
{ {
question_title: '判断题', question_title: '判断题',
...@@ -462,8 +440,7 @@ export default { ...@@ -462,8 +440,7 @@ export default {
], ],
question_answer: '正确', question_answer: '正确',
group_id: '1007', group_id: '1007',
score: 2, score: 2
question_order: 2
}, },
{ {
question_title: '简答题', question_title: '简答题',
...@@ -474,8 +451,31 @@ export default { ...@@ -474,8 +451,31 @@ export default {
child_question_type: 3, child_question_type: 3,
question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔', question_answer: '2021年一季度华北市场的脱脂牛奶交易笔数为12000笔',
group_id: '1007', group_id: '1007',
score: 2, score: 2
question_order: 1 },
{
question_title: '单选题',
question_content:
'<p>市场营销通过多方面手段便利交换、便利物流,从而保障交换工能够和物流功能的实现。这主要说的是市场营销的哪一项功能?</p>',
question_type: 1,
is_parent: 1,
child_question_type: 1,
question_options: [
{
id: '1',
options: '示向功能',
checked: true
},
{
id: '2',
options: '示向----',
checked: false
}
],
question_answer: '示向功能',
group_id: '1001',
score: 2
} }
] ]
} }
...@@ -485,25 +485,6 @@ export default { ...@@ -485,25 +485,6 @@ export default {
this.getlist() // 处理后端返回 this.getlist() // 处理后端返回
}, },
methods: { methods: {
// 试题类型
questionType(item) {
if (item.question_type === 1) {
return '单'
} else if (item.question_type === 2) {
return '多'
} else if (item.question_type === 3) {
return '问'
} else if (item.question_type === 5) {
return '案'
} else if (item.question_type === 6) {
return '判'
} else if (item.question_type === 7) {
return '实'
} else if (item.question_type === 8) {
return '情'
}
},
// 试题列表数据组装
getlist() { getlist() {
const newQuestionList = [] const newQuestionList = []
const bigData = this.questionList.filter(item => item.is_parent === 1) // 大题 const bigData = this.questionList.filter(item => item.is_parent === 1) // 大题
...@@ -514,26 +495,37 @@ export default { ...@@ -514,26 +495,37 @@ export default {
if (bigData[i].group_id === smallData[j].group_id) { if (bigData[i].group_id === smallData[j].group_id) {
// 如果大题的group_id和小题group_id相等就push listArray数组中,然后赋值给bigData[i].list 相当于加个list属性 // 如果大题的group_id和小题group_id相等就push listArray数组中,然后赋值给bigData[i].list 相当于加个list属性
listArray.push(smallData[j]) // 符合就push listArray数组暂存 listArray.push(smallData[j]) // 符合就push listArray数组暂存
listArray.sort(compare('question_order')) // 小题排序
bigData[i].list = listArray bigData[i].list = listArray
} }
} }
newQuestionList.push(bigData[i]) newQuestionList.push(bigData[i])
} }
newQuestionList.sort(compare('question_order')) // 大题排序 this.questionList = newQuestionList
this.questionList = newQuestionList // 组装完成的试题列表
console.log(this.questionList)
// 根据属性值大小进行排序
function compare(property) {
return function (a, b) {
const v1 = a[property]
const v2 = b[property]
return v1 - v2
}
}
}, },
// 排好序数据 左侧的题号,需对后端返回的数据进行排序循环 [1,2,3,6], //简单题类型 [5,7,8], //复杂题类型
getSortQuestionList() {
// [1,2,3,6,5,7,8] //以这个顺序排序
const data = [
...this.getListBytype(1),
...this.getListBytype(2),
...this.getListBytype(3),
...this.getListBytype(6),
...this.getListBytype(5),
...this.getListBytype(7),
...this.getListBytype(8)
] // 存放排好序的试题
return data
},
// 拿到指定类型的试题
getListBytype(type) {
return this.questionList.filter(item => item.question_type === type)
},
// 增加试题 // 增加试题
addPaper() { addPaper() {
console.log('dfjsf')
this.visible = true this.visible = true
}, },
// 切换题目编号 // 切换题目编号
...@@ -544,28 +536,40 @@ export default { ...@@ -544,28 +536,40 @@ export default {
// 试题列表滑动指定位置 // 试题列表滑动指定位置
handlePosition(offsetTop) { handlePosition(offsetTop) {
console.log(offsetTop) console.log(offsetTop)
// document.getElementById('questionMain').scrollTo(0, offsetTop)
window.scrollTo(0, offsetTop) window.scrollTo(0, offsetTop)
}, },
// 保存试卷 // 保存试卷
savePaper() { savePaper() {
// 校验单个小题分数是否等于大题分数 // 校验分数
// 拿出含有小题的大题 const tottalScore = 34 // 假如这套试卷的总分为 32分
// const questionComplexBig = this.questionList.filter( const bigScore = this.questionList.map(item => item.score * 1).reduce((pre, em) => (pre += em), 0) // 大题分数
// item => item.question_type === 5 || item.question_type === 8 || item.question_type === 7
// ) const bigQuestionNum = this.questionList.filter(item => item?.list).length // 记录复杂题的个数
// // 拿出含有大题的小题 const num = [] // 保存分数正确的复杂题,准确来说 num.length 和 bigQuestionNum相等 才说明每一道复杂题的分数等于小题总分
// const questionComplexSmall = questionComplexBig.map(item => item.list) this.questionList.forEach(item => {
// console.log(questionComplexBig) // 循环大题,如果有小题,就拿有小题的大题的分数和小题的总分比较,分数相等就push num中,之后根据复杂题的个数和num数组length相等,说明复杂题下面的小题都满足小题分总和等于大题的分
// console.log(questionComplexSmall) if (item?.list?.length > 0) {
// 校验大题分数和总分数是否相等 const smallAllSore = item.list.map(v => v.score * 1).reduce((pre, em) => (pre += em), 0) // 小题总分
// const arr = this.questionList.map(item => parseInt(item.score)) if (item.score === smallAllSore) {
// const r2 = arr.reduce((pre, item) => (pre += item), 0) // 大题分数 === 小题总分
// if (r2 !== this.paperTotalScore) { num.push(item.score) // 保存分数正确的复杂题
// this.$message.warning('请校验分数') }
// } }
// console.log(r2) })
// console.log(arr) if (tottalScore === bigScore && bigQuestionNum === num.length) {
// console.log(this.questionList) // 检测分数:首先判断所有大题的总分和试卷的总分相等并且有小题的大题的总分和所有对应所有小题的总分数相等
// 在这里调接口
this.$message({
message: '分数正确,去调接口',
type: 'success'
})
} else {
this.$message({
message: '分数和总分不相等,请确保分数保持一致',
type: 'warning'
})
}
}, },
// 删除所选试题 // 删除所选试题
delCheckedQuestion() { delCheckedQuestion() {
...@@ -635,14 +639,10 @@ export default { ...@@ -635,14 +639,10 @@ export default {
min-width: 20%; min-width: 20%;
max-width: 20%; max-width: 20%;
margin-top: 10px; margin-top: 10px;
.item_type { display: flex;
width: 24px; flex-direction: column;
height: 24px; align-items: center;
font-size: 14px; #subNum {
text-align: center;
color: #c01c40;
}
.item_index {
border-radius: 50px; border-radius: 50px;
width: 24px; width: 24px;
height: 24px; height: 24px;
...@@ -652,6 +652,10 @@ export default { ...@@ -652,6 +652,10 @@ export default {
color: #666; color: #666;
cursor: pointer; cursor: pointer;
} }
.subType {
font-size: 14px;
color: #666;
}
} }
.titleItem { .titleItem {
background-color: rgb(194, 43, 43); background-color: rgb(194, 43, 43);
......
<template> <template>
<div> <div>
<div v-for="(item, index) in questionList" :key="index"> <div v-for="(item, index) in questionList" :key="index">
<!-- 简单题类型 [1,2,3,4] :根据判断题的类型渲染 --> <!-- 简单题类型 [1,2,3,6] :根据判断题的类型渲染 -->
<el-card class="boxCard" v-if="signQuestionTypes.includes(item.question_type)" :id="`page${index}`"> <el-card class="boxCard" v-if="signQuestionTypes.includes(item.question_type)" :id="`page${index}`">
<div class="boxHeader"> <div class="boxHeader">
<div class="headerLeft"> <div class="headerLeft">
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</div> </div>
</el-card> </el-card>
<!-- 复杂题类型 [5,6] :根据判断题的类型渲染 复杂利用上面的头部,内部重新写个页面渲染复杂题中的小题--> <!-- 复杂题类型 [5,7,8] :根据判断题的类型渲染 复杂利用上面的头部,内部重新写个页面渲染复杂题中的小题-->
<el-card class="boxCard" v-if="intricacyQuestionTypes.includes(item.question_type)" :id="`page${index}`"> <el-card class="boxCard" v-if="intricacyQuestionTypes.includes(item.question_type)" :id="`page${index}`">
<div class="boxHeader"> <div class="boxHeader">
<div class="headerLeft"> <div class="headerLeft">
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
<div class="headerRight"> <div class="headerRight">
<div class="scoreValue"> <div class="scoreValue">
<span class="lableScore">分数:</span> <span class="lableScore">分数:</span>
<el-input v-model="item.score"></el-input> <el-input :value="getSubScore(item)"></el-input>
</div> </div>
</div> </div>
</div> </div>
...@@ -110,7 +110,13 @@ export default { ...@@ -110,7 +110,13 @@ export default {
intricacyQuestionTypes: [5, 7, 8] // 复杂题类型 intricacyQuestionTypes: [5, 7, 8] // 复杂题类型
} }
}, },
methods: { methods: {
// 根据小题的分数计算大题的分数,以至于监听分数变化 s.score*1 是为了下次修改,返回的是字符串变成number类型才可以计算
getSubScore(item) {
return item?.list?.map(s => parseInt(s.score) * 1).reduce((pre, em) => pre + em, 0)
},
// 返回点击题号的offsettop // 返回点击题号的offsettop
handleScroll(key) { handleScroll(key) {
const PageId = document.querySelector('#page' + key) const PageId = document.querySelector('#page' + key)
...@@ -143,7 +149,7 @@ export default { ...@@ -143,7 +149,7 @@ export default {
justify-content: space-around; justify-content: space-around;
.titleType { .titleType {
width: 200px; width: 200px;
color: #c01c40; color: #1890ff;
} }
} }
.checkInpt .title { .checkInpt .title {
...@@ -184,7 +190,7 @@ export default { ...@@ -184,7 +190,7 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
.boxAnswer { .boxAnswer {
color: #c01c40; color: #1890ff;
font-size: 14px; font-size: 14px;
} }
} }
...@@ -206,7 +212,7 @@ export default { ...@@ -206,7 +212,7 @@ export default {
flex: 0.8; flex: 0.8;
.intricacyTitle { .intricacyTitle {
width: 200px; width: 200px;
color: #c01c40; color: #949091;
} }
} }
.intricacyScoreValue { .intricacyScoreValue {
...@@ -227,16 +233,10 @@ export default { ...@@ -227,16 +233,10 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
.intricacyAnswer { .intricacyAnswer {
color: #c01c40; color: #1890ff;
font-size: 14px; font-size: 14px;
} }
} }
} }
} }
::v-deep .el-checkbox__label {
color: #c01c40;
}
input {
-webkit-appearance: checkbox;
}
</style> </style>
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
</template> </template>
<script> <script>
const paperMode = [ import { getPaperList, getPaperCategory } from '../api'
const paperType = [
{ label: '选题组卷', value: 0 }, { label: '选题组卷', value: 0 },
{ label: '自动组卷', value: 1 } { label: '自动组卷', value: 1 }
] ]
...@@ -23,25 +24,35 @@ export default { ...@@ -23,25 +24,35 @@ export default {
data() { data() {
return { return {
visible: false, visible: false,
multipleSelection: [] // 选择项 multipleSelection: [], // 选择项
paperCategoryList: []
} }
}, },
computed: { computed: {
tableOptions() { tableOptions() {
return { return {
// remote: { httpRequest: getAppList }, remote: {
httpRequest: getPaperList,
params: {
id: '',
paper_title: '',
paper_type: '',
paper_labels: '',
paper_category: ''
}
},
filters: [ filters: [
{ {
type: 'input', type: 'input',
prop: 'paperName', prop: 'paper_title',
placeholder: '请输入试卷名称', placeholder: '请输入试卷名称',
label: '试卷名称:' label: '试卷名称:'
}, },
{ {
type: 'select', type: 'select',
prop: 'paperMode', prop: 'paper_type',
placeholder: '请选择组卷模式', placeholder: '请选择组卷模式',
options: paperMode, options: paperType,
labelKey: 'label', labelKey: 'label',
valueKey: 'value', valueKey: 'value',
label: '组卷模式:' label: '组卷模式:'
...@@ -57,8 +68,8 @@ export default { ...@@ -57,8 +68,8 @@ export default {
type: 'select', type: 'select',
prop: 'paperType', prop: 'paperType',
placeholder: '请选择试卷分类', placeholder: '请选择试卷分类',
options: this.natureList, options: this.initTree,
labelKey: 'name', labelKey: 'category_name',
valueKey: 'id', valueKey: 'id',
label: '试卷分类:' label: '试卷分类:'
} }
...@@ -66,30 +77,40 @@ export default { ...@@ -66,30 +77,40 @@ export default {
columns: [ columns: [
{ type: 'selection', minWidth: '50px', fixed: 'left' }, { type: 'selection', minWidth: '50px', fixed: 'left' },
{ type: 'index', label: '序号', minWidth: '50px', fixed: 'left' }, { type: 'index', label: '序号', minWidth: '50px', fixed: 'left' },
{ label: '组卷模式', prop: 'paperMode' }, { label: '组卷模式', prop: 'paper_type' },
{ label: '试卷分类', prop: 'paperType' }, { label: '试卷分类', prop: 'paper_category' },
{ label: '试卷名称', prop: 'paperName' }, { label: '试卷名称', prop: 'paper_title' },
{ label: '总分', prop: 'paperTotalScore' }, { label: '总分', prop: 'paper_total_score' },
{ label: '及格分数', prop: 'paperPassScore' }, { label: '及格分数', prop: 'paperPassScore' },
{ label: '更新人', prop: 'update_name' }, { label: '更新人', prop: 'operator.username' },
{ label: '更新时间', prop: 'update_time' }, { label: '更新时间', prop: 'updated_at' },
{ label: '操作', slots: 'table-x', align: 'right', width: 150 } { label: '操作', slots: 'table-x', align: 'right', width: 150 }
],
data: [
{
paperMode: '选题组卷',
paperType: '测试',
paperName: '期中考试',
paperTotalScore: 100,
paperPassScore: 60,
update_name: '张三',
update_time: '2022-02-18'
}
] ]
// data: [
// {
// paperMode: '选题组卷',
// paperType: '测试',
// paperName: '期中考试',
// paperTotalScore: 100,
// paperPassScore: 60,
// update_name: '张三',
// update_time: '2022-02-18'
// }
// ]
} }
} }
}, },
mounted() {
// 获取试卷分类
this.getPaperCategory()
},
methods: { methods: {
getPaperCategory() {
getPaperCategory('x1').then(res => {
this.paperCategoryList = res.data
})
},
// 新建试卷 // 新建试卷
handleCreatePaper() { handleCreatePaper() {
this.$router.push({ this.$router.push({
......
...@@ -4,36 +4,35 @@ ...@@ -4,36 +4,35 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="试卷名称" label="试卷名称"
prop="paperName" prop="paper_title"
:rules="[{ message: '请输入试卷名称', required: true, trigger: 'blur' }]" :rules="[{ message: '请输入试卷名称', required: true, trigger: 'blur' }]"
> >
<el-input v-model="form.paperName" placeholder="请输入试卷名称" /> <el-input v-model="form.paper_title" placeholder="请输入试卷名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="18">
<el-form-item label="试卷用途" prop="paperUse"> <el-form-item label="试卷用途" prop="paper_uses">
<el-radio-group v-model="form.paperUse"> <el-radio-group v-model="form.paper_uses">
<el-radio label="0">考试</el-radio> <el-radio :label="1">考试</el-radio>
<el-radio label="1">作业</el-radio> <el-radio :label="2">课后作业</el-radio>
<el-radio label="2" v-if="form.paperUse !== '0'">课后作业</el-radio> <el-radio :label="3">课程测试</el-radio>
<el-radio label="3" v-if="form.paperUse !== '0'">课程测试</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="标签" prop="label"> <el-form-item label="标签" prop="paper_labels">
<el-input v-model="form.label" placeholder="请输入试卷标签" /> <el-input v-model="form.paper_labels" placeholder="请输入试卷标签" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="试卷分类" prop="classification"> <el-form-item label="试卷分类" prop="paper_category">
<el-select v-model="form.classification" placeholder="请选择试卷分类" style="width: 100%"> <el-select v-model="form.paper_category" placeholder="请选择试卷分类" style="width: 100%">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option> <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"> </el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
...@@ -41,8 +40,8 @@ ...@@ -41,8 +40,8 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="组卷模式" prop="paperMode"> <el-form-item label="组卷模式" prop="paper_type">
<el-select v-model="form.paperMode" placeholder="请选择组卷模式" style="width: 100%"> <el-select v-model="form.paper_type" placeholder="请选择组卷模式" style="width: 100%">
<el-option label="自动组卷" :value="0"> </el-option> <el-option label="自动组卷" :value="0"> </el-option>
<el-option label="选题组卷" :value="1"> </el-option> <el-option label="选题组卷" :value="1"> </el-option>
</el-select> </el-select>
...@@ -53,11 +52,11 @@ ...@@ -53,11 +52,11 @@
label="试题顺序" label="试题顺序"
:rules="[{ message: '请选择试题顺序', required: true, trigger: 'change' }]" :rules="[{ message: '请选择试题顺序', required: true, trigger: 'change' }]"
style="padding-left: 20px" style="padding-left: 20px"
v-if="form.paperMode === 1" v-if="form.paper_type === 1"
> >
<el-radio-group v-model="form.order"> <el-radio-group v-model="form.paper_question_order">
<el-radio label="0">固定</el-radio> <el-radio :label="1">固定</el-radio>
<el-radio label="1">随机</el-radio> <el-radio :label="2">随机</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -66,13 +65,13 @@ ...@@ -66,13 +65,13 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="试卷总分" label="试卷总分"
prop="paperTotalScore" prop="paper_total_score"
:rules="[{ message: '请输入试卷总分', required: true, trigger: 'blur' }]" :rules="[{ message: '请输入试卷总分', required: true, trigger: 'blur' }]"
> >
<el-input-number <el-input-number
:controls="false" :controls="false"
:step="1" :step="1"
v-model="form.paperTotalScore" v-model="form.paper_total_score"
:min="0" :min="0"
:max="200" :max="200"
placeholder="请输入试卷总分" placeholder="请输入试卷总分"
...@@ -84,14 +83,14 @@ ...@@ -84,14 +83,14 @@
<el-col :span="10"> <el-col :span="10">
<el-form-item <el-form-item
label="及格分数" label="及格分数"
prop="paperPassScore" prop="pass_score"
:rules="[{ message: '请输入及格分数', required: true, trigger: 'blur' }]" :rules="[{ message: '请输入及格分数', required: true, trigger: 'blur' }]"
style="padding-left: 20px" style="padding-left: 20px"
> >
<el-input-number <el-input-number
:controls="false" :controls="false"
:step="1" :step="1"
v-model="form.paperPassScore" v-model="form.pass_score"
:min="0" :min="0"
:max="200" :max="200"
placeholder="请输入及格分数" placeholder="请输入及格分数"
...@@ -105,11 +104,11 @@ ...@@ -105,11 +104,11 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="考试时长" label="考试时长"
prop="examDuration" prop="paper_times"
:rules="[{ message: '请输入考试时长', required: true, trigger: 'blur' }]" :rules="[{ message: '请输入考试时长', required: true, trigger: 'blur' }]"
> >
<el-input-number <el-input-number
v-model="form.examDuration" v-model="form.paper_times"
:controls="false" :controls="false"
:min="1" :min="1"
:max="150" :max="150"
...@@ -123,12 +122,12 @@ ...@@ -123,12 +122,12 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item <el-form-item
label="最短交卷时长" label="最短交卷时长"
prop="minSubtime" prop="minimum_paper_handing_time"
:rules="[{ message: '请输入考试时长', required: true, trigger: 'blur' }]" :rules="[{ message: '请输入考试时长', required: true, trigger: 'blur' }]"
style="padding-left: 20px" style="padding-left: 20px"
> >
<el-input-number <el-input-number
v-model="form.minSubtime" v-model="form.minimum_paper_handing_time"
:controls="false" :controls="false"
:min="1" :min="1"
:max="150" :max="150"
...@@ -143,17 +142,17 @@ ...@@ -143,17 +142,17 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="多次考试" :rules="[{ required: true, trigger: 'blur' }]"> <el-form-item label="多次考试" :rules="[{ required: true, trigger: 'blur' }]">
<el-radio-group v-model="form.moreExam"> <el-radio-group v-model="form.is_multiple_exams">
<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-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="多次考试成绩计算规则" style="padding-left: 20px" v-if="form.moreExam === '1'"> <el-form-item label="多次考试成绩计算规则" style="padding-left: 20px" v-if="form.moreExam === '1'">
<el-radio-group v-model="form.rule"> <el-radio-group v-model="form.multiple_test_score_rule">
<el-radio label="0">平均计算法</el-radio> <el-radio :label="1">平均计算法</el-radio>
<el-radio label="1">最高得分法</el-radio> <el-radio :label="2">最高得分法</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -169,29 +168,30 @@ ...@@ -169,29 +168,30 @@
</template> </template>
<script> <script>
import { createNewPaper } from '../api'
export default { export default {
data() { data() {
return { return {
labelPosition: 'left', labelPosition: 'left',
btnDisabled: false, btnDisabled: false,
options: [ paper_category: [
{ label: '测试', value: 1 }, { label: '测试', value: 1 },
{ label: '考试', value: 2 }, { label: '考试', value: 2 },
{ label: '模拟', value: 3 } { label: '模拟', value: 3 }
], ],
form: { form: {
paperName: '', // 试卷名称 paper_title: '', // 试卷名称
paperUse: '0', // 试卷用途 paper_uses: 1, // 试卷用途
label: '', // 标签 paper_labels: '', // 标签
classification: 1, // 试卷分类 paper_category: 1, // 试卷分类
paperMode: 0, // 组卷模式 paper_type: 1, // 组卷模式
order: '0', // 试题顺序 paper_question_order: 0, // 试题顺序
paperTotalScore: undefined, // 试卷总分 paper_total_score: undefined, // 试卷总分
paperPassScore: undefined, // 及格分数 paperPassScore: undefined, // 及格分数
examDuration: undefined, // 考试时长 paper_times: undefined, // 考试时长
minSubtime: undefined, // 最短交卷时长 minimum_paper_handing_time: undefined, // 最短交卷时长
moreExam: '1', // 多次考试 is_multiple_exams: 1, // 多次考试
rule: '0' // 多次考试成绩计算规则 multiple_test_score_rule: 1 // 多次考试成绩计算规则
} }
} }
}, },
...@@ -230,6 +230,9 @@ export default { ...@@ -230,6 +230,9 @@ export default {
confirmButtonText: '确定' confirmButtonText: '确定'
}).then(() => { }).then(() => {
history.go(-1) history.go(-1)
createNewPaper(Object.assign(this.form, { project_prefix: 'x1' })).then(res => {
this.$message.sucess('新建试卷成功')
})
}) })
} else { } else {
setTimeout(() => { setTimeout(() => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论