This commit is contained in:
@fawn-nine
2024-09-05 17:10:11 +08:00
parent a9f706e96f
commit 409e808a3c
6 changed files with 578 additions and 408 deletions

View File

@@ -6,13 +6,14 @@
@click="showPopup = true">考试说明</text>
</z-nav-bar>
<!-- 有考试结果时候 -->
<template>
<template v-if="exameResult.id">
<view class="border_radius_10 haveResult">
<view class="scoreBox">
本次考试卷面成绩为<text class="score PM_font">90</text>
</view>
<view class="">
<button type="primary" @click="goToClass">返回班级</button> <button type="primary" @click="goToPaper">查看试卷</button>
<button type="primary" @click="goToClass">返回班级</button>
<button type="primary" @click="goToPaper">查看试卷</button>
</view>
<view class="result_imgBox">
<image src="../../static/jiesuan_Icon.jpg" mode="widthFix"></image>
@@ -20,12 +21,7 @@
</view>
</template>
<!-- 没有考试结果的时候 -->
<template>
<!-- <view class="tips border_radius_10">
<text>每位学员共有两次考试的机会考试成绩以两次成绩的最高分作为最终的卷面成绩请认真对待每次考试;<br />
请在倒计时结束前完成答题倒计时结束后将自动交卷;<br />
考试结束前中途离开视为放弃此次考试成绩为0分</text>
</view> -->
<template v-else>
<view style="padding: 20rpx; " class="timeBox border_radius_10 flex_box flex_between align-items_box"
v-if="paperCreateTime > 0">
<!-- <view class=""> -->
@@ -33,12 +29,15 @@
<text><i style="color: #00aaff; font-style: normal; margin-right: 10rpx;" class="">{{curIndex1+1}}
</i> / {{testPaper.length}}</text>
</view>
<view class="flex_box align-items_box">
<view class="flex_box align-items_box" v-if="secondTimeDif > 0">
<view class="">
剩余时间
</view>
<view class="">
<uni-countdown @timeup="timeup" :font-size="20" :show-day="false" :hour="paperCreateTime"
<uni-countdown @timeup="timeup" :font-size="20" :show-day="false"
:hour="timeDif.hour"
:minute="timeDif.minutes"
:second="timeDif.second"
color="#ffaa7f" />
</view>
</view>
@@ -48,13 +47,11 @@
<view class="question border_radius_10" v-if="curQuestion.id">
<view class="">
<text class="questionType">{{curQuestion.type == 0 ? '单选题' : '多选题'}}</text>
<text class="checkQuestBtn small_btn border_radius_10" @click="showQuestIndex = true">检查</text>
<view class="questionItem" v-if="curQuestion.id">
<view class="">
<text>{{curQuestion.content}}</text>
</view>
<!-- <view class="">
{{curQuestion}}-{{curIndex1}}
</view> -->
</view>
<view class="optionsBox">
<view
:class="['item','border_radius_10',curQuestion.answerIds.includes(item.id) ? 'choosed' : '']"
@@ -70,28 +67,15 @@
<button @click="showPrevQuestion" type="default" plain="true" :disabled="curIndex1 == 0"
size="mini">上一题</button>
</view>
<view class="item" v-show="curIndex1 == testPaper.length-1 && !isOvertime">
<button @click="sumitAnswer" type="primary" size="mini"> </button>
</view>
<view class="item">
<button @click="showNextQuestion" type="primary"
:disabled="curIndex1 == testPaper.length-1" size="mini">下一题</button>
</view>
</view>
<!-- v-show="curIndex1 == testPaper.length-1 && !isOvertime" -->
<view class="" style="margin-top: 20rpx;"
>
<button @click="sumitAnswer" type="primary"> </button>
</view>
</view>
<view class="questIndx ">
<view class="" style="text-align: center; font-size: 24rpx; color: #666;">
<span>题目索引</span>
</view>
<scroll-view class="scroll-view_H" scroll-x="true">
<view class="scroll-view-item_H" v-for="index of getallLIst" :key="index">
<text @click="clickIndex(index)"
:class="[ haveAnswerList.includes(index-1) ? 'green' : '', noAnswerList.includes(index-1) ? 'red' : '',(curIndex1+1) == index ? 'cur' :'']">{{index}}</text>
</view>
</scroll-view>
</view>
</view>
</view>
</view>
</template>
@@ -100,8 +84,25 @@
<h3>考试说明</h3>
<view class="tips border_radius_10">
<text>每位学员共有两次考试的机会考试成绩以两次成绩的最高分作为最终的卷面成绩请认真对待每次考试;<br />
请在倒计时结束前完成答题倒计时结束后将自动交卷;<br />
考试结束前中途离开视为放弃此次考试成绩为0分</text>
请在倒计时结束前完成答题倒计时结束后将自动交卷</text>
</view>
</view>
</u-popup>
<u-popup key="2" :show="showQuestIndex" :round="10" @close="hidePopup">
<view class="guanli">
<h3>题目索引</h3>
<view class="">
<view class="questIndx questIndxPup flex_box">
<!-- <view class="" style="text-align: center; font-size: 24rpx; color: #666;">
<span>题目索引可左右滑动</span>
</view> -->
<!-- <scroll-view class="scroll-view_H" scroll-x="true">
<view class="scroll-view-item_H" v-for="index of getallLIst" :key="index"> -->
<text v-for="index of getallLIst" @click="clickIndex(index)" :key="index"
:class="[ haveAnswerList.includes(index-1) ? 'green' : '', noAnswerList.includes(index-1) ? 'red' : '',(curIndex1+1) == index ? 'cur' :'']">{{index}}</text>
<!-- </view>
</scroll-view> -->
</view>
</view>
</view>
</u-popup>
@@ -111,7 +112,7 @@
<script>
import $http from '@/config/requestConfig.js';
import {
mapState
mapState,mapMutations
} from "vuex";
export default {
data() {
@@ -128,6 +129,7 @@
paperCreateTime: 0,
examId: undefined,
endTime: undefined, // 结束时间戳
timeDif:{}, // 时间差(结束 - 现在)
isOvertime: false, // 是否超时
step: 8, /// 步长
// questIndexList: [],
@@ -136,7 +138,9 @@
maxNumber: 0,
minNumber: 0,
noAnswerList: [],
haveAnswerList:[]
haveAnswerList:[],
exameResult:{},
showQuestIndex:false,
}
},
async onLoad(e) {
@@ -152,8 +156,8 @@
if (!this.isOvertime) {}
},
onShow() {
this.endTime = this.hourUp(1)
console.log('this.endTime', this.endTime.getTime());
// this.endTime = this.hourUp(1)
// console.log('this.endTime', this.endTime.getTime());
},
beforeDestroy() {
if (!this.isOvertime) { // 如果中途退出
@@ -171,6 +175,7 @@
},
methods: {
...mapMutations(['setPaperEndTime']),
// 单个题的提交
saveQuestAnswer(paperId,questIndex,ids){
console.log('收到的值',paperId,questIndex,ids);
@@ -205,34 +210,34 @@
})
});
},
getNoAnswerList() {
getNoAnswerList() {
var list = []
if (this.curIndex1 > 0) {
for (var i = 0; i < this.curIndex1; i++) {
if (this.testPaper[i].answerIds.length == 0) {
// if (this.curIndex1 > 0) {
for (var i = 0; i < this.testPaper.length; i++) {
if (this.testPaper[i].answerIds.length == 0 && this.testPaper[i].hadOpend) {
console.log('fuhe?');
list.push(i)
}
}
}
// }
return list
},
gethaveAnswerList() {
var list = []
if (this.curIndex1 > 0) {
for (var i = 0; i < this.curIndex1; i++) {
if (this.testPaper[i].answerIds.length > 0) {
console.log('fuhe?');
// if (this.curIndex1 > 0) {
for (var i = 0; i < this.testPaper.length; i++) {
if (this.testPaper[i].answerIds.length > 0 && this.testPaper[i].hadOpend) {
// console.log('fuhe?');
list.push(i)
}
}
}
// }
return list
},
// 倒计时结束 (超时)
timeup() {
this.isOvertime = true
this.sumitAnswer()
this.sumbitPaper()
let that = this
uni.showModal({
title: '提示',
@@ -248,24 +253,29 @@
},
goToPaper(){
uni.navigateTo({
url: `/pages/miniClass/paperBack?id=${this.classId}`
url: `/pages/miniClass/paperBack?id=${this.examId}`
})
},
// 获取交卷数据
sumitAnswer() {
// var list = []
// var _newList = this.testPaper.map(item => {
// return item.answerIds
// })
// _newList = _newList.map(item => {
// return item.join(',')
// })
// console.log('_newList', _newList);
// list = _newList
// return list
this.sumbitPaper()
sumitAnswer() {
let that = this
// this.noAnswerList = await this.getNoAnswerList()
if(this.noAnswerList.length > 0){
this.showQuestIndex = true
uni.showModal({
title:'提示',
content:'您有未作答的题目,是否继续交卷操作?',
cancelText:'点错了',
confirmText:'确定',
success(res) {
if (res.confirm) {
that.sumbitPaper()
}
},
})
}
},
// q请求提交试卷
sumbitPaper(ids) {
@@ -306,8 +316,10 @@
this.curQuestion = {
...this.testPaper[this.curIndex1]
}
this.testPaper[this.curIndex1].hadOpend = true
console.log('----------------', this.testPaper );
// this.haveAnswerList = this.gethaveAnswerList()
this.noAnswerList = this.getNoAnswerList()
this.haveAnswerList = this.gethaveAnswerList()
},
showNextQuestion() {
// 下一题
@@ -316,7 +328,9 @@
this.curQuestion = {
...this.testPaper[this.curIndex1]
}
console.log('+++++++++++++++', this.testPaper, );
this.testPaper[this.curIndex1].hadOpend = true
// console.log('+++++++++++++++', this.testPaper, );
this.noAnswerList = this.getNoAnswerList()
this.haveAnswerList = this.gethaveAnswerList()
},
clickOption(item, index) {
@@ -375,6 +389,7 @@
// that.isHave = true
res.examPaper.forEach(item => {
item.answerIds = []
item.hadOpend = false // 是否呗打开过
var code = 0
item.options.forEach(item1 => {
const randomAbc = this.setDesc().splice(65)
@@ -385,11 +400,23 @@
this.testPaper = res.examPaper
this.examId = res.id
this.paperCreateTime = 1
this.endTime = this.hourUp(1)
console.log('this.endTime', this.endTime);
this.endTime = this.hourUp(res.startTime,2) // 结束的时间戳
this.secondTimeDif = this.endTime - Date.now() // 时间差 毫秒
if(this.secondTimeDif > 0){
this.setPaperEndTime({time:this.endTime})
this.timeDif.hour = (this.secondTimeDif % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
this.timeDif.minutes = (this.secondTimeDif % (1000 * 60 * 60)) / (1000 * 60);
this.timeDif.second = (this.secondTimeDif % (1000 * 60)) / 1000
console.log('this.endTime',this.timeDif.hour, this.timeDif.minutes, this.timeDif.second);
}else{
this.setPaperEndTime(0)
}
console.log('本地存储的结束时间', this.$store.state.paperEndTime);
this.curQuestion = {
...this.testPaper[this.curIndex1]
}
this.testPaper[this.curIndex1].hadOpend = true
uni.showToast({
title: '获取成功',
icon: 'success'
@@ -433,22 +460,30 @@
},
hidePopup() {
this.showPopup = false
this.showQuestIndex = false
},
clickIndex(val) {
this.curIndex1 = val - 1
console.log('val', val, this.curIndex1, this.testPaper.length);
for (var i = 0; i < this.curIndex1; i++) {
this.testPaper[i].hadOpend = true
}
this.curQuestion = this.testPaper[this.curIndex1]
this.testPaper[this.curIndex1].hadOpend = true
this.hidePopup()
this.noAnswerList = this.getNoAnswerList()
this.haveAnswerList = this.gethaveAnswerList()
},
hourUp(e) {
hourUp(start,e) {
// 比现在多几个小时
var end = Date.now()
var start = 1000 * 60 * 60 * e
var interval = end + start; //结束 - 开始 = 毫秒值
var a = new Date(interval)
return a
// var end = Date.now()
var startTimeDate = new Date(start)
var startTime = startTimeDate.getTime();
var step = 1000 * 60 * 60 * e // 时间间隔
var interval = startTime + step; //开始 + 时长 = 结束的毫秒数
// var a = new Date(interval)
console.log('aaaaaaaaaa结束时间的毫秒数时间戳',interval);
return interval
},
}
}
@@ -466,14 +501,16 @@
border-color: #67c23a; color: #67c23a;
}
text {
font-size: 28rpx;
background-color: #fff;
padding: 6rpx 10rpx;
// padding: 6rpx 10rpx;
display: flex;
justify-content: center;
// justify-content: center;
border-radius: 10rpx;
align-items: center;
width: 60rpx;
height: 60rpx;
// align-items: center;
width: 70rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
border: 1px solid #eee;
}
@@ -483,10 +520,11 @@
color: #fff;
}
}
.guanli {
padding: 40rpx;
max-height: 60vh;
overflow-y: scroll;
h3 {
text-align: center;
margin-bottom: 20rpx;
@@ -512,7 +550,15 @@
padding: 10rpx 20rpx;
border-radius: 0 50rpx 50rpx 0;
}
.checkQuestBtn {
position: absolute;
right: 20rpx;
top: 20rpx;
border: 1px solid $themeColor;
color: $themeColor;
// padding: 10rpx 20rpx;
// border-radius: 0 50rpx 50rpx 0;
}
.scroll-Y {
height: 300rpx;
}
@@ -567,8 +613,8 @@
.item {
border: 1px solid #eee;
padding: 24rpx 20rpx;
margin-bottom: 20rpx;
padding: 16rpx 12rpx;
margin-bottom: 16rpx;
}
.choosed {
@@ -605,12 +651,20 @@
}
.questIndx {
.cur {
border-color:#409eff ;
background-color: #409eff;
color: #fff;
}
}
.questIndxPup{
justify-content: space-around;
flex-wrap: wrap;
text{
display: inline-block; margin: 10rpx;
}
}
.btnBox {
.item {
width: 40%;