Commit 6b2e55e9 authored by Damon's avatar Damon

feat: 提交答案

parent bc18f8f8
const UNI_APP = {
apiUrl: 'http://192.168.0.208:8760',
apiUrl: 'http://192.168.0.204:8760',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'http://deudn.c.pp.cc/',
uCenterUrl: 'http://192.168.0.5:8093/',//'http://rest-u.yunya.com/'
......
......@@ -11,6 +11,7 @@ const install = (Vue, vm) => {
'content-type': 'application/json; charset=utf-8',
},
loadingTime: 800,
showLoading: false,
originalData: true,
})
......
......@@ -69,6 +69,7 @@ export default {
lists: [],
// 答案对错
answer: '',
userAnswer: ''
}
},
watch: {
......@@ -98,6 +99,8 @@ export default {
v.confirm = false // 确认答案
})
this.$set(this.lists[index], 'confirm', true)
// 用户选的答案
this.userAnswer = this.lists[index].sort
// 判断所选答案是否正确
this.answer = this.rightKey.includes(this.lists[index].sort)
? 'pass'
......@@ -114,6 +117,9 @@ export default {
if (num.length > 1) {
// 判断所选答案是否正确
const checkedList = num.map((v) => v.sort)
// 用户选的答案
this.userAnswer = checkedList.join(',')
// 判断所选答案是否正确
this.answer = equar(checkedList, this.rightKey) ? 'pass' : 'fail'
// 处理显示逻辑
this.lists.forEach((v) => {
......@@ -124,7 +130,7 @@ export default {
}
},
submitAnswer() {
this.$emit('change', this.answer, this.lists)
this.$emit('change', this.answer, this.lists, this.userAnswer)
},
},
}
......
......@@ -125,10 +125,10 @@ export default {
this.swiperIndex = current
this.swiperCurrent = current
},
answerChange(status, lists) {
answerChange(status, lists, userAnswer) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
this.$emit("answerChange", status, lists)
this.$emit("answerChange", status, lists, userAnswer)
},
clear () {
this.list = []
......
......@@ -364,14 +364,15 @@ export default {
this.handPapers()
},
// 作答完毕
answerChange(status, lists) {
answerChange(status, lists, userAnswer) {
// 保存答题状态
const item = this.list.find(v => v.index === this.currentIndex)
item.submitStatus = true
item.answerList = lists
item.result = status
item.errShow = this.type === 2 ? true : status === 'fail'
item.userAnswer = userAnswer
if(this.model === 1) this.saveAnswer(item)
// 更新答题卡
if (this.type === 1){
this.questionList[this.currentIndex] = item
......@@ -391,7 +392,7 @@ export default {
// 如果回答错误或者是考试模式,自动进入下一题
if ((status === 'pass' && this.model !== 2) || this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) {
if (this.currentIndex + 1 > this.total - 1) { // 最后一题回答后
if (this.type === 2) {
this.handPapers(1)
this.submit()
......@@ -403,6 +404,18 @@ export default {
})
}
},
// 保存答案
saveAnswer(info) {
const params = {
answer: info.userAnswer,
answerRight: info.result === 'pass',
questionId: info.id,
questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId,
source: this.source
}
this.$u.api.answer([params])
},
// 统计分数
handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
......
......@@ -135,6 +135,7 @@ function request({ currentPage, size, onSuccess, onFailed }, vm) {
}
let item = {
index: i + (currentPage - 1) * size,
id: info.id,
currentPage: currentPage,
total: data.total,
title: content.title,
......
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