提交 0f981e81 authored 作者: 王鹏飞's avatar 王鹏飞

updates

上级 368f6440
......@@ -28,7 +28,7 @@ export default {
},
computed: {
questionTypeName() {
const map = { 1: '单选题', 2: '多选题', 5: '案例题', 6: '判断题' }
const map = { 1: '单选题', 2: '多选题', 3: '问答题', 5: '案例题', 6: '判断题', 7: '实操题', 8: '情景题' }
return map[this.data.question_type]
}
},
......
......@@ -19,12 +19,13 @@
:index="index"
:list="questionList"
:data="currentExam"
@change="handlePageChange"
@page-change="handlePageChange"
></question-numbers>
</div>
</div>
<div class="foot" id="foot-h">
<div class="exam-btn">
<div class="confirm" @click="showResult">确认答案</div>
<div @click="prevQuestion">上一题</div>
<div @click="nextQuestion">下一题</div>
</div>
......@@ -37,8 +38,9 @@
<div :class="currentItem.sign ? 'icon active' : 'icon'"></div>
<div class="txt">{{ currentItem.sign ? '已标记' : '标记' }}</div>
</div>
<div class="del-btn" v-if="hasDeleteBtn">删除</div>
<div class="end-exam-btn">
<div class="btn" v-if="hasSubmitBtn && !disabled" @click="submitExam">交卷</div>
<div class="btn" v-if="hasSubmitBtn && !disabled" @click="submitExam">{{ submitButtonText }}</div>
</div>
</div>
</div>
......@@ -54,11 +56,14 @@ export default {
components: { questionList, questionNumbers },
props: {
title: { type: String },
hasMark: { type: Boolean, default: true },
hasCollect: { type: Boolean, default: true },
hasSubmitBtn: { type: Boolean, default: true },
hasCountDown: { type: Boolean, default: true },
data: { type: Object, default: () => {} }
hasMark: { type: Boolean, default: true }, // 标记
hasCollect: { type: Boolean, default: true }, // 收藏
hasSubmitBtn: { type: Boolean, default: true }, // 提交按钮
hasDeleteBtn: { type: Boolean, default: false }, // 删除按钮
hasCountDown: { type: Boolean, default: true }, // 计时
data: { type: Object, default: () => {} },
questionItems: { type: Array, default: () => [] },
submitButtonText: { type: String, default: '交卷' } // 提交按钮显示的文字
},
data() {
return {
......@@ -87,6 +92,10 @@ export default {
deep: true,
immediate: true,
handler(value) {
if (this.questionItems.length) {
this.questionList = this.questionItems
return
}
if (value) {
const { status } = value
this.disabled = ['1', '2'].includes(status)
......@@ -94,6 +103,9 @@ export default {
this.genQuestions(value)
}
}
},
index(value) {
this.hasResult = this.currentExam.hasResult
}
},
beforeDestroy() {
......@@ -134,14 +146,21 @@ export default {
}
return result
},
// 确认答案
showResult() {
this.hasResult = true
this.questionList[this.index].hasResult = true
},
// 下一题
nextQuestion() {
const totalNumber = this.questionList.length
if (this.index + 1 < totalNumber) this.index++
this.$emit('page-change', this.currentExam)
},
// 上一题
prevQuestion() {
if (this.index !== 0) this.index--
this.$emit('page-change', this.currentExam)
},
handlePageChange(index) {
this.index = index
......@@ -171,11 +190,10 @@ export default {
},
// 组装试题数据
genQuestions(data) {
const { questions = [], answers = {} } = data
const { questions, answers = {} } = data
if (!questions) return []
this.questionList = questions.question_items.reduce((result, question) => {
question.question_list.forEach(list => {
console.log(list)
list = list.map(item => {
let userAnswers = []
let sign = false
......@@ -314,6 +332,19 @@ export default {
.rigth-btn {
display: flex;
margin-left: auto;
.del-btn {
margin-top: 10px;
width: 100px;
height: 40px;
border-radius: 4px;
border: 1px solid #cccccc;
line-height: 40px;
font-size: 14px;
font-weight: bold;
color: #999999;
text-align: center;
margin-right: 30px;
}
.end-exam-btn {
background: #fff;
height: 62px;
......@@ -323,6 +354,7 @@ export default {
display: flex;
justify-content: center;
align-items: center;
.btn {
cursor: pointer;
width: 200px;
......
......@@ -88,7 +88,7 @@ export default {
}
},
handleClick(data) {
this.$emit('change', data.index, data)
this.$emit('page-change', data.index, data)
}
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论