|
@@ -100,7 +100,7 @@
|
|
|
:key="oi"
|
|
:key="oi"
|
|
|
class="q-option"
|
|
class="q-option"
|
|
|
:class="{ selected: isSelected(opt.optionLabel) }"
|
|
:class="{ selected: isSelected(opt.optionLabel) }"
|
|
|
- @click="selectAnswer(opt)"
|
|
|
|
|
|
|
+ @click="selectAnswer(oi)"
|
|
|
>
|
|
>
|
|
|
<view class="q-option-label">{{ opt.optionLabel }}</view>
|
|
<view class="q-option-label">{{ opt.optionLabel }}</view>
|
|
|
<view class="q-option-content">
|
|
<view class="q-option-content">
|
|
@@ -250,18 +250,18 @@
|
|
|
},
|
|
},
|
|
|
onHide() {
|
|
onHide() {
|
|
|
this.clearTimer()
|
|
this.clearTimer()
|
|
|
- this.saveCurrentAnswer()
|
|
|
|
|
|
|
+ if (!this.hasSubmitted) this.saveCurrentAnswer()
|
|
|
},
|
|
},
|
|
|
onUnload() {
|
|
onUnload() {
|
|
|
this.clearTimer()
|
|
this.clearTimer()
|
|
|
- this.saveCurrentAnswer()
|
|
|
|
|
|
|
+ if (!this.hasSubmitted) this.saveCurrentAnswer()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
// 加载左侧题号导航
|
|
// 加载左侧题号导航
|
|
|
async loadSidebar() {
|
|
async loadSidebar() {
|
|
|
try {
|
|
try {
|
|
|
const response = await examElExamAttemptReviewSidebar({ attemptId: this.attemptId })
|
|
const response = await examElExamAttemptReviewSidebar({ attemptId: this.attemptId })
|
|
|
- const data = response.data
|
|
|
|
|
|
|
+ const data = response.data.data
|
|
|
this.examInfo = {
|
|
this.examInfo = {
|
|
|
examTypeName: data.examTypeName || '',
|
|
examTypeName: data.examTypeName || '',
|
|
|
examName: data.examName || '',
|
|
examName: data.examName || '',
|
|
@@ -291,7 +291,7 @@
|
|
|
snapshotQuestionId: snapshotQuestionId,
|
|
snapshotQuestionId: snapshotQuestionId,
|
|
|
examScene: 2,
|
|
examScene: 2,
|
|
|
})
|
|
})
|
|
|
- this.$set(this, 'currentQuestion', response.data)
|
|
|
|
|
|
|
+ this.$set(this, 'currentQuestion', response.data.data)
|
|
|
this.$set(this, 'viewAnswerShowType', false)
|
|
this.$set(this, 'viewAnswerShowType', false)
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
uni.showToast({ title: '题目加载失败', icon: 'none' })
|
|
uni.showToast({ title: '题目加载失败', icon: 'none' })
|
|
@@ -301,7 +301,7 @@
|
|
|
async syncRemainingTime() {
|
|
async syncRemainingTime() {
|
|
|
try {
|
|
try {
|
|
|
const response = await examUserExamGetExamSurplusTime({ attemptId: this.attemptId })
|
|
const response = await examUserExamGetExamSurplusTime({ attemptId: this.attemptId })
|
|
|
- this.remainingSeconds = Number(response.data) || 0
|
|
|
|
|
|
|
+ this.remainingSeconds = Number(response.data.data) || 0
|
|
|
this.clearTimer()
|
|
this.clearTimer()
|
|
|
this.startTimer()
|
|
this.startTimer()
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -330,16 +330,15 @@
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
// 选择答案
|
|
// 选择答案
|
|
|
- selectAnswer(opt) {
|
|
|
|
|
- if (!this.currentQuestion.snapshotQuestionId) return
|
|
|
|
|
|
|
+ selectAnswer(optIndex) {
|
|
|
|
|
+ const opt = (this.currentQuestion.options || [])[optIndex]
|
|
|
|
|
+ if (!opt || !this.currentQuestion.snapshotQuestionId) return
|
|
|
let tags = Array.isArray(this.currentQuestion.answerTags) ? [...this.currentQuestion.answerTags] : []
|
|
let tags = Array.isArray(this.currentQuestion.answerTags) ? [...this.currentQuestion.answerTags] : []
|
|
|
const qType = this.currentQuestion.questionType
|
|
const qType = this.currentQuestion.questionType
|
|
|
if (qType == 2) {
|
|
if (qType == 2) {
|
|
|
- // 多选
|
|
|
|
|
const idx = tags.indexOf(opt.optionLabel)
|
|
const idx = tags.indexOf(opt.optionLabel)
|
|
|
if (idx === -1) { tags.push(opt.optionLabel) } else { tags.splice(idx, 1) }
|
|
if (idx === -1) { tags.push(opt.optionLabel) } else { tags.splice(idx, 1) }
|
|
|
} else {
|
|
} else {
|
|
|
- // 单选 / 判断
|
|
|
|
|
tags = [opt.optionLabel]
|
|
tags = [opt.optionLabel]
|
|
|
}
|
|
}
|
|
|
this.$set(this.currentQuestion, 'answerTags', tags)
|
|
this.$set(this.currentQuestion, 'answerTags', tags)
|
|
@@ -359,10 +358,9 @@
|
|
|
snapshotQuestionId: q.snapshotQuestionId,
|
|
snapshotQuestionId: q.snapshotQuestionId,
|
|
|
userAnswer: tags.join(','),
|
|
userAnswer: tags.join(','),
|
|
|
}).then(response => {
|
|
}).then(response => {
|
|
|
- // response.data 是 isCorrect 值(1正确 0错误)
|
|
|
|
|
const groups = this.questionTypeGroups
|
|
const groups = this.questionTypeGroups
|
|
|
if (groups[this.groupIndex] && groups[this.groupIndex].questions[this.questionIndex]) {
|
|
if (groups[this.groupIndex] && groups[this.groupIndex].questions[this.questionIndex]) {
|
|
|
- this.$set(groups[this.groupIndex].questions[this.questionIndex], 'isCorrect', response.data)
|
|
|
|
|
|
|
+ this.$set(groups[this.groupIndex].questions[this.questionIndex], 'isCorrect', response.data.data)
|
|
|
}
|
|
}
|
|
|
}).catch(e => {
|
|
}).catch(e => {
|
|
|
console.error('保存答案失败', e)
|
|
console.error('保存答案失败', e)
|
|
@@ -453,7 +451,7 @@
|
|
|
const response = await examUserExamSubmit({ attemptId: this.attemptId })
|
|
const response = await examUserExamSubmit({ attemptId: this.attemptId })
|
|
|
this.hasSubmitted = true
|
|
this.hasSubmitted = true
|
|
|
this.clearTimer()
|
|
this.clearTimer()
|
|
|
- this.buildResult(response.data)
|
|
|
|
|
|
|
+ this.buildResult(response.data.data)
|
|
|
this.showResult = true
|
|
this.showResult = true
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
uni.showToast({ title: '交卷失败', icon: 'none' })
|
|
uni.showToast({ title: '交卷失败', icon: 'none' })
|
|
@@ -481,7 +479,7 @@
|
|
|
async retakeExam() {
|
|
async retakeExam() {
|
|
|
try {
|
|
try {
|
|
|
const response = await examUserExamStart({ examId: this.examId, examScene: 2 })
|
|
const response = await examUserExamStart({ examId: this.examId, examScene: 2 })
|
|
|
- const data = response.data
|
|
|
|
|
|
|
+ const data = response.data.data
|
|
|
if (data && data.attemptId) {
|
|
if (data && data.attemptId) {
|
|
|
this.attemptId = data.attemptId
|
|
this.attemptId = data.attemptId
|
|
|
this.showResult = false
|
|
this.showResult = false
|
|
@@ -497,7 +495,7 @@
|
|
|
this.pageLoading = true
|
|
this.pageLoading = true
|
|
|
this.loadSidebar()
|
|
this.loadSidebar()
|
|
|
} else {
|
|
} else {
|
|
|
- uni.showToast({ title: response.message || '重新考试失败', icon: 'none' })
|
|
|
|
|
|
|
+ uni.showToast({ title: response.data.message || '重新考试失败', icon: 'none' })
|
|
|
uni.navigateBack()
|
|
uni.navigateBack()
|
|
|
}
|
|
}
|
|
|
} catch (e) {
|
|
} catch (e) {
|