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