feat: 考试模块接口对接
This commit is contained in:
parent
73caca04a8
commit
56874cf27a
|
@ -4,7 +4,25 @@ const examApi = {
|
|||
examList: 'exam/list', // 我的考试-预约考试列表
|
||||
attendList: 'exam/attend', // 我的考试-已参加考试
|
||||
exam: 'exam/exam', // 我的考试进入考试
|
||||
viewReport: 'exam/viewReport' // 查看报告
|
||||
viewReport: 'exam/viewReport', // 查看报告
|
||||
viewResolution: 'exam/viewResolution', // 查看解析
|
||||
submit: 'exam/submit' // 交卷
|
||||
}
|
||||
|
||||
export function reqExamViewResolution (data) {
|
||||
return request({
|
||||
url: examApi.viewResolution,
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
export function reqExamSubmit (data) {
|
||||
return request({
|
||||
url: examApi.submit,
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function reqExamList (params) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<div class="exam-title">{{ data.courseName }}</div>
|
||||
<div class="exam-main">
|
||||
<div v-for="(item, index) in data.question" :key="index">
|
||||
<div class="sub-title">{{ $getCapitalizeNumber(index) }}、{{ $getQuestionTypeText(item.questionType) }}(共30题,每题1.5分,共45分)</div>
|
||||
<div class="sub-title">{{ $getCapitalizeNumber(index) }}、{{ $getQuestionTypeText(item.questionType) }}<span v-if="type === 'exam'">(共{{ item.questionCount }}题,每题{{ item.questionScore }}分,共{{ item.totalScore }}分)</span></div>
|
||||
<DbQuestionItem
|
||||
:id="`type${item.questionType}-${k}`"
|
||||
:index="j.orderNumber"
|
||||
|
@ -68,6 +68,10 @@ import DbQuestionItem from '@/components/DbQuestionItem/index'
|
|||
import DbAnswerCard from '@/components/DbAnswerCard/index'
|
||||
export default {
|
||||
props: {
|
||||
type: {
|
||||
type: String,
|
||||
default: 'exam'
|
||||
},
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
<!-- 判断题选项 -->
|
||||
<template v-if="type == 3">
|
||||
<a-radio-group v-model="data.myAnswers">
|
||||
<a-radio v-if="data.answerA" :style="radioStyle" value="A"><span>A、</span>{{ data.answerA }}</a-radio>
|
||||
<a-radio v-if="data.answerB" :style="radioStyle" value="B"><span>B、</span>{{ data.answerB }}</a-radio>
|
||||
<a-radio :style="radioStyle" value="A"><span>A、</span>{{ data.answerA || '正确' }}</a-radio>
|
||||
<a-radio :style="radioStyle" value="B"><span>B、</span>{{ data.answerB || '错误' }}</a-radio>
|
||||
</a-radio-group>
|
||||
</template>
|
||||
<!-- 填空题 -->
|
||||
|
@ -83,7 +83,8 @@
|
|||
export default {
|
||||
props: {
|
||||
index: {
|
||||
type: Number
|
||||
type: Number,
|
||||
default: 0
|
||||
}, // 题目序号
|
||||
type: {
|
||||
type: [String, Number], // 1: 单选, 2: 多选, 3: 判断题, 4: 填空题, 5: 简答题
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
<a-card title="得分统计" :bordered="false">
|
||||
<a-row :gutter="30" style="margin: 15px 0;">
|
||||
<a-col :span="12" class="flex-center">
|
||||
<a-progress type="circle" :percent="75" :format="percent => `${percent} 分`" />
|
||||
<a-progress type="circle" :percent="score/totalScore * 100" :format="percent => `${percent} 分`" />
|
||||
</a-col>
|
||||
<a-col class="count-info" :span="12">
|
||||
<div>共30道题,答对15道。总用时30分钟</div>
|
||||
<div>已击败考生10%的考生</div>
|
||||
<div>全站平均得分70分</div>
|
||||
<div>共{{ data.totalQuestions }}道题,答对{{ data.rightQuestions }}道。总用时{{ data.answerTime }}分钟</div>
|
||||
<div>已击败考生{{ data.beat }}%的考生</div>
|
||||
<div>全站平均得分{{ data.avgScore }}分</div>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
|
@ -28,7 +28,7 @@
|
|||
<a-col :span="24" style="margin-top: 15px;">
|
||||
<a-card title="答题卡" :bordered="false">
|
||||
<ul class="answer-box">
|
||||
<li class="flex-center" v-for="(item, index) in 50" :key="index">{{item+1}}</li>
|
||||
<li class="flex-center" v-for="(item, index) in data.reportItems" :key="index">{{ index+1 }}</li>
|
||||
</ul>
|
||||
</a-card>
|
||||
</a-col>
|
||||
|
@ -39,6 +39,12 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
columns: [
|
||||
|
|
|
@ -129,7 +129,7 @@ export default {
|
|||
handlerGoReport (item, type) {
|
||||
this.$router.push({
|
||||
path: '/myreport',
|
||||
query: { type: type, reportId: item.reportId }
|
||||
query: { type: 'practice', index: type, reportId: item.reportId }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<script>
|
||||
import DbExam from '@/components/DbExam/index'
|
||||
import { practiceStartAnswer, practiceExecuteSubmit } from '@/api/practice/practice'
|
||||
import { reqExamExam } from '@/api/myexam/exam.js'
|
||||
import { reqExamExam, reqExamSubmit } from '@/api/myexam/exam.js'
|
||||
import _ from 'lodash'
|
||||
export default {
|
||||
components: { DbExam },
|
||||
|
@ -42,7 +42,8 @@ export default {
|
|||
},
|
||||
// 获取考试详情
|
||||
getExamDetail () {
|
||||
reqExamExam({ projectId: this.query.projectId }).then((res) => {
|
||||
const { person } = this.$store.state.user
|
||||
reqExamExam({ personId: person.id, projectId: this.query.projectId }).then((res) => {
|
||||
this.examData = res.data
|
||||
})
|
||||
},
|
||||
|
@ -52,18 +53,13 @@ export default {
|
|||
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: []
|
||||
if (type === 'exam') {
|
||||
this.submitExam(result)
|
||||
}
|
||||
},
|
||||
// 格式化题目答案
|
||||
formatSubmit (result) {
|
||||
const data = { ...result }
|
||||
const allQuestion = []
|
||||
const question = data.question
|
||||
if (question && question.length > 0) {
|
||||
|
@ -71,10 +67,18 @@ export default {
|
|||
if (item.questionList && item.questionList.length > 0) {
|
||||
item.questionList.map(j => {
|
||||
let myAnswers = j.myAnswers
|
||||
if (item.type != 2 && _.isArray(myAnswers)) {
|
||||
myAnswers = myAnswers.join(',')
|
||||
// const myAnswers = j.myAnswers
|
||||
// if (item.type != 2 && _.isArray(myAnswers)) {
|
||||
// myAnswers = myAnswers.join(',')
|
||||
// }
|
||||
console.log("item.questionType", item.questionType)
|
||||
if (['1', '3'].indexOf(item.questionType) !== -1 && myAnswers) {
|
||||
console.log('item.type', item.questionType)
|
||||
myAnswers = [myAnswers]
|
||||
}
|
||||
console.log('myAnswers', myAnswers)
|
||||
allQuestion.push({
|
||||
...j,
|
||||
questionId: j.questionId,
|
||||
answerTime: 0,
|
||||
myAnswers: myAnswers
|
||||
|
@ -83,11 +87,37 @@ export default {
|
|||
}
|
||||
})
|
||||
}
|
||||
params.questionList = allQuestion
|
||||
return allQuestion
|
||||
},
|
||||
// 提交练习
|
||||
submitPractice (result) {
|
||||
const query = this.query
|
||||
const params = {
|
||||
projectId: query.projectId,
|
||||
courseId: query.courseId,
|
||||
answerTime: 0,
|
||||
type: query.practiceType,
|
||||
questionList: this.formatSubmit(result)
|
||||
}
|
||||
practiceExecuteSubmit(params).then(() => {
|
||||
this.$message.success('交卷成功!')
|
||||
this.$router.go(-1)
|
||||
})
|
||||
},
|
||||
// 提交考试
|
||||
submitExam (result) {
|
||||
const query = this.query
|
||||
const params = {
|
||||
projectId: query.projectId,
|
||||
courseId: query.courseId,
|
||||
answerTime: 0,
|
||||
type: query.practiceType,
|
||||
questionList: this.formatSubmit(result)
|
||||
}
|
||||
reqExamSubmit(params).then(() => {
|
||||
this.$message.success('交卷成功!')
|
||||
this.$router.go(-1)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<template slot="title">
|
||||
<h3>{{ viewReport.courseName }}</h3>
|
||||
<div class="sub-info"><span>交卷时间:{{ viewReport.submitTime }}</span><span v-if="viewReport.totalScore">答题用时:{{ viewReport.totalScore }}</span></div>
|
||||
<DbReport :data="viewReport.reportItems"></DbReport>
|
||||
<DbReport :data="viewReport"></DbReport>
|
||||
</template>
|
||||
</a-card>
|
||||
</a-tab-pane>
|
||||
|
@ -14,7 +14,7 @@
|
|||
<a-card :bordered="false" :bodyStyle="{padding: '0px !important'}" :headStyle="{paddingLeft: '0px !important'}">
|
||||
<template slot="title">
|
||||
<h4>{{ viewReport.courseName }}</h4>
|
||||
<div class="sub-info"><span>选择题30/30</span><span>选择题30/30</span><span>选择题30/30</span></div>
|
||||
<!-- <div class="sub-info"><span>选择题30/30</span><span>选择题30/30</span><span>选择题30/30</span></div> -->
|
||||
</template>
|
||||
<template v-for="(item, index) in viewResolution" >
|
||||
<div :key="index">
|
||||
|
@ -32,7 +32,7 @@
|
|||
import DbQuestionInfoItem from '@/components/DbQuestionInfoItem/index.vue'
|
||||
import DbReport from '@/components/DbReport/index.vue'
|
||||
import { answerViewReport, answerViewResolution } from '@/api/practice/report'
|
||||
import { reqExamViewReport } from '@/api/myexam/exam.js'
|
||||
import { reqExamViewReport, reqExamViewResolution } from '@/api/myexam/exam.js'
|
||||
|
||||
export default {
|
||||
components: { DbQuestionInfoItem, DbReport },
|
||||
|
@ -53,6 +53,7 @@ export default {
|
|||
}
|
||||
if (query.type === 'exam') {
|
||||
this.getExamViewReport()
|
||||
this.getExamViewResolution()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -62,6 +63,11 @@ export default {
|
|||
this.viewReport = res.data
|
||||
})
|
||||
},
|
||||
getExamViewResolution () {
|
||||
reqExamViewResolution({ projectId: this.query.reportId }).then(res => {
|
||||
this.viewResolution = res.data
|
||||
})
|
||||
},
|
||||
// 练习 start
|
||||
getAnswerViewReport () {
|
||||
answerViewReport({ reportId: Number(this.query.reportId) }).then(res => {
|
||||
|
|
Loading…
Reference in New Issue