Commit c7de1097 by 陈超

A

parent 7dc091c5
...@@ -403,7 +403,8 @@ ...@@ -403,7 +403,8 @@
countDown: "00:00:00", countDown: "00:00:00",
expand: false, expand: false,
//选项 //选项
currentOptions: [] currentOptions: [],
finished: []
} }
}, },
computed: { computed: {
...@@ -467,8 +468,6 @@ ...@@ -467,8 +468,6 @@
currentMyOptions: function() { currentMyOptions: function() {
let cur = this.currentRightOptions let cur = this.currentRightOptions
return this.currentOptions.filter( r => { return r.selected }).map( r => { return this.currentOptions.filter( r => { return r.selected }).map( r => {
console.log(r)
console.log(cur.hx_indexOf( k => { return k == r.key }))
return { return {
right: cur.hx_indexOf( k => { return k == r.key }) != -1, right: cur.hx_indexOf( k => { return k == r.key }) != -1,
key: r.key key: r.key
...@@ -489,19 +488,44 @@ ...@@ -489,19 +488,44 @@
this.info = {:json_encode($paper)}; this.info = {:json_encode($paper)};
this.temp = {:json_encode($tempData)}; this.temp = {:json_encode($tempData)};
this.paperOptions = {:json_encode($paper_options)}; this.paperOptions = {:json_encode($paper_options)};
for(let k in this.currentQuestion.answer_options) { this.initAnswerMode()
let value = this.currentQuestion.answer_options[k] 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({ this.currentOptions.push({
key: k, key: k,
value: value, value: value,
selected: false selected: select
}) })
} }
console.log(this.info) break
console.log(this.temp) }
console.log(this.paperOptions) },
recordData: function() {
return {
paperId: this.info.exams_paper_id,
timeConsumed: 1,
questionIndex: this.current,
finished: this.finished
}
}, },
methods: {
countDown: function() { countDown: function() {
let time = 1 let time = 1
let hours = Math.floor(time / 3600) let hours = Math.floor(time / 3600)
...@@ -530,6 +554,7 @@ ...@@ -530,6 +554,7 @@
}, },
onNextQuestion: function() { onNextQuestion: function() {
if(this.current < this.totalQuestion) { if(this.current < this.totalQuestion) {
this.cacheQuestion()
this.current += 1 this.current += 1
} else { } else {
ui.confirm("已经是最后一题了,是否交卷?", { // 是否返回第一题 ui.confirm("已经是最后一题了,是否交卷?", { // 是否返回第一题
...@@ -543,6 +568,32 @@ ...@@ -543,6 +568,32 @@
if(this.current > 1) { if(this.current > 1) {
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