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

feat:新增试卷列表

上级 b7f50005
...@@ -11,10 +11,10 @@ ...@@ -11,10 +11,10 @@
> >
<el-button class="clearfix_add" type="primary" @click="addPaper">添加试题</el-button> <el-button class="clearfix_add" type="primary" @click="addPaper">添加试题</el-button>
</div> </div>
<!-- 题目列表 -->
<div v-for="(item, index) in questionList" :key="index"> <div v-for="(item, index) in questionList" :key="index">
<!-- 题目列表 -->
<QuestionListItems <QuestionListItems
:questionList="questionList" :item="item"
ref="listItemRef" ref="listItemRef"
@handlePosition="handlePosition" @handlePosition="handlePosition"
@selectSubjectsChange="selectSubjectsChange" @selectSubjectsChange="selectSubjectsChange"
...@@ -68,13 +68,11 @@ export default { ...@@ -68,13 +68,11 @@ export default {
data() { data() {
return { return {
visible: false, // 控制增加试题弹框显示还是隐藏 visible: false, // 控制增加试题弹框显示还是隐藏
questionList: [ questionList: [
{ {
question_type: 1, question_type: 1,
question_title: 'xxxxx', question_title: 'xxxxx',
question_content: '这是一道单选题', question_content: '这是一道单选题',
is_parent: 1,
child_question_type: 0, child_question_type: 0,
question_answer: '答案就是你猜呀', question_answer: '答案就是你猜呀',
question_score: '3', question_score: '3',
...@@ -88,7 +86,6 @@ export default { ...@@ -88,7 +86,6 @@ export default {
question_type: 2, question_type: 2,
question_title: 'xxxxx', question_title: 'xxxxx',
question_content: '这是一道多选题', question_content: '这是一道多选题',
is_parent: 1,
child_question_type: 0, child_question_type: 0,
question_answer: '答案就是你猜呀', question_answer: '答案就是你猜呀',
question_score: '3', question_score: '3',
...@@ -99,10 +96,20 @@ export default { ...@@ -99,10 +96,20 @@ export default {
] ]
}, },
{ {
question_type: 2, question_type: 3,
question_title: 'xxxxx',
question_content: '这是一道问答题',
child_question_type: 0,
question_answer: '答案就是你猜呀',
question_score: '3',
group_id: '0',
question_options: []
},
{
question_type: 8,
question_title: 'xxxxx', question_title: 'xxxxx',
question_content: '这是一道情景题', question_content: '这是一道情景题',
is_parent: 0, is_parent: 1,
child_question_type: '', child_question_type: '',
question_answer: '答案就是你猜呀', question_answer: '答案就是你猜呀',
question_score: '3', question_score: '3',
...@@ -110,12 +117,12 @@ export default { ...@@ -110,12 +117,12 @@ export default {
question_options: [] question_options: []
}, },
{ {
question_type: 2, question_type: 8,
question_title: 'xxxxx', question_title: 'xxxxx',
question_content: '这是一道单选题', question_content: '这是一道单选题',
is_parent: 1, is_parent: 0,
child_question_type: 1, child_question_type: 1,
question_answer: '答案就是你猜呀', question_answer: '答案就是你猜呀111111',
question_score: '3', question_score: '3',
group_id: '0', group_id: '0',
question_options: [ question_options: [
......
<template> <template>
<div> <div class="question_bd">
<el-card style="margin-top: 32px" :key="index"> <span class="question_hd_left_title" v-if="item.is_parent === 0">{{ item.question_content }}</span>
<div class="question_hd"> <!-- 单选判断 -->
<div class="question_hd_left"> <template v-if="[1, 6].includes(item.question_type) || item.child_question_type === 1">
<div class="question_hd_left_type"> <div v-for="(item, id) in item.question_options" :key="id" class="options">
{{ item[0].question_options }} <el-radio-group>
<input type="checkbox" v-model="checkboxValue" :value="item" @change="slectSubItem(item)" /> <el-radio label="item.options" class="question_bd_desc">
{{ index + 1 }}{{ title }} <span class="question_bd_desc_item">{{ item.options }}</span>
<span class="question_hd_left_title">{{ item[0].question_content }}</span> </el-radio>
</div> </el-radio-group>
</div>
<div class="question_hd_right">分数 :<el-input :value="item.score"></el-input></div>
</div> </div>
<div class="question_bd"> <div v-if="item.is_parent === 0">正确答案:{{ item.question_answer }}</div>
<!-- 单选判断 --> </template>
<template v-if="item.tag === '1'"> <!-- 多选 -->
<div v-for="(item, id) in item[0].question_options" :key="id" class="options"> <template v-if="item.question_type === 2 || item.child_question_type === 2">
<el-radio-group> <div class="question-option-item" v-for="item in item.question_options" :key="item.id">
<el-radio label="item.option" class="question_bd_desc"> <el-checkbox label="item.id" class="question_bd_desc"
<span class="question_bd_desc_item">{{ item.option }}</span> ><span class="question_bd_desc_item">{{ item.options }}</span>
</el-radio> </el-checkbox>
</el-radio-group>
</div>
</template>
<!-- 多选 -->
<template v-if="item.tag === '2'">
<div class="question-option-item" v-for="item in item.checkList" :key="item.id">
<el-checkbox label="item.id" class="question_bd_desc"
><span class="question_bd_desc_item">{{ item.desc }}</span>
</el-checkbox>
</div>
</template>
<!-- 简答题 -->
<template v-if="item.tag === '3'">
<el-input type="textarea" class="question_bd_desc"></el-input>
</template>
</div> </div>
<div style="margin-top: 10px" class="question_ft">正确答案:{{ item.answer }}</div> <div v-if="item.is_parent === 0">正确答案:{{ item.question_answer }}</div>
</el-card> </template>
<!-- 简答题 -->
<template v-if="item.question_type === 3 || item.child_question_type === 3">
<el-input type="textarea"></el-input>
<div v-if="item.is_parent === 0">正确答案:{{ item.question_answer }}</div>
</template>
</div> </div>
</template> </template>
...@@ -49,12 +37,7 @@ export default { ...@@ -49,12 +37,7 @@ export default {
} }
}, },
props: { props: {
item: { item: {}
type: Object
},
title: {
type: String
}
}, },
methods: { methods: {
handleScroll(key) { handleScroll(key) {
......
<template> <template>
<div> <div>
<el-card style="margin-top: 32px" v-for="(item, index) in item.question_list" :key="index" :id="`page${index}`"> <!-- <div style="margin-top: 32px" v-for="(item, index) in questionList" :key="index" :id="`page${index}`"> -->
<div style="margin-top: 32px">
<div class="question_hd"> <div class="question_hd">
<div class="question_hd_left"> <div class="question_hd_left">
<div class="question_hd_left_type"> <div class="question_hd_left_type">
<input type="checkbox" v-model="checkboxValue" :value="item" @change="slectSubItem(item)" /> <input
{{ index + 1 }}{{ title }} type="checkbox"
<span class="question_hd_left_title">{{ item[0].question_content }}</span> v-model="checkboxValue"
:value="item"
@change="slectSubItem(item)"
v-show="item.is_parent !== 0"
/>
<span v-show="item.is_parent !== 0">
{{ questionType(item) }}
</span>
<div class="question_hd_left_title" v-if="item.is_parent !== 0">{{ item.question_content }}</div>
</div> </div>
</div> </div>
<div class="question_hd_right">分数 :<el-input :value="item.question_score"></el-input></div>
</div> </div>
<div class="question_bd"> <question-list-item :item="item"></question-list-item>
<question-list-item :item="item"></question-list-item> <div
v-if="item.is_parent !== 0 && [1, 2, 3, 6].includes(item.question_type)"
style="margin-top: 10px"
class="question_ft"
>
正确答案:{{ item.question_answer }}
</div> </div>
</el-card> </div>
</div> </div>
</template> </template>
<script> <script>
import QuestionListItem from './QuestionListItem.vue'
export default { export default {
components: { QuestionListItem },
data() { data() {
return { return {
checkboxValue: false checkboxValue: false
} }
}, },
props: { props: {
item: { item: {},
type: Object questionList: []
},
title: {
type: String
}
}, },
// computed: {
// // 试题类型
// questionType() {
// const questionType = this.questionList.map(item => item.question_type)
// return questionType
// }
// },
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 '情景题'
}
},
handleScroll(key) { handleScroll(key) {
const PageId = document.querySelector('#page' + key) const PageId = document.querySelector('#page' + key)
this.$emit('handlePosition', PageId.offsetTop) this.$emit('handlePosition', PageId.offsetTop)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论