提交 57533d8e authored 作者: lihuihui's avatar lihuihui

开发考试

上级 0c43d6fc
...@@ -20,30 +20,7 @@ ...@@ -20,30 +20,7 @@
<li <li
:key="cItem.q_order + '-' + cIndex" :key="cItem.q_order + '-' + cIndex"
@click="goQuestion(cItem.q_order)" @click="goQuestion(cItem.q_order)"
:class="questionParams.questionIndex + 1 === cItem.q_order :class="isClass(cItem)"
? questionParams.answerRecord[item.question_item_id]
? questionParams.answerRecord[item.question_item_id][cItem.id]
? questionParams.answerRecord[item.question_item_id][cItem.id].answer.length !== 0
? questionParams.answerRecord[item.question_item_id][cItem.id].sign
? 'stu1 stu2 stu3'
: 'stu1 stu2'
: questionParams.answerRecord[item.question_item_id][cItem.id].sign
? 'stu2 stu3'
: 'stu2'
: 'stu2'
: 'stu2'
: questionParams.answerRecord[item.question_item_id]
? questionParams.answerRecord[item.question_item_id][cItem.id]
? questionParams.answerRecord[item.question_item_id][cItem.id].answer.length !== 0
? questionParams.answerRecord[item.question_item_id][cItem.id].sign
? 'stu1 stu3'
: 'stu1'
: questionParams.answerRecord[item.question_item_id][cItem.id].sign
? 'stu3'
: ''
: ''
: ''
"
>{{ cItem.q_order }}</li> >{{ cItem.q_order }}</li>
</template> </template>
</ul> </ul>
...@@ -97,22 +74,53 @@ export default { ...@@ -97,22 +74,53 @@ export default {
info: { type: Object, default: () => {} } info: { type: Object, default: () => {} }
}, },
mounted() { mounted() {
// Bus.$on('monitoringChanges', target => { this.msgCenter.$on('monitoringChanges', this.monitoringChanges)
// this.$forceUpdate()
// })
}, },
computed: { computed: {
changeQuestionIndex() { changeQuestionIndex() {
return this.questionParams.questionIndex return this.questionParams.answerRecord
},
isClass() {
return (cItem) => {
const currentAnswer = this.questionParams.answerRecord[cItem.question_item_id]
return this.questionParams.questionIndex + 1 === cItem.q_order
? currentAnswer
? currentAnswer[cItem.id]
? currentAnswer[cItem.id].answer.length !== 0
? currentAnswer[cItem.id].sign
? 'stu1 stu2 stu3'
: 'stu1 stu2'
: currentAnswer[cItem.id].sign
? 'stu2 stu3'
: 'stu2'
: 'stu2'
: 'stu2'
: currentAnswer
? currentAnswer[cItem.id]
? currentAnswer[cItem.id].answer.length !== 0
? currentAnswer[cItem.id].sign
? 'stu1 stu3'
: 'stu1'
: currentAnswer[cItem.id].sign
? 'stu3'
: ''
: ''
: ''
}
} }
}, },
methods: { methods: {
monitoringChanges() {
console.log(this.questionParams.answerRecord)
this.$forceUpdate()
},
goQuestion(n) { goQuestion(n) {
this.questionParams.questionIndex = n - 1 this.questionParams.questionIndex = n - 1
} }
}, },
watch: { watch: {
changeQuestionIndex(newV, oldV) { changeQuestionIndex(newV, oldV) {
console.log(111)
this.$forceUpdate() this.$forceUpdate()
} }
} }
......
...@@ -37,33 +37,37 @@ ...@@ -37,33 +37,37 @@
<div class="case-que"> <div class="case-que">
<div class="stem" v-html="questionData.common_content"></div> <div class="stem" v-html="questionData.common_content"></div>
<ul class="topics" :style="{height: contentHeight - 60 + 'px'}"> <ul class="topics" :style="{height: contentHeight - 60 + 'px'}">
<template v-for="(item, index) in questionData.list"> <template v-for="item in questionData.list">
<li :key="'type5' + index"> <template v-if="questionData.group_id === item[0].group_id">
<div class="title"> <template v-for="(listItem, index) in item">
<div class="num">{{ item.q_order }}.</div><div class="des" v-html="item.content"></div> <li :key="'type5' + index">
</div> <div class="title">
<ul :class="item.type == 2 ? 'check-option' : 'radio-option'"><!-- radio-option check-option --> <div class="num">{{ questionData.q_order }}.</div><div class="des" v-html="listItem.question_content"></div>
<template v-if="item.options"> </div>
<template v-for="(items, cIndex) in item.options"> <ul :class="questionData.answer_count > 1 ? 'check-option' : 'radio-option'"><!-- radio-option check-option -->
<li <template v-if="listItem.id === questionData.id">
:id="items.id" <template v-for="(opt, oIndex) in listItem.question_options">
:key="'c' + cIndex" <li
@click="changeOptions(item.type, questionData.question_item_id, questionData.id, items.id)" :id="opt.id"
:class="questionParams.answerRecord[questionData.question_item_id] :key="'c' + oIndex"
? questionParams.answerRecord[questionData.question_item_id][questionData.id] @click="changeOptions(questionData.answer_count > 1 ? 2 : 1, questionData.question_item_id, questionData.id, opt.id)"
? questionParams.answerRecord[questionData.question_item_id][questionData.id].answer.find(id => { return id === items.id }) :class="questionParams.answerRecord[questionData.question_item_id]
? 'active' ? questionParams.answerRecord[questionData.question_item_id][questionData.id]
: '' ? questionParams.answerRecord[questionData.question_item_id][questionData.id].answer.find(id => { return id === opt.id })
: '' ? 'active'
: ''" : ''
> : ''
<div class="icon"></div> : ''"
<div class="txt">{{items.option}}</div> >
</li> <div class="icon"></div>
</template> <div class="txt">{{opt.option}}</div>
</template> </li>
</ul> </template>
</li> </template>
</ul>
</li>
</template>
</template>
</template> </template>
</ul> </ul>
</div> </div>
...@@ -87,52 +91,8 @@ export default { ...@@ -87,52 +91,8 @@ export default {
this.questionData = this.questionParams.question this.questionData = this.questionParams.question
}, },
mounted() { mounted() {
// this.questionData = this.questionParams.question
// console.log(this.questionParams, '=====111')
// this.dataCombined()
}, },
methods: { methods: {
// 重组数据
dataCombined() {
// this.questionParams.question.question_items.map((item, index) => {
// if (parseInt(item.question_item_type) === 5) {
// item.question_list.map(cItem => {
// const currentItem = cItem.list.find(items => { return items.q_order === this.questionParams.questionIndex + 1 })
// if (currentItem) {
// this.questionData = {}
// this.questionData.common_content = cItem.common_content
// this.questionData.list = cItem.list.map(k => {
// if (k.q_order === this.questionParams.questionIndex + 1) {
// this.questionData.id = k.id
// this.questionData.q_order = k.q_order
// typeof k.options === 'string' && (k.options = JSON.parse(k.options))
// return k
// } else {
// return {
// content: k.content,
// q_order: k.q_order
// }
// }
// })
// const key = ['question_item_id', 'question_item_title', 'question_item_type']
// key.map(k => {
// this.questionData[k] = item[k]
// })
// }
// })
// } else {
// const currentItem = item.question_list.find(items => { return items.q_order === this.questionParams.questionIndex + 1 })
// if (currentItem) {
// this.questionData = currentItem
// const key = ['question_item_id', 'question_item_title', 'question_item_type']
// key.map(k => {
// this.questionData[k] = item[k]
// })
// typeof this.questionData.options === 'string' && (this.questionData.options = JSON.parse(currentItem.options))
// }
// }
// })
},
// 选项选择 // 选项选择
changeOptions(type, pId, cId, optId) { changeOptions(type, pId, cId, optId) {
if (parseInt(type) !== 2) { if (parseInt(type) !== 2) {
...@@ -171,6 +131,7 @@ export default { ...@@ -171,6 +131,7 @@ export default {
} }
} }
} }
this.msgCenter.$emit('monitoringChanges')
// Bus.$emit('monitoringChanges') // Bus.$emit('monitoringChanges')
this.$forceUpdate() this.$forceUpdate()
}, },
......
...@@ -16,6 +16,8 @@ router.beforeEach((to, from, next) => { ...@@ -16,6 +16,8 @@ router.beforeEach((to, from, next) => {
next() next()
}) })
Vue.prototype.msgCenter = new Vue()
new Vue({ new Vue({
store, store,
router, router,
......
...@@ -151,7 +151,7 @@ export default { ...@@ -151,7 +151,7 @@ export default {
} else { } else {
this.questionParams.questionIndex + 1 !== this.questionParams.question.total_question_count && (this.questionParams.questionIndex++) this.questionParams.questionIndex + 1 !== this.questionParams.question.total_question_count && (this.questionParams.questionIndex++)
} }
this.setData() this.changeData()
}, },
getTopic() { getTopic() {
const param = { const param = {
...@@ -163,16 +163,15 @@ export default { ...@@ -163,16 +163,15 @@ export default {
.then(response => { .then(response => {
const data = JSON.parse(response.data) const data = JSON.parse(response.data)
this.beforeChangeData = data.sheet this.beforeChangeData = data.sheet
this.afterChangeData = this.addNumber(data.sheet.questions.question_items) this.afterChangeData = this.setData(data.sheet.questions.question_items)
this.questionParams.card = this.addNumber(data.sheet.questions.question_items) this.questionParams.card = this.setData(data.sheet.questions.question_items)
console.log(this.afterChangeData, '===1') this.changeData()
this.setData()
}) })
.finally(() => { .finally(() => {
// this.loaded = true // this.loaded = true
}) })
}, },
addNumber(data) { setData(data) {
let countNum = 0 let countNum = 0
const type = { const type = {
1: '单选题', 1: '单选题',
...@@ -194,8 +193,10 @@ export default { ...@@ -194,8 +193,10 @@ export default {
total_question_count: this.beforeChangeData.questions.total_question_count total_question_count: this.beforeChangeData.questions.total_question_count
} }
if (parseInt(item.question_type) === 5) { if (parseInt(item.question_type) === 5) {
data.common_content = cItem.common_content
data.group_id = cItem.group_id data.group_id = cItem.group_id
data.list = this.mergeData(item.question_list, 'answer_count') data.list = this.mergeData(item.question_list, 'group_id')
data.answer_count = cItem.answer_count
} }
return data return data
}) })
...@@ -206,28 +207,25 @@ export default { ...@@ -206,28 +207,25 @@ export default {
const _arr = [] const _arr = []
let _t = [] let _t = []
let _tmp = null let _tmp = null
if (arr.length) { arr.length && (_tmp = arr[0][str])
_tmp = arr[0][str]
}
for (const i in arr) { for (const i in arr) {
if (arr[i][str] === _tmp) { arr[i][str] === _tmp
_t.push(arr[i]) ? _t.push(arr[i])
} else { : (() => {
_tmp = arr[i][str] _tmp = arr[i][str]
_arr.push(_t) _arr.push(_t)
_t = [arr[i]] _t = [arr[i]]
} })()
} }
_arr.push(_t) _arr.push(_t)
return _arr return _arr
}, },
setData() { changeData() {
this.afterChangeData.map(item => { this.afterChangeData.map(item => {
item.map(cItem => { item.map(cItem => {
cItem.q_order === this.questionParams.questionIndex + 1 && (this.questionParams.question = cItem) cItem.q_order === this.questionParams.questionIndex + 1 && (this.questionParams.question = cItem)
}) })
}) })
console.log(this.questionParams.question)
}, },
getCache() { getCache() {
// action.Exam.getCache(this.$route.params.examId).then(res => { // action.Exam.getCache(this.$route.params.examId).then(res => {
...@@ -249,7 +247,7 @@ export default { ...@@ -249,7 +247,7 @@ export default {
}, },
watch: { watch: {
changeQuestionIndex(newV, oldV) { changeQuestionIndex(newV, oldV) {
this.setData() this.changeData()
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论