feat: 我的练习接口对接
This commit is contained in:
parent
103ad546cb
commit
c7f51a10dc
|
@ -8,7 +8,16 @@ const practiceApi = {
|
|||
collectionList: 'practice/collection/pageList', // 我的收藏列表
|
||||
recordList: 'practice/record/pageList', // 答题记录
|
||||
wrongList: 'practice/wrong/pageList', // 错题集
|
||||
startAnswer: 'practice/startAnswer' // 开始答题
|
||||
startAnswer: 'practice/startAnswer', // 开始答题
|
||||
executeSubmit: 'practice/executeSubmit', // 练习交卷
|
||||
}
|
||||
|
||||
export function practiceExecuteSubmit(data) {
|
||||
return request({
|
||||
url: practiceApi.executeSubmit,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function practiceStartAnswer(params) {
|
||||
|
|
|
@ -2,20 +2,20 @@
|
|||
<div class="question-item">
|
||||
<div class="question-title">
|
||||
<span>{{ questionIndex || 1 }}、</span>
|
||||
<span>({{ type | QuestionTypeFormat }})</span>
|
||||
<span v-html="title"></span>
|
||||
<span>({{ $getQuestionTypeText(data.questionType) }})</span>
|
||||
<span v-html="data.questionName"></span>
|
||||
</div>
|
||||
<div class="options-box">
|
||||
<ul class="answer-list">
|
||||
<!-- <li :class="{'success-li' : index == 2}" v-for="(item, index) in options" :key="index">
|
||||
<span>{{ optionKeys[index] }}、</span>{{ item.label }}
|
||||
</li> -->
|
||||
<li v-if="data.answerA || data.answerA === 0" :class="{'success-li' : data.rightAnswers == 'A'}"><span>A、</span>{{ data.answerA }}</li>
|
||||
<li v-if="data.answerB || data.answerB === 0" :class="{'success-li' : data.rightAnswers == 'B'}"><span>B、</span>{{ data.answerB }}</li>
|
||||
<li v-if="data.answerC || data.answerC === 0" :class="{'success-li' : data.rightAnswers == 'C'}"><span>C、</span>{{ data.answerC }}</li>
|
||||
<li v-if="data.answerD || data.answerD === 0" :class="{'success-li' : data.rightAnswers == 'D'}"><span>D、</span>{{ data.answerD }}</li>
|
||||
<li v-if="data.answerE || data.answerE === 0" :class="{'success-li' : data.rightAnswers == 'E'}"><span>E、</span>{{ data.answerE }}</li>
|
||||
<li v-if="data.answerF || data.answerF === 0" :class="{'success-li' : data.rightAnswers == 'F'}"><span>F、</span>{{ data.answerF }}</li>
|
||||
<li v-if="data.answerA || data.answerA === 0" :class="{'success-li' : data.rightAnswers.indexOf('A') !== -1}"><span>A、</span>{{ data.answerA }}</li>
|
||||
<li v-if="data.answerB || data.answerB === 0" :class="{'success-li' : data.rightAnswers.indexOf('B') !== -1}"><span>B、</span>{{ data.answerB }}</li>
|
||||
<li v-if="data.answerC || data.answerC === 0" :class="{'success-li' : data.rightAnswers.indexOf('C') !== -1}"><span>C、</span>{{ data.answerC }}</li>
|
||||
<li v-if="data.answerD || data.answerD === 0" :class="{'success-li' : data.rightAnswers.indexOf('D') !== -1}"><span>D、</span>{{ data.answerD }}</li>
|
||||
<li v-if="data.answerE || data.answerE === 0" :class="{'success-li' : data.rightAnswers.indexOf('E') !== -1}"><span>E、</span>{{ data.answerE }}</li>
|
||||
<li v-if="data.answerF || data.answerF === 0" :class="{'success-li' : data.rightAnswers.indexOf('F') !== -1}"><span>F、</span>{{ data.answerF }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="flex-center justify-between" style="margin-top: 10px;">
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="question-title">
|
||||
<span>{{ index || 1 }}、</span>
|
||||
<span>({{ $getQuestionTypeText(type) }})</span>
|
||||
<span v-html="title"></span>
|
||||
<span v-html="data.questionName"></span>
|
||||
</div>
|
||||
<div class="options-box">
|
||||
<!-- 单选题选项 -->
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<template v-if="wrongInfo.list && wrongInfo.list.length>0">
|
||||
<template v-for="(item, index) in wrongInfo.list" >
|
||||
<div :key="index">
|
||||
<DbQuestionInfoItem :questionIndex="index+1" ></DbQuestionInfoItem>
|
||||
<DbQuestionInfoItem :data="item" :questionIndex="index+1" ></DbQuestionInfoItem>
|
||||
<a-divider></a-divider>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
<script>
|
||||
import DbExam from '@/components/DbExam/index'
|
||||
import { practiceStartAnswer } from '@/api/practice/practice'
|
||||
import { practiceStartAnswer, practiceExecuteSubmit } from '@/api/practice/practice'
|
||||
import _ from 'lodash'
|
||||
export default {
|
||||
components: { DbExam },
|
||||
data () {
|
||||
|
@ -38,8 +39,47 @@ export default {
|
|||
})
|
||||
},
|
||||
// 提交
|
||||
handlerSubmit (data) {
|
||||
console.log('this.data', data)
|
||||
handlerSubmit (result) {
|
||||
const { type } = this.query
|
||||
if (type === 'practice') {
|
||||
this.submitPractice(result)
|
||||
}
|
||||
},
|
||||
// 提交练习
|
||||
submitPractice (result) {
|
||||
const data = { ...result }
|
||||
const query = this.query
|
||||
const params = {
|
||||
projectId: query.projectId,
|
||||
courseId: query.courseId,
|
||||
answerTime: 0,
|
||||
type: query.practiceType,
|
||||
questionList: []
|
||||
}
|
||||
const allQuestion = []
|
||||
const question = data.question
|
||||
if (question && question.length > 0) {
|
||||
question.map(item => {
|
||||
if (item.questionList && item.questionList.length > 0) {
|
||||
item.questionList.map(j => {
|
||||
let myAnswers = j.myAnswers
|
||||
if (item.type != 2 && _.isArray(myAnswers)) {
|
||||
myAnswers = myAnswers.join(',')
|
||||
}
|
||||
allQuestion.push({
|
||||
questionId: j.questionId,
|
||||
answerTime: 0,
|
||||
myAnswers: myAnswers
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
params.questionList = allQuestion
|
||||
practiceExecuteSubmit(params).then(() => {
|
||||
this.$message.success('交卷成功!')
|
||||
this.$router.go(-1)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue