提交 971227a6 authored 作者: lihuihui's avatar lihuihui

考前摸底,真题实战

上级 b1a87ba8
......@@ -9,8 +9,8 @@ export function getExamQuestion(params) {
/**
* 缓存考前摸底试题
*/
export function setCache(data) {
return httpRequest.post('/api/zy/v2/examination/examination-papers', data)
export function setCache(params) {
return httpRequest.post('/api/zy/v2/examination/examination-papers', params)
}
/**
......@@ -20,6 +20,13 @@ export function getExamStatus(params) {
return httpRequest.get('/api/zy/v2/examination/examination-papers-status', { params })
}
/**
* 模拟考试设置角色
*/
export function setRoles(params) {
return httpRequest.post('/api/zy/v2/examination/role', params)
}
/**
* 获取课程列表
*/
......
......@@ -5,8 +5,7 @@
<circle cx="74" cy="74" r="70" stroke-width="7" stroke="#4cce8c" fill="none" :stroke-dasharray="data" stroke-linecap="round"></circle>
</svg>
<div class="chart-txt">
<div class="num">{{ accuracy }}%</div>
<div class="t">正确率</div>
<slot name="tips"></slot>
</div>
</div>
</template>
......
......@@ -88,12 +88,13 @@ export default {
})
},
goQuestion(id) {
this.$router.push({
path: '/testExam/exam',
query: {
id: id
}
})
this.$emit('goQuestion', id)
// this.$router.push({
// path: '/testExam/exam',
// query: {
// id: id
// }
// })
}
}
}
......
......@@ -28,7 +28,7 @@ export default {
return {
defaultMenus: [
{ title: '考前摸底', icon: '', path: '/testExam' },
{ title: '真题实战', icon: '', path: '/mockExam' },
{ title: '真题实战', icon: '', path: '/mock' },
{ title: '错题集合', icon: '', path: '/my/questions/wrong' },
{ title: '收藏试题', icon: '', path: '/my/questions/collection' },
{ title: '必考考点', icon: '', path: '/course/test' },
......
<template>
<div>
<div class="answer-box">
<div class="head" id="head-h">
<div class="title">全国统一高考试卷A</div>
<div class="right">
<div class="count">{{ time.examTimeText }}</div>
</div>
</div>
<div class="exam-main" :style="{height: this.contentHeight + 'px'}">
<div class="left">
<question
v-if="Object.keys(questionParams.question).length"
:contentHeight="contentHeight"
:questionParams="questionParams"
ref="signHandle"
@isSign="isSign"
></question>
</div>
<div class="right">
<answer-card
:questionParams="questionParams"
ref="signHandle"
@isSign="isSign"
></answer-card>
</div>
</div>
<div class="foot" id="foot-h">
<div class="exam-btn">
<div
@click="changeIndex('prev')"
:class="this.questionParams.questionIndex !== 0 ? 'active' : ''"
>上一题</div>
<div
:class="questionParams.questionIndex + 1 !== questionParams.question.total_question_count ? 'active' : ''"
@click="changeIndex('next')"
>下一题</div>
</div>
<div class="rigth-btn" @click="signHandle" v-if="!$route.query.id">
<!-- <div class="sign">
<div class="icon"></div>
<div class="txt">{{ itemSign ? '取消标记' : '标记' }}</div>
</div> -->
<div class="end-exam-btn">
<div class="btn" @click="endExam">交卷</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import * as api from '@/api/exam.js'
import answerCard from '@/components/exam/answerCard.vue'
import question from '@/components/exam/question.vue'
export default {
components: {
question,
answerCard
},
data() {
return {
time: {
// 考试持续时间
duration: 0,
examTimeText: '00:00:00',
clearTime: null
},
// isExamTimeDate: true,
// 标记
itemSign: false,
// 设置页面高
contentHeight: 0,
// 原数据
beforeChangeData: {},
// 过滤后的数据
afterChangeData: {},
// 题的数据所需的参数
changeTime: 0,
questionParams: {
// 用户选择的选项 --- 提交后台的数据
answerRecord: {},
// 当前题的下标
questionIndex: 0,
// 所有题 和题的信息
question: {},
card: {},
beforeData: {}
}
}
},
mounted() {
// 赋值页面高度
this.contentHeight = parseInt(document.documentElement.clientHeight - (this.getDom('head-h').offsetHeight + this.getDom('foot-h').offsetHeight))
this.getTopic()
},
methods: {
// 标记
signHandle() {
this.$refs.signHandle.onSignHandle()
},
isSign(value) {
this.itemSign = value
},
// 提交考试
endExam() {
this.handlePapers(1)
},
setClock(time) {
let sec = parseInt(time)
clearInterval(this.time.clearTime)
this.time.clearTime = setInterval(() => {
// if (this.requestParam.course_id) {
// this.time.examTimeText = this.secondToDate(sec)
// sec++
// } else {
// }
if (this.$route.query.id) {
this.time.examTimeText = '00:00:00'
return false
}
sec--
if (sec === 0) {
clearInterval(this.time.clearTime)
this.$alert('考试时间结束,自动提交试卷', '', {
confirmButtonText: '确定',
callback: action => {
this.endExam()
}
})
return false
}
this.time.examTimeText = this.secondToDate(sec)
this.time.duration++
}, 1000)
},
secondToDate(result) {
const h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600)
const m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60))
const s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60))
if (h === 0) {
result = m + ':' + s
} else {
result = h + ':' + m + ':' + s
}
return result
},
addZero(i) {
return i < 10 ? '0' + i : i + ''
},
getDom(id) {
return document.getElementById(id)
},
// 改变题序
changeIndex(type) {
if (type === 'prev') {
this.questionParams.questionIndex > 0 && (this.questionParams.questionIndex--)
} else {
this.questionParams.questionIndex + 1 !== this.questionParams.question.total_question_count && (this.questionParams.questionIndex++)
}
this.changeData()
this.handlePapers()
},
// 获取考卷
getTopic() {
const param = {
type: 1,
is_create: this.$route.query.id || this.$route.query.is_create === undefined ? 0 : this.$route.query.is_create
}
api
.getExamQuestion(param)
.then(response => {
const data = JSON.parse(response.data)
this.beforeChangeData = data.sheet
this.questionParams.beforeData = data.sheet
this.afterChangeData = this.setData(data.sheet.questions.question_items)
this.questionParams.card = this.setData(data.sheet.questions.question_items)
data.sheet.answers !== null && (this.questionParams.answerRecord = data.sheet.answers)
this.$route.query.id && this.$route.query.id.length > 5
? this.analysisInit()
: this.changeData()
this.setClock(data.sheet.remaining_times)
this.time.duration = data.sheet.duration
})
.finally(() => {
})
},
// 重组数据
setData(data) {
let countNum = 0
const type = {
1: '单选题',
2: '多选题',
5: '案例题',
6: '判断题'
}
return data.map(item => {
return item.question_list.map(cItem => {
countNum++
const data = {
q_order: countNum,
question_item_id: item.question_item_id,
question_item_type: item.question_type,
content: cItem.question_content,
id: cItem.id,
options: cItem.question_options,
question_item_title: type[item.question_type],
total_question_count: this.beforeChangeData.questions.total_question_count
}
if (this.$route.query.id) {
if (this.$route.query.id.length > 5 || this.$route.query.id === 'all' || this.$route.query.id === 'err') {
const qAnswer = Array.isArray(cItem.question_answer) ? cItem.question_answer : cItem.question_answer = [cItem.question_answer]
let optGroup = ''
const findAB = qAnswer.map(qOpt => {
const findIndex = cItem.question_options.findIndex(i => { return i.id === qOpt })
return this.A_Z()[findIndex]
})
data.question_analysis = cItem.question_analysis
optGroup = (findAB.sort().toString().replace(new RegExp(',', 'g'), ''))
data.question_answer = optGroup
}
}
if (parseInt(item.question_type) === 5) {
data.common_content = cItem.common_content
data.group_id = cItem.group_id
data.list = this.mergeData(item.question_list, 'group_id')
data.answer_count = cItem.answer_count
}
return data
})
})
},
// ABC
A_Z() {
const result = []
for (let i = 0; i < 26; i++) {
result.push(String.fromCharCode(65 + i))
}
return result
},
// 合并案例题
mergeData(arr, str) {
const _arr = []
let _t = []
let _tmp = null
arr.length && (_tmp = arr[0][str])
for (const i in arr) {
arr[i][str] === _tmp
? _t.push(arr[i])
: (() => {
_tmp = arr[i][str]
_arr.push(_t)
_t = [arr[i]]
})()
}
_arr.push(_t)
return _arr
},
// 点击上一题下一题 答题卡序号
changeData() {
this.afterChangeData.map(item => {
item.map(cItem => {
cItem.q_order === this.questionParams.questionIndex + 1 && (this.questionParams.question = cItem)
})
})
},
// 结果页进入设置默认点击的题
analysisInit() {
this.afterChangeData.map(item => {
const findData = item.find(datas => { return datas.id === this.$route.query.id })
if (findData) {
this.questionParams.questionIndex = findData.q_order - 1
this.questionParams.questions = findData
findData.q_order === 1 && (this.changeData())
}
})
},
// 缓存 提交
handlePapers(n) {
if (!this.$route.query.id) {
const param = {
sheet_id: this.beforeChangeData.id,
status: n || 0,
answers: JSON.stringify(this.questionParams.answerRecord),
duration: this.time.duration
}
api
.setCache(param)
.then(response => {
if (n) {
this.$router.replace({
path: '/mock/result'
})
}
})
.finally(() => {
})
}
}
},
computed: {
changeQuestionIndex() {
return this.questionParams.questionIndex
}
},
watch: {
// 监听题的变化
changeQuestionIndex(newV, oldV) {
this.changeData()
}
}
}
</script>
<style lang="scss" scoped>
.answer-box{
width: 100%;
height: 100%;
// background: #f9f9f9;
.head{
width: 100%;
height: 80px;
background: #FFFFFF;
display: flex;
.title{
padding-left: 30px;
font-size: 24px;
font-weight: bold;
color: #222222;
line-height: 80px;
}
.right{
width: 260px;
margin-left: auto;
display: flex;
justify-content: space-around;
align-items: center;
.count{
font-size: 18px;
font-weight: bold;
color: #222222;
}
.time{
display: flex;
.icon{
width: 23px;
height: 23px;
// background: url(../../assets/images/tick.png);
background-size:100% 100%;
}
.mun{
font-size: 18px;
font-weight: bold;
color: #222222;
line-height: 25px;
margin-left: 10px;
}
}
}
}
.exam-main{
display: flex;
.left{
flex: 1;
padding: 10px 20px 0 53px;
overflow-y: scroll;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
.right{
position: relative;
width: 220px;
background: #fff;
padding: 0 20px;
overflow-y: scroll;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
}
.foot{
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 60px;
background: #FFFFFF;
display: flex;
align-items: center;
.exam-btn{
display: flex;
padding-left: 40px;
cursor: pointer;
div{
width: 100px;
height: 40px;
border-radius: 4px;
border: 1px solid #CCCCCC;
font-size: 14px;
font-weight: bold;
color: #999999;
line-height: 40px;
text-align: center;
margin-right: 20px;
&.active{
background: #C01540;
border-radius: 4px;
color: #fff;
}
}
}
.rigth-btn{
display: flex;
margin-left: auto;
.end-exam-btn{
width: 260px;
display: flex;
justify-content: center;
align-items: center;
.btn{
cursor: pointer;
width: 200px;
height: 40px;
background: #EEEEEE;
border-radius: 4px;
font-size: 14px;
font-weight: bold;
color: #CCCCCC;
line-height: 40px;
text-align: center;
}
}
.sign{
margin-right: 20px;
.icon{
margin: 0 auto;
width: 24px;
height: 24px;
background: url(@/assets/images/sign.png);
background-size:100% 100%;
}
.txt{
font-size: 14px;
color: #CCCCCC;
line-height: 20px;
margin-top: 2px;
}
}
}
}
}
</style>
<template>
<div class="result-box">
<div class="card-left">
<div class="title">成绩报告</div>
<div class="chart-box">
<chart :accuracy="accuracy">
<template v-slot:tips>
<div class="num">{{ accuracy }}</div>
<div class="t"></div>
</template>
</chart>
</div>
<!-- <div class="assess">测试评估</div>
<div class="assess-box">
<div class="prog">
<div class="line-box">
<div class="line" :style="setStyle"></div>
</div>
<div class="icon"></div>
</div>
<div class="text">{{ accuracy !== 100 ? '您离成功还有一段距离,继续努力!' : '成功近在眼前,再接再厉!' }}</div>
<div class="btn">全部考试服务</div>
</div> -->
</div>
<div class="card-right">
<card v-if="data.sheet" :data="data.sheet" @goQuestion="goPage">
<template v-slot:btnBox>
<div class="btn-box">
<div class="btn" @click="goPage('all')">全部解析</div>
<div class="btn" @click="goPage('err')">错误解析</div>
</div>
</template>
</card>
</div>
</div>
</template>
<script>
import chart from '@/components/exam/pieChart.vue'
import card from '@/components/exam/resultCard.vue'
import * as api from '@/api/exam.js'
export default {
components: {
chart,
card
},
data() {
return {
data: {},
accuracy: 0
}
},
created() {
this.getExamPapers()
},
computed: {
},
mounted() {
},
methods: {
goPage(param) {
this.$router.push({
path: '/mock/exam',
query: {
id: param
}
})
},
getExamPapers() {
const param = {
type: 1,
is_create: 0
}
api
.getExamQuestion(param)
.then(response => {
const data = JSON.parse(response.data)
this.data = data
this.accuracy = parseInt(data.sheet.score)
// console.log(this.accuracy)
})
.finally(() => {
// this.loaded = true
})
}
}
}
</script>
<style lang="scss" scoped>
.result-box{
width: 100%;
display: flex;
.card-left{
position: relative;
box-sizing: border-box;
padding: 10px 30px 20px;
flex: 1;
background: #fff;
margin-right: 10px;
height: 560px;
border-radius: 8px;
.title{
font-size: 18px;
color: #222222;
line-height: 45px;
border-bottom: 1px solid #ccc;
}
.chart-box{
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
width: 148px;
// margin: 26px auto 0;
}
.assess{
font-size: 18px;
color: #222222;
line-height: 45px;
border-bottom: 1px solid #ccc;
}
.assess-box{
padding-top: 27px;
.prog{
width: 350px;
margin: 0 auto;
display: flex;
align-items: center;
justify-content: space-between;
.line-box{
width: 300px;
width: 300px;
height: 10px;
background: #F9F9F9;
border-radius: 5px;
.line{
width: 80%;
height: 10px;
background: linear-gradient(90deg, #F47C46 0%, #F22F48 100%);
border-radius: 5px;
}
}
.icon{
width: 41px;
height: 38px;
background: url(@/assets/images/res-icon.png);
background-size: 100% 100%;
}
}
.text{
font-size: 14px;
color: #222222;
line-height: 20px;
text-align: center;
margin: 50px 0 68px 0;
}
.btn{
cursor: pointer;
text-align: center;
line-height: 40px;
width: 144px;
height: 40px;
background: #C01540;
border-radius: 4px;
font-size: 14px;
font-weight: bold;
color: #FFFFFF;
margin: 0 auto;
}
}
}
.card-right{
box-sizing: border-box;
flex: 1;
background: #fff;
height: 560px;
border-radius: 8px;
margin-left: 10px;
padding: 10px 30px 0;
}
}
</style>
......@@ -20,8 +20,8 @@
<div class="item">
<p><b>选择角色</b></p>
<el-radio-group v-model="role">
<el-radio :label="0">管理人员</el-radio>
<el-radio :label="1">安全人员</el-radio>
<el-radio :label="1">管理人员</el-radio>
<el-radio :label="2">安全人员</el-radio>
</el-radio-group>
</div>
<div class="item">
......@@ -30,18 +30,71 @@
</div>
</div>
<template #footer>
<div class="app-container-ft"><el-button type="primary">开始考试</el-button></div>
<div class="app-container-ft"><el-button type="primary" @click="startExam">开始考试</el-button></div>
</template>
</app-container>
</template>
<script>
import AppContainer from '@/components/AppContainer'
import * as api from '@/api/exam.js'
export default {
components: { AppContainer },
data() {
return {
role: 0
role: window.localStorage.role ? parseInt(window.localStorage.role) : 1
}
},
mounted() {},
methods: {
startExam() {
api
.setRoles({ role: this.role })
.then(response => {
if (response.code === 0) {
window.localStorage.role = this.role
api
.getExamStatus({ type: 2 })
.then(response => {
if (parseInt(response.status) === 0 || parseInt(response.status) === 3) {
this.toolTipBox()
} else {
this.$router.push({
path: '/mock/exam',
query: {
is_create: true
}
})
}
})
.finally(() => {
})
}
})
.finally(() => {
})
},
toolTipBox() {
this.$confirm('您上次未做完试题', '', {
confirmButtonText: '重新答题',
cancelButtonText: '继续答题',
type: 'warning'
}).then(() => {
this.$router.push({
path: '/mock/exam',
query: {
is_create: 1
}
})
}).catch((e) => {
console.log(e)
this.$router.push({
path: '/mock/exam',
query: {
is_create: 0
}
})
})
}
}
}
......
......@@ -165,7 +165,7 @@ export default {
getTopic() {
const param = {
type: 1,
is_create: this.$route.query.id || !this.$route.query.is_create ? 0 : 1
is_create: this.$route.query.id || this.$route.query.is_create === undefined ? 0 : this.$route.query.is_create
}
api
.getExamQuestion(param)
......
......@@ -3,7 +3,12 @@
<div class="card-left">
<div class="title">成绩报告</div>
<div class="chart-box">
<chart :accuracy="accuracy"/>
<chart :accuracy="accuracy">
<template v-slot:tips>
<div class="num">{{ accuracy }}%</div>
<div class="t">正确率</div>
</template>
</chart>
</div>
<div class="assess">测试评估</div>
<div class="assess-box">
......@@ -18,7 +23,7 @@
</div>
</div>
<div class="card-right">
<card v-if="data.sheet" :data="data.sheet">
<card v-if="data.sheet" :data="data.sheet" @goQuestion="goPage">
<template v-slot:btnBox>
<div class="btn-box">
<div class="btn" @click="goPage('all')">全部解析</div>
......
......@@ -23,11 +23,8 @@ export default {
},
methods: {
getExamStatus() {
const param = {
type: 1
}
api
.getExamStatus(param)
.getExamStatus({ type: 1 })
.then(response => {
if (response.status === 0 || response.status === 3) {
this.open()
......@@ -35,7 +32,7 @@ export default {
this.$router.push({
path: '/testExam/exam',
query: {
is_create: true
is_create: 1
}
})
}
......@@ -60,14 +57,14 @@ export default {
this.$router.push({
path: '/testExam/exam',
query: {
is_create: false
is_create: 0
}
})
} else {
this.$router.push({
path: '/testExam/exam',
query: {
is_create: true
is_create: 1
}
})
}
......
......@@ -43,10 +43,15 @@ const examAnswer = [
path: '/testExam/result',
component: () => import(/* webpackChunkName: "exam" */ '@/pages/testExam/exam/result')
},
// 真题实战
/* 真题实战 */
{
path: '/mockExam',
path: '/mock',
component: () => import(/* webpackChunkName: "exam" */ '@/pages/mockExam')
},
/* 真题实战结果页 */
{
path: '/mock/result',
component: () => import(/* webpackChunkName: "exam" */ '@/pages/mockExam/exam/result')
}
]
......@@ -259,5 +264,10 @@ export default [
path: '/testExam/exam',
component: () => import(/* webpackChunkName: "course-learn" */ '@/pages/testExam/exam/index')
},
/* 模拟考试 */
{
path: '/mock/exam',
component: () => import(/* webpackChunkName: "course-learn" */ '@/pages/mockExam/exam/index')
},
...viewerRoutes
]
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论