| | |
| | | <u-modal v-model="show" :content="content" :show-cancel-button="true" @confirm="handleConfirm"></u-modal> |
| | | |
| | | <!-- 渲染题目 --> |
| | | <Answer :isReviewed='isReview' :examType="examType" @submit='handleCommit' @timeEnd='handleConfirm' |
| | | @onChange='onChange'></Answer> |
| | | <Answer @submit='handleCommit' @timeEnd='handleConfirm' @onChange='onChange'></Answer> |
| | | |
| | | <u-toast ref="uToast" /> |
| | | </view> |
| | |
| | | <script> |
| | | import Answer from '@/components/dyw-answer/answer.vue'; |
| | | import { |
| | | enterExam |
| | | enterExam, |
| | | submitExam |
| | | } from '@/common/api/exam' |
| | | import { |
| | | ModifyQuesList |
| | |
| | | return { |
| | | show: false, |
| | | content: '是否确认交卷', |
| | | isReview: false, |
| | | questionList: [], |
| | | examType: 'exam', //考试类型 |
| | | } |
| | | }, |
| | | onLoad(option) { |
| | | this.$store.state.questionList = [] |
| | | |
| | | this.examType = option.examType |
| | | |
| | | var that = this |
| | | if (option.examType == 'exam') { |
| | | // 理论考试 |
| | | enterExam({ |
| | | idCardNo: option.id |
| | | }).then(res => { |
| | | var examObj = res.data.data.simulateExamRecord |
| | | // 理论考试 |
| | | enterExam({ |
| | | idCardNo: option.id |
| | | }).then(res => { |
| | | var examObj = res.data.data.simulateExamRecord |
| | | |
| | | examObj.exam = { |
| | | name: '测试考试', |
| | | examScore: 100, |
| | | examTime: res.data.data.simulateExamRecord.answerTime, |
| | | checkFace: 1, |
| | | ...option |
| | | } |
| | | |
| | | |
| | | examObj.exam = { |
| | | name: '模拟考试', |
| | | examScore: 100, |
| | | examTime: res.data.data.simulateExamRecord.answerTime, |
| | | checkFace: 1, |
| | | ...option |
| | | } |
| | | |
| | | examObj.exam.totalQuestion = res.data.data.examSubjectInfo.length |
| | | examObj.totalQuestion = res.data.data.examSubjectInfo.length |
| | | that.$store.state.examDetail = examObj |
| | | examObj.exam.totalQuestion = res.data.data.examSubjectInfo.length |
| | | examObj.totalQuestion = res.data.data.examSubjectInfo.length |
| | | that.$store.state.examDetail = examObj |
| | | |
| | | // 提取出所有的题目 |
| | | ModifyQuesList(res.data.data.examSubjectInfo) |
| | | }) |
| | | } else if (option.examType == 'paper') { |
| | | // 模拟考试 |
| | | this.$api.paperStart(option.paperId) |
| | | .then(res => { |
| | | console.log('paperStart:', res); |
| | | that.$store.state.examDetail = res.values |
| | | console.log('paper examDetail:', res.values); |
| | | var quesModules = res.values.modules |
| | | that.$api.ModifyQuesList(quesModules) |
| | | console.log(that.$store.state.pracDetail); |
| | | console.log(that.$store.state.pracQuesList); |
| | | }) |
| | | } else if (option.examType == 'know') { |
| | | // 知识点练习 |
| | | const knowSearch = JSON.parse(decodeURIComponent(option.knowSearch)); |
| | | console.log(knowSearch); |
| | | this.$api.startKnow(knowSearch) |
| | | .then(res => { |
| | | if (res.status == 1) { |
| | | // 获取知识点失败 |
| | | this.$refs.uToast.show({ |
| | | title: res.message, |
| | | type: 'error', |
| | | // icon: false, |
| | | url: '/pages/exam/pracIndexKnow' |
| | | }) |
| | | } else { |
| | | console.log('开始知识点练习的请求结果:', res); |
| | | that.$store.state.examDetail = res.values |
| | | var quesModules = res.values.modules |
| | | that.$api.ModifyQuesList(quesModules) |
| | | console.log(that.$store.state.pracDetail); |
| | | console.log(that.$store.state.pracQuesList); |
| | | } |
| | | }) |
| | | } else if (option.examType == 'course') { |
| | | this.$api.startTheory(that.$store.state.access_token, option.paperId) |
| | | .then(res => { |
| | | that.$store.state.examDetail = res.values |
| | | var quesModules = res.values.modules |
| | | that.$api.ModifyQuesList(quesModules) |
| | | }) |
| | | } else { |
| | | console.log("考试类型错误,请输入正确的类型"); |
| | | // return false |
| | | } |
| | | that.$store.state.paperDetail = res.data.data.simulateExamRecord |
| | | // 提取出所有的题目 |
| | | ModifyQuesList(res.data.data.examSubjectInfo) |
| | | }) |
| | | |
| | | console.log('考题列表:', this.questionList); |
| | | }, |
| | | components: { |
| | | Answer |
| | |
| | | |
| | | // 已确认进行答案提交 |
| | | handleConfirm() { |
| | | // 进行交卷的api请求 |
| | | let that = this |
| | | if (this.examType == 'exam') { |
| | | this.$api.commitExam(this.$store.state.examDetail.exam.id, this.$store.state.examDetail.recordId) |
| | | .then(res => { |
| | | console.log('交卷:', res); |
| | | that.$u.route('/pages/exam/examResultPage', { |
| | | recordId: that.$store.state.examDetail.recordId, |
| | | examType: 'exam' |
| | | }) |
| | | }) |
| | | } else if ((this.examType == 'paper') || (this.examType == 'know')) { |
| | | this.$api.commitPaper(this.$store.state.examDetail.exerciseId) |
| | | .then(res => { |
| | | console.log('交卷:', res); |
| | | that.$u.route('/pages/exam/examResultPage', { |
| | | exerciseId: that.$store.state.examDetail.exerciseId, |
| | | examType: 'paper', |
| | | }) |
| | | }) |
| | | } else if (this.examType == 'store') { |
| | | this.$api.commitExam(this.$store.state.examDetail.exam.id, this.$store.state.examDetail.recordId) |
| | | .then(res => { |
| | | console.log('交卷:', res); |
| | | that.$u.route('/pages/exam/examResultPage', { |
| | | recordId: that.$store.state.examDetail.recordId, |
| | | examType: 'exam' |
| | | }) |
| | | }) |
| | | } else if (this.examType == 'course') { |
| | | this.$api.commitCourse(this.$store.state.access_token, this.$store.state.examDetail.exerciseId) |
| | | .then(res => { |
| | | console.log('交卷:', res); |
| | | that.$u.route('/pages/exam/examResultPage', { |
| | | exerciseId: that.$store.state.examDetail.exerciseId, |
| | | examType: 'course', |
| | | }) |
| | | }) |
| | | } else { |
| | | console.log("提交的考试类型出错"); |
| | | let totalQueNum = 0 |
| | | let rightQueNum = 0 |
| | | let wrongQueNum = 0 |
| | | let noneQueNum = 0 |
| | | let score = 0 |
| | | |
| | | let sendData = { |
| | | simulateExamId: this.$store.state.paperDetail.id, |
| | | examResultVOS: [] |
| | | } |
| | | |
| | | this.$store.state.questionList.forEach(item => { |
| | | if (item.selectedFlag == true) { |
| | | |
| | | let obj = { |
| | | subjectChoicesId: item.id, |
| | | value: item.tempAnswer, |
| | | grade: item.score |
| | | } |
| | | |
| | | if (item.correctOrError == false) { |
| | | obj.grade = 0 |
| | | wrongQueNum += 1 |
| | | } else { |
| | | rightQueNum += 1 |
| | | score += item.score |
| | | } |
| | | |
| | | sendData.examResultVOS.push(obj) |
| | | |
| | | } else { |
| | | noneQueNum += 1 |
| | | } |
| | | totalQueNum += 1 |
| | | }) |
| | | |
| | | // 进行交卷的api请求 |
| | | that.$u.route('/pages/exam/examResultPage', { |
| | | recordId: that.$store.state.examDetail.recordId, |
| | | totalQueNum: totalQueNum, |
| | | rightQueNum: rightQueNum, |
| | | wrongQueNum: wrongQueNum, |
| | | noneQueNum: noneQueNum, |
| | | score: score |
| | | }) |
| | | |
| | | submitExam(sendData).then(res => {}) |
| | | }, |
| | | /* 题目答案变化 |
| | | */ |
| | | onChange(answer) { |
| | | console.log(answer) |
| | | } |
| | | } |
| | | } |