Commit c7de1097 by 陈超

A

parent 7dc091c5
......@@ -403,7 +403,8 @@
countDown: "00:00:00",
expand: false,
//选项
currentOptions: []
currentOptions: [],
finished: []
}
},
computed: {
......@@ -467,8 +468,6 @@
currentMyOptions: function() {
let cur = this.currentRightOptions
return this.currentOptions.filter( r => { return r.selected }).map( r => {
console.log(r)
console.log(cur.hx_indexOf( k => { return k == r.key }))
return {
right: cur.hx_indexOf( k => { return k == r.key }) != -1,
key: r.key
......@@ -489,19 +488,44 @@
this.info = {:json_encode($paper)};
this.temp = {:json_encode($tempData)};
this.paperOptions = {:json_encode($paper_options)};
for(let k in this.currentQuestion.answer_options) {
let value = this.currentQuestion.answer_options[k]
this.currentOptions.push({
key: k,
value: value,
selected: false
})
}
this.initAnswerMode()
console.log(this.info)
console.log(this.temp)
console.log(this.paperOptions)
},
watch: {
current: func(o, n) {
this.initAnswerMode()
}
},
methods: {
initAnswerMode: function() {
let q = this.currentQuestionTypeKey
switch(q) {
case "radio":
this.currentOptions = []
let Q = this.currentQuestion
let old = this.finished.hx_firstOf( r => { return r.qId == Q.exams_question_id })
for(let k in Q.answer_options) {
let value = Q.answer_options[k]
let select = old ? old.option == k : false
this.currentOptions.push({
key: k,
value: value,
selected: select
})
}
break
}
},
recordData: function() {
return {
paperId: this.info.exams_paper_id,
timeConsumed: 1,
questionIndex: this.current,
finished: this.finished
}
},
countDown: function() {
let time = 1
let hours = Math.floor(time / 3600)
......@@ -530,6 +554,7 @@
},
onNextQuestion: function() {
if(this.current < this.totalQuestion) {
this.cacheQuestion()
this.current += 1
} else {
ui.confirm("已经是最后一题了,是否交卷?", { // 是否返回第一题
......@@ -543,6 +568,32 @@
if(this.current > 1) {
this.current -= 1
}
},
cacheQuestion: function() {
let q = this.currentQuestion
let mode = this.finished.hx_firstOf( r => { return r.qId == q.exams_question_id })
if(mode) {
switch(this.currentQuestionTypeKey) {
case "radio":
let my = this.currentMyOptions
if(my.length > 0) {
mode.option = my[0].key
}
break
}
} else {
switch(this.currentQuestionTypeKey) {
case "radio":
let my = this.currentMyOptions
if(my.length > 0) {
this.finished.push({
qId: q.exams_question_id,
option: my[0].key
})
}
break
}
}
}
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment