提交 4448187d authored 作者: 王鹏飞's avatar 王鹏飞

修改模拟考试

上级 d1cf15c2
import httpRequest from '@/utils/axios' import httpRequest from '@/utils/axios'
/**
* 获取模拟考试试题
*/
export function getExamList(params) {
return httpRequest.get('/api/zy/v2/examination/examination-papers-list', { params })
}
/** /**
* 获取模拟考试试题 * 获取模拟考试试题
*/ */
......
...@@ -54,10 +54,7 @@ import * as api from '@/api/exam.js' ...@@ -54,10 +54,7 @@ import * as api from '@/api/exam.js'
import answerCard from '../../components/answerCard.vue' import answerCard from '../../components/answerCard.vue'
import question from '../../components/question.vue' import question from '../../components/question.vue'
export default { export default {
components: { components: { question, answerCard },
question,
answerCard
},
data() { data() {
return { return {
time: { time: {
...@@ -90,6 +87,20 @@ export default { ...@@ -90,6 +87,20 @@ export default {
handleTime: null handleTime: null
} }
}, },
computed: {
examId() {
return this.$route.query.exam_id
},
changeQuestionIndex() {
return this.questionParams.questionIndex
}
},
watch: {
// 监听题的变化
changeQuestionIndex(newV, oldV) {
this.changeData()
}
},
beforeDestroy() { beforeDestroy() {
// this.handlePapers() // this.handlePapers()
clearInterval(this.handleTime) clearInterval(this.handleTime)
...@@ -130,8 +141,15 @@ export default { ...@@ -130,8 +141,15 @@ export default {
// 收藏试题 // 收藏试题
collectQuestion() { collectQuestion() {
const data = this.questionParams.question const data = this.questionParams.question
data.isCollection if (data.isCollection) {
? this.removeCall(data.id, () => { data.isCollection = false }) : this.addCall(data.id, () => { data.isCollection = true }) this.removeCall(data.id, () => {
data.isCollection = false
})
} else {
this.addCall(data.id, () => {
data.isCollection = true
})
}
}, },
addCall(id, call) { addCall(id, call) {
api.addCollection({ question_id: id }).then(response => { api.addCollection({ question_id: id }).then(response => {
...@@ -203,6 +221,7 @@ export default { ...@@ -203,6 +221,7 @@ export default {
getTopic() { getTopic() {
const param = { const param = {
type: 2, type: 2,
paper_id: this.examId,
is_create: this.$route.query.id || this.$route.query.is_create === undefined ? 0 : this.$route.query.is_create is_create: this.$route.query.id || this.$route.query.is_create === undefined ? 0 : this.$route.query.is_create
} }
api.getExamQuestion(param).then(response => { api.getExamQuestion(param).then(response => {
...@@ -274,7 +293,10 @@ export default { ...@@ -274,7 +293,10 @@ export default {
return this.A_Z()[findIndex] return this.A_Z()[findIndex]
}) })
data.question_analysis = cItem.question_analysis data.question_analysis = cItem.question_analysis
optGroup = findAB.sort().toString().replace(new RegExp(',', 'g'), '') optGroup = findAB
.sort()
.toString()
.replace(new RegExp(',', 'g'), '')
data.question_answer = optGroup data.question_answer = optGroup
} }
} }
...@@ -314,11 +336,13 @@ export default { ...@@ -314,11 +336,13 @@ export default {
let _tmp = null let _tmp = null
arr.length && (_tmp = arr[0][str]) arr.length && (_tmp = arr[0][str])
for (const i in arr) { for (const i in arr) {
arr[i][str] === _tmp ? _t.push(arr[i]) : (() => { if (arr[i][str] === _tmp) {
_t.push(arr[i])
} else {
_tmp = arr[i][str] _tmp = arr[i][str]
_arr.push(_t) _arr.push(_t)
_t = [arr[i]] _t = [arr[i]]
})() }
} }
_arr.push(_t) _arr.push(_t)
return _arr return _arr
...@@ -367,17 +391,6 @@ export default { ...@@ -367,17 +391,6 @@ export default {
return item.filter(is => is) return item.filter(is => is)
}) })
} }
},
computed: {
changeQuestionIndex() {
return this.questionParams.questionIndex
}
},
watch: {
// 监听题的变化
changeQuestionIndex(newV, oldV) {
this.changeData()
}
} }
} }
</script> </script>
......
<template> <template>
<app-container title="模拟考试介绍"> <app-container title="模拟考试">
<div class="desc-exam"> <ul class="exam-list">
<p>考试时间20分钟。</p> <li v-for="item in examList" :key="item.id" class="exam-item" @click="startExam(item)">
<p>演示考试题目共10题,全部为单选题。</p> <el-card shadow="hover">
</div> <h3>{{ item.paper_title }}</h3>
<template #footer> <p v-if="[1, 2].includes(item.status)">已完成</p>
<p v-if="[0, 3].includes(item.status)">待完成</p>
<!-- <p>重新考试</p> -->
</el-card>
</li>
</ul>
<!-- <template #footer>
<div class="app-container-ft"><el-button type="primary" @click="getExamStatus">开始考试</el-button></div> <div class="app-container-ft"><el-button type="primary" @click="getExamStatus">开始考试</el-button></div>
</template> </template> -->
</app-container> </app-container>
</template> </template>
...@@ -16,73 +22,60 @@ import AppContainer from '@/components/AppContainer' ...@@ -16,73 +22,60 @@ import AppContainer from '@/components/AppContainer'
export default { export default {
components: { AppContainer }, components: { AppContainer },
data() { data() {
return {} return {
examList: []
}
}, },
mounted() { mounted() {
// this.open() this.getExamList()
}, },
methods: { methods: {
getExamStatus() { getExamList() {
api api.getExamList().then(response => {
.getExamStatus({ type: 2 }) // 考试状态(0,3:已缓存,1:已提交,2:已评阅,100:未做)
.then(response => { this.examList = response.papers
if (response.status === 0 || response.status === 3) { })
this.open() },
} else { startExam(item) {
this.$router.push({ if (item.status === 0 || item.status === 3) {
path: '/testExam/exam', this.open(item)
query: { } else {
is_create: 1 this.$router.push({ path: '/testExam/exam', query: { exam_id: item.id, is_create: 1 } })
} }
})
}
})
.finally(() => {
// this.loaded = true
})
}, },
open() { open(item) {
const h = this.$createElement
this.$msgbox({ this.$msgbox({
title: '消息', title: '提示',
message: h('p', null, [h('span', null, '您上次未做完试题 ')]), message: '您上次未做完试题',
showCancelButton: true, showCancelButton: true,
confirmButtonText: '继续答题', confirmButtonText: '继续答题',
cancelButtonText: '重新答题', cancelButtonText: '重新答题'
beforeClose: (action, instance, done) => {
done()
if (action === 'confirm') {
this.$router.push({
path: '/testExam/exam',
query: {
is_create: 0
}
})
} else {
this.$router.push({
path: '/testExam/exam',
query: {
is_create: 1
}
})
}
}
}).then(action => {
// this.$message({
// type: 'info',
// message: 'action: ' + action
// })
}) })
.then(() => {
this.$router.push({ path: '/testExam/exam', query: { exam_id: item.id, is_create: 0 } })
})
.catch(() => {
this.$router.push({ path: '/testExam/exam', query: { exam_id: item.id, is_create: 1 } })
})
} }
} }
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.desc-exam { .exam-list {
}
.exam-item {
display: inline-block;
width: 300px;
margin: 0 20px 20px 0;
text-align: center;
cursor: pointer;
h3 {
line-height: 30px;
}
p { p {
margin-bottom: 20px; height: 24px;
line-height: 20px; line-height: 24px;
color: #333;
} }
} }
</style> </style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论