提交 dda86f81 authored 作者: zhengyadong's avatar zhengyadong

【fix】优化试卷答题流程

上级 a0bb19b8
......@@ -212,13 +212,13 @@ export default {
}
.default-e{
.option-num{
// background: url('~@/assets/img/practice/p-E.png');
background: url('~@/assets/img/practice/p-E.png');
background-size:cover;
}
}
.default-f{
.option-num{
// background: url('~@/assets/img/practice/p-F.png');
background: url('~@/assets/img/practice/p-F.png');
background-size:cover;
}
}
......
......@@ -73,8 +73,6 @@ export default {
methods: {
getList(){
getMoonListAPI(this.listQuery).then(res=>{
console.log(res.data.data,22);
if(res.data.code == 0){
this.list = res.data.data.list
}
......
......@@ -239,12 +239,10 @@ export default {
this.createRecord.coverId = this.id
try{
let result = await this.getPaperStatus()
console.log(result,'result');
this.createPaperId = result.testPaperId
this.getDetail(result.status,result.endTime)
}catch(error) {
console.log(error,'error');
}
}
},
......@@ -267,8 +265,6 @@ export default {
return status
},
leftTimer(time){
console.log(time,'time');
let year = time.slice(0,4)
let month = time.slice(5,7)
let day = time.slice(8,10)
......@@ -286,11 +282,11 @@ export default {
this.isShow = false
this.$router.push({name:'moonMatch'})
},
// 试卷答题状态
getPaperStatus(){
return new Promise((resolve,reject)=>{
getPaperStatusAPI(this.conQuery).then(res=>{
if(res.data.code == 0){
console.log(res.data.data);
resolve(res.data.data)
}else{
reject(res.data.msg)
......@@ -317,7 +313,7 @@ export default {
this.setInter = setInterval(()=> {
this.lastTime = this.leftTimer(time)
if(this.lastTime == '00:00'){
console.log('交卷');
this.hasDown()
}
}, 1000)
}else{
......@@ -349,7 +345,6 @@ export default {
}
})
return startIndex
console.log(this.answerRecordList,'this.answerRecordList');
},
_filterNum(list){
......@@ -368,8 +363,6 @@ export default {
// 根据题目类型来确定渲染内容
_showDetail(startIndex){ // startIndex 0 代表大题,1代表小题
let currentObj = this.currentObj
console.log(this,'thisthisthis');
if(currentObj.questionType === 5||currentObj.questionType === 6){
let list = this.childrenList = this.currentObj.children
let index = startIndex === 0 ? 0 : list.length - 1
......@@ -445,7 +438,6 @@ export default {
}
return new Promise((resolve,reject)=>{
createPaperAPI(this.createPaper).then(res=>{
console.log(res.data,'创建试卷');
let data = res.data.data
if(res.data.code == 0){
this.paperObj = data
......@@ -454,11 +446,12 @@ export default {
// this.$router.push({name:'viewMatchReport',query:{id:this.id,paperId:this.createPaperId}})
} else{
this.createPaperId = data.id
this.createPaper.id = this.createPaperId
let time = data.endtime
this.setInter = setInterval(()=> {
this.lastTime = this.leftTimer(time)
if(this.lastTime == '00:00'){
console.log('交卷');
this.hasDown()
}
}, 1000)
}
......@@ -474,7 +467,6 @@ export default {
async _createRecord(){
return new Promise((resolve,reject)=>{
createRecordAPI(this.createRecord).then(res=>{
console.log(res.data,'创建答题记录');
if(res.data.code == 0){
resolve(res.data.data)
}else{
......@@ -485,8 +477,6 @@ export default {
},
// 保存答题记录
async _saveRecord(obj,parentObj){
// return new Promise((resolve,reject)=>{
this.createPaper.id = this.createPaperId
this.createRecord.parentQuestionsId = parentObj?parentObj.questionid:''
this.createRecord.testPaperId = this.createPaperId // 试卷id
this.createRecord.questionType = obj.questionType // 试题类型
......@@ -494,12 +484,9 @@ export default {
this.createRecord.stuanswer = this.userAns // 考生答案
try{
let res = await this._createRecord()
// resolve(res)
}catch(error){
console.log('保存答题记录接口错误',error);
// reject(error)
}
// })
},
// 添加下一题信息
nextQues(){
......@@ -510,13 +497,14 @@ export default {
// 下一题
async nextQuestion(){
try{
await this._saveRecord(this.currentObj)
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList) // 本地保存记录
if(this.userAns){
await this._saveRecord(this.currentObj)
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList) // 本地保存记录
}
}catch(error){
console.log(error,'错误');
}
this.nextQues()
console.log(this.answerRecordList,'保存所有得答案');
},
childrenPrevQuestion(){
......@@ -535,29 +523,32 @@ export default {
async childrenNextQuestion(){
let key
try{
await this._saveRecord(this.currentChildrenObj,this.currentObj) // 调用保存接口
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList,this.currentChildrenIndex) // 本地保存记录
if(this.currentChildrenIndex + 1 < this.childrenList.length){
this.currentChildrenIndex += 1
this.currentChildrenObj = this.childrenList[this.currentChildrenIndex] // 当前题目
this._showCom(this.currentChildrenObj)
this.changeAns('refChildrenObj',this.currentChildrenObj,'_getUserChildAnswer')
console.log(this.answerRecordList,'保存所有得答案');
}else{
this.nextQues()
if(this.userAns){
await this._saveRecord(this.currentChildrenObj,this.currentObj) // 调用保存接口
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList,this.currentChildrenIndex) // 本地保存记录
}
}catch(error){console.log(error,'错误');}
if(this.currentChildrenIndex + 1 < this.childrenList.length){
this.currentChildrenIndex += 1
this.currentChildrenObj = this.childrenList[this.currentChildrenIndex] // 当前题目
this._showCom(this.currentChildrenObj)
this.changeAns('refChildrenObj',this.currentChildrenObj,'_getUserChildAnswer')
}else{
this.nextQues()
}
},
// 打开交卷
async openPost(){
try{
if(this.currentObj.questionType === 5||this.currentObj.questionType === 6){
await this._saveRecord(this.currentChildrenObj,this.currentObj) // 调用保存接口
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList,this.currentChildrenIndex) // 本地保存记录
}else{
await this._saveRecord(this.currentObj)
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList) // 本地保存记录
if(this.userAns){
if(this.currentObj.questionType === 5||this.currentObj.questionType === 6){
await this._saveRecord(this.currentChildrenObj,this.currentObj) // 调用保存接口
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList,this.currentChildrenIndex) // 本地保存记录
}else{
await this._saveRecord(this.currentObj)
this._saveAnswer('answer',this.userAns,this.currentIndex,this.answerRecordList) // 本地保存记录
}
}
this.backStatus = true
}catch(error){
......@@ -583,7 +574,7 @@ export default {
// 完成
async hasDown(){
let result = await this._createPaper('1')
this.createPaper.updateTime = getTimer()
// this.createPaper.updateTime = getTimer()
this.$router.push({name:'viewMatchReport',query:{id:this.id,paperId:this.createPaperId}})
}
}
......
......@@ -175,8 +175,6 @@ export default {
};
},
created() {
console.log(111111);
let query = this.$route.query
if(query&&query.id){
this.id = query.id
......@@ -191,8 +189,6 @@ export default {
watch: {},
methods: {
backTo(){
console.log(111);
this.$router.go(-1)
// this.$router.push({name:this.viewType[this.type].routerName})
},
......@@ -284,7 +280,6 @@ export default {
this.rightAns.indexOf(type) != -1 && (num += 1)
this.userAns.indexOf(type) != -1 && (num += 2)
this.currentStatus[answer] = num
console.log(this.userAns,this.rightAns,'this.userAns == this.rightAns')
},
_filterAnswer(userAns,rightAns){
......
......@@ -8,24 +8,24 @@
</div>
<div class="report-bg">
<div class="report-detail">
<div class="detail-num">{{detail.rightCount}}</div>
<div class="detail-num">{{detail.rightCount | defaultCount}}</div>
<div class="detail-tip">本次答对题目数</div>
</div>
</div>
<div class="report-statistics">
<div class="statistics-detail">
<div class="time-wrap-top">
<span class="item-top">{{detail.begintime&&detail.begintime.substring(2,10).replace(/-/g,'.')}}</span>
<span class="item-top">{{detail.updateTime&&detail.updateTime.substring(2,10).replace(/-/g,'.')}}</span>
<span class="item-top">{{detail.begintime | filterYear}}</span>
<span class="item-top">{{detail.updateTime | filterYear}}</span>
<span class="item-top"></span>
</div>
<div class="time-wrap">
<div class="time-item">
<span class="item-cnt">{{detail.begintime&&detail.begintime.substring(10)}}</span>
<span class="item-cnt">{{detail.begintime | filterTime}}</span>
<span class="item-bot">开始时间</span>
</div>
<div class="time-item">
<span class="item-cnt">{{detail.updateTime&&detail.updateTime.substring(10)}}</span>
<span class="item-cnt">{{detail.updateTime | filterTime}}</span>
<span class="item-bot">结束时间</span>
</div>
<div class="time-item">
......@@ -36,12 +36,12 @@
<div class="info-item">
<img src="@/assets/img/practice/info-tip.png" alt="">
<span class="item-right">正确率:<span class="item-per">{{detail.correct}}</span></span>
<span class="item-false item-point">答对:<span class="item-num">{{detail.rightCount}}</span><span class="item-false"></span></span>
<span class="item-false item-point">答对:<span class="item-num">{{detail.rightCount | defaultCount}}</span><span class="item-false"></span></span>
</div>
<div class="info-item info-long">
<img src="" alt="">
<span class="item-right">答错:<span class="item-per item-per-color">{{detail.errorCount}}</span></span>
<span class="item-false item-point">未答:<span class="item-num item-num-color">{{detail.unFinishCount}}</span><span class="item-false"></span></span>
<span class="item-right">答错:<span class="item-per item-per-color">{{detail.errorCount | defaultCount}}</span><span class="item-false"></span></span>
<span class="item-false item-point">未答:<span class="item-num item-num-color">{{detail.unFinishCount | defaultCount}}</span><span class="item-false"></span></span>
</div>
</div>
</div>
......@@ -70,8 +70,18 @@ export default {
}
};
},
filters:{
defaultCount:function(value){
return value||0
},
filterYear:function(value){
return value&&value.substring(2,10).replace(/-/g,'.')
},
filterTime:function(value){
return value&&value.substring(10)
}
},
created() {
console.log(this.$route.query);
let query = this.$route.query
this.paperId = query.paperId
......@@ -86,7 +96,6 @@ export default {
paperId:id
}
getDetailPaperAPI(data).then(res=>{
console.log(res.data.data);
if(res.data.code == 0){
this.detail = res.data.data
}else{
......@@ -250,7 +259,7 @@ export default {
color: #999999;
}
.item-per {
margin-left: .07rem;
margin: 0 .07rem;
color: #04afaf;
font-weight: Bold;
}
......
......@@ -106,8 +106,6 @@ import { Toast } from 'vant';
import { getWeekDetailAPI, saveWeekAPI,getColStatusAPI,addCollectionAPI,delCollectionAPI } from '@/api/week'
export default {
beforeRouteLeave (to, from, next) {
// const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
console.log(this.backStatus,22222);
if (this.backStatus) {
next()
} else {
......@@ -255,13 +253,11 @@ export default {
this.colQuery.goodsId = this.currentObj.questionid
this.getColStatus()
if(this.currentObj.questionType === 5||this.currentObj.questionType === 6){
console.log(this.currentObj,111);
this.childrenList = this.currentObj.children
if(this.childrenList.length === 0) return
this.currentChildrenIndex = 1
this.currentChildrenObj = this.childrenList[0]
this.rightAns = this.currentChildrenObj.rightanswer
console.log(this.currentChildrenObj,2222);
}
}
......@@ -280,15 +276,12 @@ export default {
this.scoreObj.forEach(item=>{
obj[item.name]&&this._changeScore(item.name,item.value)
})
console.log(this.userAns,'用户答案');
console.log(this.rightAns,'正确1答案');
},
_changeScore(answer,type){
let num = 0
this.rightAns.indexOf(type) != -1 && (num += 1)
this.userAns.indexOf(type) != -1 && (num += 2)
this.currentStatus[answer] = num
console.log(this.userAns,this.rightAns,'this.userAns == this.rightAns')
},
// 单选选中 多选 填空
......@@ -381,8 +374,6 @@ export default {
this.changeScore(obj)
this.showButton = 'next'
this.showAnswer = true
console.log(this.currentStatus,2222);
this.$refs[this.refChildrenObj[obj.questionType]].currentStatus = this.currentStatus
}else if(type == '4'){ // 填空
let curentRef = this.$refs[this.refChildrenObj[obj.questionType]]
......@@ -443,7 +434,6 @@ export default {
// 完成
hasDown(){
this.backStatus = true
console.log(this.saveFrom,1);
saveWeekAPI(this.saveFrom).then(res=>{
if(res.data.code == 0){
this.$router.push({name:'viewPracticeReport',query:{id:this.id,title:this.topTitle,paperId:res.data.data.id}})
......@@ -454,7 +444,6 @@ export default {
// 获取收藏状态
getColStatus(){
getColStatusAPI(this.colQuery).then(res=>{
console.log(res.data,222);
if(res.data.code == 0){
this.collectionStatus = res.data.data
}
......@@ -471,7 +460,6 @@ export default {
}
let API = status ? addCollectionAPI(addData) : delCollectionAPI(delData)
API.then(res=>{
console.log(res.data,222);
if(res.data.code == 0){
Toast.success(`${!status?'取消收藏':'收藏成功'}`);
this.getColStatus()
......@@ -480,15 +468,11 @@ export default {
},
getColStatus(){
getColStatusAPI(this.colQuery).then(res=>{
console.log(res.data,222);
if(res.data.code == 0){
this.collectionStatus = res.data.data
}
})
},
// getColStatusAPI,addCollectionAPI,delCollectionAPI
}
}
</script>
......
......@@ -8,24 +8,24 @@
</div>
<div class="report-bg">
<div class="report-detail">
<div class="detail-num">{{detail.rightCount}}</div>
<div class="detail-num">{{detail.rightCount | defaultCount}}</div>
<div class="detail-tip">本次答对题目数</div>
</div>
</div>
<div class="report-statistics">
<div class="statistics-detail">
<div class="time-wrap-top">
<span class="item-top">{{detail.begintime.substring(2,10).replace(/-/g,'.')}}</span>
<span class="item-top">{{detail.updateTime.substring(2,10).replace(/-/g,'.')}}</span>
<span class="item-top">{{detail.begintime | filterYear}}</span>
<span class="item-top">{{detail.updateTime | filterYear}}</span>
<span class="item-top"></span>
</div>
<div class="time-wrap">
<div class="time-item">
<span class="item-cnt">{{detail.begintime.substring(10)}}</span>
<span class="item-cnt">{{detail.begintime | filterTime}}</span>
<span class="item-bot">开始时间</span>
</div>
<div class="time-item">
<span class="item-cnt">{{detail.updateTime.substring(10)}}</span>
<span class="item-cnt">{{detail.updateTime | filterTime}}</span>
<span class="item-bot">交卷时间</span>
</div>
<div class="time-item">
......@@ -38,7 +38,7 @@
<span class="item-right">正确率:</span>
<span class="item-per">{{detail.correct}}</span>
<span class="item-false item-point">答错</span>
<span class="item-num">{{detail.errorCount}}</span>
<span class="item-num">{{detail.errorCount | defaultCount}}</span>
<span class="item-false"></span>
</div>
</div>
......@@ -68,10 +68,19 @@ export default {
}
};
},
filters:{
defaultCount:function(value){
return value||0
},
filterYear:function(value){
return value&&value.substring(2,10).replace(/-/g,'.')
},
filterTime:function(value){
return value&&value.substring(10)
}
},
created() {
console.log(this.$route.query);
let query = this.$route.query
this.paperId = query.paperId
this.title = query.title
this.id = query.id
......@@ -84,7 +93,6 @@ export default {
paperId:id
}
getDetailPaperAPI(data).then(res=>{
console.log(res.data.data);
if(res.data.code == 0){
this.detail = res.data.data
}else{
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论