feat: 考试模块接口对接

This commit is contained in:
cgd_mac 2022-01-17 21:58:52 +08:00
parent 73caca04a8
commit 56874cf27a
7 changed files with 95 additions and 30 deletions

View File

@ -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) {

View File

@ -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: () => ({})

View File

@ -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:

View File

@ -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: [

View File

@ -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 }
})
}
}

View File

@ -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)
})
}
}
}

View File

@ -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 => {