From d196e97a2ff77767268d3e55f07c37c8ce06258c Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 02 Mar 2022 15:56:16 +0800
Subject: [PATCH] 考试相关添加,页面等
---
pages/exam/examTextPage.vue | 184 +++++++++++++++++----------------------------
1 files changed, 69 insertions(+), 115 deletions(-)
diff --git a/pages/exam/examTextPage.vue b/pages/exam/examTextPage.vue
index a21fcf4..316e990 100644
--- a/pages/exam/examTextPage.vue
+++ b/pages/exam/examTextPage.vue
@@ -5,8 +5,7 @@
<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>
@@ -15,7 +14,8 @@
<script>
import Answer from '@/components/dyw-answer/answer.vue';
import {
- enterExam
+ enterExam,
+ submitExam
} from '@/common/api/exam'
import {
ModifyQuesList
@@ -25,88 +25,36 @@
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
@@ -120,52 +68,58 @@
// 已确认进行答案提交
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)
}
}
}
--
Gitblit v1.9.3