|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<view id="questionBank">
|
|
|
- <uni-nav-bar left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
|
|
|
+ <uni-nav-bar @clickLeft="clickLeft" left-icon="back" :statusBar="true" title="试卷"></uni-nav-bar>
|
|
|
<swiper class="swiper" :current="current" @change="swiperChange" :interval="interval">
|
|
|
<swiper-item v-for="(bank,bankIndex) in questionList" :key="bankIndex">
|
|
|
<view class="pageContent">
|
|
@@ -323,6 +323,35 @@
|
|
|
<view class="text">左右滑动切换上下题</view>
|
|
|
<view class="btn" @click="hideDialog">我知道了</view>
|
|
|
</view>
|
|
|
+
|
|
|
+ <view class="dialog_wrap" v-if="testOver">
|
|
|
+ <view class="bg"></view>
|
|
|
+ <view class="dialog">
|
|
|
+ <view class="title">温馨提示</view>
|
|
|
+ <view class="content">
|
|
|
+ <view>您已完成所有题目,</view>
|
|
|
+ <view>快去交卷吧!</view>
|
|
|
+ </view>
|
|
|
+ <view class="btns">
|
|
|
+ <view class="btn" @click="noSubmit()">暂不交卷</view>
|
|
|
+ <view class="btn active" @click="submitNow()">立即交卷</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <view class="dialog_wrap" v-if="isLastCount">
|
|
|
+ <view class="bg"></view>
|
|
|
+ <view class="dialog">
|
|
|
+ <view class="title">温馨提示</view>
|
|
|
+ <view class="content">
|
|
|
+ <view>您当前正在测试,还剩{{lastCount}}道题未完成,离开视为交卷</view>
|
|
|
+ </view>
|
|
|
+ <view class="btns">
|
|
|
+ <view class="btn" @click="noLeave()">暂不离开</view>
|
|
|
+ <view class="btn active" @click="leaveNow()">继续离开</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -347,7 +376,11 @@ export default {
|
|
|
lastTime:0,
|
|
|
timer :null,
|
|
|
wrongList:[],
|
|
|
- bankType:0
|
|
|
+ bankType:0, //试卷类型
|
|
|
+ needBack:false, //是否是考试
|
|
|
+ testOver:false,
|
|
|
+ isLastCount:false, //是否有未答题目
|
|
|
+ lastCount:0, //剩余没有回答的题目数
|
|
|
};
|
|
|
},
|
|
|
onLoad(option){
|
|
@@ -365,25 +398,35 @@ export default {
|
|
|
}
|
|
|
} else {
|
|
|
this.goodsQuestionList();
|
|
|
- this.wrongRecordExamQuestionList();
|
|
|
+ // this.wrongRecordExamQuestionList();
|
|
|
this.bankExam();
|
|
|
}
|
|
|
},
|
|
|
onUnload() {
|
|
|
- this.examRecordEdit();
|
|
|
- if(this.bankType == 2) {
|
|
|
+ if(this.isSubmit) {
|
|
|
+ this.examRecordEdit();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //考试试卷 阻止ios手势返回,自动跳回答题页
|
|
|
+ if(this.needBack) {
|
|
|
let app = getApp();
|
|
|
app.globalData.bankData = this.$data;
|
|
|
uni.navigateTo({
|
|
|
url: '/pages2/bank/questionBank?id='+this.id+'&goodsid='+this.goodsId+'&isback=true'
|
|
|
})
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ //点击返回按钮确认允许退出,记录答题记录
|
|
|
+ this.examRecordEdit();
|
|
|
+ }
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
bankExam() {
|
|
|
this.$api.bankExam(this.id).then(res => {
|
|
|
this.bankType = res.data.data.doType;
|
|
|
+ if(this.bankType == 1) {
|
|
|
+ this.needBack = true;
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
@@ -397,6 +440,134 @@ export default {
|
|
|
this.wrongList = res.data.rows
|
|
|
})
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 点击后退按钮
|
|
|
+ */
|
|
|
+ clickLeft() {
|
|
|
+
|
|
|
+ if(this.bankType == 2) {
|
|
|
+ this.needBack = false;
|
|
|
+ uni.navigateBack({
|
|
|
+ delta:1
|
|
|
+ })
|
|
|
+ } else if(this.bankType == 1){
|
|
|
+ let ansCount = this.questionOverNum();
|
|
|
+ this.lastCount = this.questionList.length - ansCount;
|
|
|
+
|
|
|
+ if(this.lastCount == 0) {
|
|
|
+ this.testOver = true;
|
|
|
+ } else {
|
|
|
+ this.isLastCount = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 获取已经回答的题目数
|
|
|
+ */
|
|
|
+ questionOverNum() {
|
|
|
+ let count = 0;
|
|
|
+ this.questionList.forEach(item => {
|
|
|
+ if(item.type == 1 || item.type == 2 || item.type == 3) {
|
|
|
+ if(item.ques) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ } else if(item.type == 4) { //案例题
|
|
|
+ let isOver = item.jsonStr.every(jsonItem => {
|
|
|
+ if(jsonItem.type == 1 || jsonItem.type == 2 || jsonItem.type == 3) {
|
|
|
+ if(jsonItem.ques) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else if(jsonItem.type ==5) {
|
|
|
+ if(jsonItem.ansText.text.length || jsonItem.ansText.imageList.length) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if(isOver) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ } else if(item.type == 5) { //简答题
|
|
|
+ if(item.ansText.text.length || item.ansText.imageList.length) {
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return count;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 暂不交卷
|
|
|
+ */
|
|
|
+ noSubmit() {
|
|
|
+ //设为允许退出页面
|
|
|
+ this.needBack = false;
|
|
|
+ uni.navigateBack({
|
|
|
+ delta:1
|
|
|
+ })
|
|
|
+ },
|
|
|
+ noLeave() {
|
|
|
+ this.isLastCount = false;
|
|
|
+ },
|
|
|
+ leaveNow() {
|
|
|
+ this.needBack = false;
|
|
|
+ uni.navigateBack({
|
|
|
+ delta:1
|
|
|
+ })
|
|
|
+ let score = 0; //计算总分
|
|
|
+ let reportStatus = 0;
|
|
|
+ let number = 0;
|
|
|
+ this.questionList.forEach((item,index) => {
|
|
|
+ if(item.type == 1) {
|
|
|
+ if(item.ques == item.ans) {
|
|
|
+ score += item.score;
|
|
|
+ number++
|
|
|
+ }
|
|
|
+ } else if(item.type == 2) {
|
|
|
+ let isRight = item.ques && item.ques.every((quesItem,quesIndex) => {
|
|
|
+ return item.ques[quesIndex] == item.ans[quesIndex]
|
|
|
+ })
|
|
|
+
|
|
|
+ if(isRight) {
|
|
|
+ score += item.score;
|
|
|
+ number++
|
|
|
+ }
|
|
|
+ } else if(item.type == 3) {
|
|
|
+ if(item.ques == item.ans) {
|
|
|
+ score += item.score;
|
|
|
+ number++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ // if(score >= 60) {
|
|
|
+ // reportStatus = 1
|
|
|
+ // } else {
|
|
|
+ // reportStatus = 0
|
|
|
+ // }
|
|
|
+
|
|
|
+ this.$api.examRecordEdit({
|
|
|
+ examId:this.id,
|
|
|
+ goodsId:this.goodsId,
|
|
|
+ // reportStatus:reportStatus,
|
|
|
+ recordId: this.recordId,
|
|
|
+ rightQuestionNum:number,
|
|
|
+ status:1,
|
|
|
+ score:score,
|
|
|
+ historyExamJson:JSON.stringify(this.questionList)
|
|
|
+ }).then(res => {
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ submitNow() {
|
|
|
+ this.needBack = false;
|
|
|
+ this.submit();
|
|
|
+ },
|
|
|
/**
|
|
|
* 离开页面统计回答正确题数
|
|
|
*/
|
|
@@ -565,6 +736,7 @@ export default {
|
|
|
})
|
|
|
|
|
|
this.questionList = res.data.data;
|
|
|
+ this.lastCount = this.questionList.length;
|
|
|
this.examRecord()
|
|
|
this.getCollectInfo(this.current)
|
|
|
|
|
@@ -818,9 +990,9 @@ export default {
|
|
|
});
|
|
|
|
|
|
setTimeout(() => {
|
|
|
- uni.navigateBack({
|
|
|
- delta: 1
|
|
|
- });
|
|
|
+ uni.redirectTo({
|
|
|
+ url:'/pages2/bank/question_report?id='+this.recordId
|
|
|
+ })
|
|
|
},2000)
|
|
|
}
|
|
|
})
|
|
@@ -1036,7 +1208,7 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- this.$set(this.ques,bankindex,{
|
|
|
+ this.$set(this.questionList[bankindex],'ques',{
|
|
|
imageList:this.questionList[bankindex].ansText.imageList,
|
|
|
text:this.questionList[bankindex].ansText.text,
|
|
|
})
|
|
@@ -1153,7 +1325,7 @@ export default {
|
|
|
<style lang="scss" scoped>
|
|
|
.swiper {
|
|
|
width:100%;
|
|
|
- height:100vh;
|
|
|
+ height:calc(100vh - 44px);
|
|
|
}
|
|
|
.lisSty {
|
|
|
margin-bottom: 16rpx;
|
|
@@ -1495,4 +1667,77 @@ export default {
|
|
|
font-size: 32rpx;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+.dialog_wrap {
|
|
|
+ position:fixed;
|
|
|
+ left:0;
|
|
|
+ top:0;
|
|
|
+ width:100%;
|
|
|
+ height:100%;
|
|
|
+ z-index: 9999999999;
|
|
|
+
|
|
|
+ .bg {
|
|
|
+ background:rgba(0, 0, 0, 0.3);
|
|
|
+ position:absolute;
|
|
|
+ left:0;
|
|
|
+ top:0;
|
|
|
+ width:100%;
|
|
|
+ height:100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dialog {
|
|
|
+ position:absolute;
|
|
|
+ left:50%;
|
|
|
+ top:50%;
|
|
|
+ transform: translate3D(-50%,-50%,0);
|
|
|
+ width: 640rpx;
|
|
|
+ height: 439rpx;
|
|
|
+ background: #FFFFFF;
|
|
|
+ border-radius: 24rpx;
|
|
|
+
|
|
|
+
|
|
|
+ .title {
|
|
|
+ font-size: 30rpx;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #333333;
|
|
|
+ line-height: 48rpx;
|
|
|
+ text-align: center;
|
|
|
+ margin-top:40rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .content {
|
|
|
+ margin:35rpx 35rpx 0;
|
|
|
+ font-size: 30rpx;
|
|
|
+ color: #666666;
|
|
|
+ line-height: 48rpx;
|
|
|
+ }
|
|
|
+
|
|
|
+ .btns {
|
|
|
+ margin-top:35rpx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+
|
|
|
+ .btn {
|
|
|
+ width: 200rpx;
|
|
|
+ height: 80rpx;
|
|
|
+ line-height: 80rpx;
|
|
|
+ text-align: center;
|
|
|
+ background: #F5F5F5;
|
|
|
+ border-radius: 40rpx;
|
|
|
+ font-size: 30rpx;
|
|
|
+ color:rgba(0, 122, 255, 1);
|
|
|
+ background: #F5F5F5;
|
|
|
+ margin:0 20rpx;
|
|
|
+
|
|
|
+ &.active {
|
|
|
+ color: #F5F5F5;
|
|
|
+ background: rgba(0, 122, 255, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
</style>
|