|
@@ -11,28 +11,29 @@
|
|
|
<a class="goback" @click="$router.go(-1)"><i class="el-icon-arrow-left">{{title}}</i></a>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="content">
|
|
|
+ <div class="content" v-if="question_list">
|
|
|
<template v-if="progress==='answer'">
|
|
|
<div class="content-top">
|
|
|
- <span class="chapter"> {{activeIndex+1}} / {{evaluData.length}} </span>
|
|
|
+ <span class="chapter"> {{activeIndex+1}} / {{question_list.length}} </span>
|
|
|
<span class="countdown">-{{realFormatSecond(time)}}</span>
|
|
|
</div>
|
|
|
- <template v-for="(item,index) in evaluData">
|
|
|
- <div class="content-center" :key="index" v-if="activeIndex===index">
|
|
|
- <template v-if="item.type==='single'">
|
|
|
+ <!-- <template v-for="(item,index) in evaluData"> -->
|
|
|
+ <!-- <div class="content-center" :key="index" v-if="activeIndex===index"> -->
|
|
|
+ <div class="content-center" v-if="questionDetailList[activeIndex]">
|
|
|
+ <!-- <template v-if="item.type==='single'"> -->
|
|
|
<div class="title-box">
|
|
|
- <b v-if="item.number">{{item.number}}.</b>
|
|
|
- <h5>{{item.title}}</h5>
|
|
|
+ <b>{{activeIndex+1}}.</b>
|
|
|
+ <h5>{{questionDetailList[activeIndex].content.content}}</h5>
|
|
|
</div>
|
|
|
- <el-radio-group v-model="userSelect[index]">
|
|
|
- <el-radio :label="indexs" v-for="(items,indexs) in item.option" :key="indexs">
|
|
|
- <b v-if="items.number">{{items.number}}.</b>
|
|
|
- <span>{{items.title}}</span>
|
|
|
+ <el-radio-group v-model="userSelect[activeIndex]">
|
|
|
+ <el-radio :label="items.num" v-for="(items,indexs) in questionDetailList[activeIndex].option_list" :key="indexs">
|
|
|
+ <b v-if="items.label">{{items.label}}.</b>
|
|
|
+ <span>{{items.content}}</span>
|
|
|
</el-radio>
|
|
|
</el-radio-group>
|
|
|
- </template>
|
|
|
+ <!-- </template> -->
|
|
|
</div>
|
|
|
- </template>
|
|
|
+ <!-- </template> -->
|
|
|
<div class="btn-box">
|
|
|
<el-button size="small" @click="handlePrev">上一题</el-button>
|
|
|
<el-button type="primary" size="small" @click="handleNext">下一题</el-button>
|
|
@@ -67,7 +68,7 @@
|
|
|
//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
|
|
|
//例如:import 《组件名称》from ‘《组件路径》';
|
|
|
import Header from "../../components/Header.vue";
|
|
|
-
|
|
|
+import { getLogin } from "@/api/ajax";
|
|
|
export default {
|
|
|
//import引入的组件需要注入到对象中才能使用
|
|
|
components: { Header },
|
|
@@ -166,6 +167,9 @@ export default {
|
|
|
rightRate: 0,
|
|
|
time: 1800,
|
|
|
timer: null,
|
|
|
+ question_list: null,
|
|
|
+ questionInfo: null,
|
|
|
+ questionDetailList:[]
|
|
|
}
|
|
|
},
|
|
|
//计算属性 类似于data概念
|
|
@@ -186,74 +190,113 @@ export default {
|
|
|
},
|
|
|
// 重新测试
|
|
|
retest(){
|
|
|
- this.progress = 'answer'
|
|
|
- this.activeIndex = 0
|
|
|
- this.handleUserSelect()
|
|
|
- this.handleTimer()
|
|
|
+ getLogin('/TestServer/Client/ExamManager/RetestTestOrder', {
|
|
|
+ test_order_id: this.$route.query.order
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ this.progress = 'answer'
|
|
|
+ this.activeIndex = 0
|
|
|
+ this.handleUserSelect()
|
|
|
+ this.handleTimer()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
},
|
|
|
// 上一题
|
|
|
- handlePrev(){
|
|
|
+ async handlePrev(){
|
|
|
if(this.activeIndex!==0){
|
|
|
+ await this.handleSubmit()
|
|
|
this.activeIndex--
|
|
|
+ this.handleGetQuestionDetail(this.activeIndex)
|
|
|
}else{
|
|
|
this.$message.warning('已经是第一题了')
|
|
|
}
|
|
|
},
|
|
|
// 下一题
|
|
|
- handleNext(){
|
|
|
- if(this.activeIndex!==this.evaluData.length-1){
|
|
|
+ async handleNext(){
|
|
|
+ if(this.activeIndex!==this.question_list.length-1){
|
|
|
+ await this.handleSubmit()
|
|
|
this.activeIndex++
|
|
|
+ this.handleGetQuestionDetail(this.activeIndex)
|
|
|
}else{
|
|
|
+ await this.handleSubmit()
|
|
|
this.progress = 'result'
|
|
|
this.handleCorrect()
|
|
|
clearInterval(this.timer);
|
|
|
this.time = 1800;
|
|
|
+ this.questionDetailList = []
|
|
|
+ this.handleGetQuestionDetail(0)
|
|
|
}
|
|
|
},
|
|
|
+ // 提交答案
|
|
|
+ handleSubmit(){
|
|
|
+ getLogin('/TestServer/Client/ExamManager/SubmitTestOrderQuestionAnswer', {
|
|
|
+ test_order_id: this.$route.query.order,
|
|
|
+ question_id: this.question_list[this.activeIndex].question_id,
|
|
|
+ answer_num: this.userSelect[this.activeIndex]
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
// 给用户选项数组赋初始值
|
|
|
handleUserSelect(){
|
|
|
this.userSelect = []
|
|
|
- this.evaluData.forEach(item => {
|
|
|
- if(item.type==='single'){
|
|
|
- this.userSelect.push(null)
|
|
|
- }else{
|
|
|
- let itemsOption = []
|
|
|
- item.option.forEach(items=>{
|
|
|
- itemsOption.push(null)
|
|
|
- })
|
|
|
- this.userSelect.push(itemsOption)
|
|
|
- }
|
|
|
- });
|
|
|
+ this.questionDetailList = []
|
|
|
+ this.handleGetQuestionDetail(0)
|
|
|
+ // this.evaluData.forEach(item => {
|
|
|
+ // if(item.type==='single'){
|
|
|
+ // this.userSelect.push(null)
|
|
|
+ // }else{
|
|
|
+ // let itemsOption = []
|
|
|
+ // item.option.forEach(items=>{
|
|
|
+ // itemsOption.push(null)
|
|
|
+ // })
|
|
|
+ // this.userSelect.push(itemsOption)
|
|
|
+ // }
|
|
|
+ // });
|
|
|
},
|
|
|
// 计算对错
|
|
|
handleCorrect(){
|
|
|
- let total = 0
|
|
|
- this.rightNumber=0
|
|
|
- this.errorNumber=0
|
|
|
- this.evaluData.forEach((item,index)=>{
|
|
|
- if(item.type==='single'){
|
|
|
- if(item.correct!==null){
|
|
|
- if(item.correct===this.userSelect[index]){
|
|
|
- this.rightNumber++
|
|
|
- }else{
|
|
|
- this.errorNumber++
|
|
|
- }
|
|
|
- total++
|
|
|
- }
|
|
|
- }else{
|
|
|
- item.option.forEach((items,indexs)=>{
|
|
|
- if(items.correct!==null){
|
|
|
- if(items.correct===this.userSelect[index][indexs]){
|
|
|
- this.rightNumber++
|
|
|
- }else{
|
|
|
- this.errorNumber++
|
|
|
- }
|
|
|
- total++
|
|
|
- }
|
|
|
- })
|
|
|
+ // let total = 0
|
|
|
+ // this.rightNumber=0
|
|
|
+ // this.errorNumber=0
|
|
|
+ // this.evaluData.forEach((item,index)=>{
|
|
|
+ // if(item.type==='single'){
|
|
|
+ // if(item.correct!==null){
|
|
|
+ // if(item.correct===this.userSelect[index]){
|
|
|
+ // this.rightNumber++
|
|
|
+ // }else{
|
|
|
+ // this.errorNumber++
|
|
|
+ // }
|
|
|
+ // total++
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // item.option.forEach((items,indexs)=>{
|
|
|
+ // if(items.correct!==null){
|
|
|
+ // if(items.correct===this.userSelect[index][indexs]){
|
|
|
+ // this.rightNumber++
|
|
|
+ // }else{
|
|
|
+ // this.errorNumber++
|
|
|
+ // }
|
|
|
+ // total++
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // this.rightRate = Math.round(this.rightNumber/total *100 )
|
|
|
+ getLogin('/TestServer/Client/ExamManager/GetTestOrderExamResult', {
|
|
|
+ test_order_id: this.$route.query.order
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ this.rightNumber = res.count_right
|
|
|
+ this.errorNumber = res.count_wrong
|
|
|
+ this.rightRate = res.percent_right
|
|
|
}
|
|
|
})
|
|
|
- this.rightRate = Math.round(this.rightNumber/total *100 )
|
|
|
},
|
|
|
// 计时器
|
|
|
handleTimer(){
|
|
@@ -305,10 +348,41 @@ export default {
|
|
|
}
|
|
|
return result;
|
|
|
},
|
|
|
+ // 获取试题列表
|
|
|
+ handleGetList(){
|
|
|
+ getLogin('/TestServer/Client/ExamManager/GetTestOrderQuestionList', {
|
|
|
+ test_order_id: this.$route.query.order
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ this.handleTimer()
|
|
|
+ this.question_list = res.question_list
|
|
|
+ if(this.question_list.length>0){
|
|
|
+ this.handleGetQuestionDetail(0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取试题信息
|
|
|
+ handleGetQuestionDetail(index){
|
|
|
+ if(this.questionDetailList[index]){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.questionInfo = null
|
|
|
+ getLogin('/TestServer/Client/QuestionManager/GetQuestionInfo', {
|
|
|
+ id: this.question_list[index].question_id
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if(res.status===1){
|
|
|
+ this.questionDetailList[index] = res
|
|
|
+ this.questionInfo = res
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
created() {
|
|
|
- this.handleTimer()
|
|
|
+ this.handleGetList()
|
|
|
},
|
|
|
//生命周期 - 挂载完成(可以访问DOM元素)
|
|
|
mounted() {
|