This commit is contained in:
@fawn-nine
2024-09-06 17:08:49 +08:00
parent 409e808a3c
commit ac4f5dcd66
5 changed files with 1263 additions and 135 deletions

View File

@@ -9,11 +9,11 @@
<template v-if="exameResult.id">
<view class="border_radius_10 haveResult">
<view class="scoreBox">
本次考试卷面成绩为<text class="score PM_font">90</text>
本次考试卷面成绩为<text class="score PM_font">{{exameResult.score}} </text>
</view>
<view class="">
<button type="primary" @click="goToClass">返回班级</button>
<button type="primary" @click="goToPaper">查看试卷</button>
<view class="flex_box flex_between">
<button type="primary" size="mini" @click="goToClass">返回班级</button>
<button type="warn" size="mini" @click="goToPaper">查看试卷</button>
</view>
<view class="result_imgBox">
<image src="../../static/jiesuan_Icon.jpg" mode="widthFix"></image>
@@ -23,7 +23,7 @@
<!-- 没有考试结果的时候 -->
<template v-else>
<view style="padding: 20rpx; " class="timeBox border_radius_10 flex_box flex_between align-items_box"
v-if="paperCreateTime > 0">
v-if="secondTimeDif > 0">
<!-- <view class=""> -->
<view class="">
<text><i style="color: #00aaff; font-style: normal; margin-right: 10rpx;" class="">{{curIndex1+1}}
@@ -91,11 +91,11 @@
<u-popup key="2" :show="showQuestIndex" :round="10" @close="hidePopup">
<view class="guanli">
<h3>题目索引</h3>
<view class="" style="text-align: center; font-size: 28rpx; line-height: 50rpx; color: #666;">
<text>红框标识未作答绿色框标识已选定答案灰色框标识您未查看的题目</text>
</view>
<view class="">
<view class="questIndx questIndxPup flex_box">
<!-- <view class="" style="text-align: center; font-size: 24rpx; color: #666;">
<span>题目索引可左右滑动</span>
</view> -->
<view class="questIndx questIndxPup flex_box">
<!-- <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"
@@ -141,15 +141,18 @@
haveAnswerList:[],
exameResult:{},
showQuestIndex:false,
secondTimeDif:undefined
}
},
async onLoad(e) {
console.log('收到得值');
this.classId = e.classId
if (this.testPaper.length == 0) {
// this.examId = e.id
if (this.testPaper.length <= 0) {
this.getTestPage()
}
// this.questIndexList = await this.getNowList('add')
},
onHide() {
@@ -176,6 +179,28 @@
},
methods: {
...mapMutations(['setPaperEndTime']),
// 获取服务器时间
async getServerTime() {
var time = 0
await $http.request({
url: "common/classExam/getServerTime",
method: "POST",
data: {},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
},
})
.then(async (res) => {
if (res.code == 0) {
time = res.serverTime
} else {
time = -1
}
}).catch(e => {
time = -1
});
return time
},
// 单个题的提交
saveQuestAnswer(paperId,questIndex,ids){
console.log('收到的值',paperId,questIndex,ids);
@@ -209,7 +234,7 @@
icon: 'error'
})
});
},
},
getNoAnswerList() {
var list = []
// if (this.curIndex1 > 0) {
@@ -238,15 +263,18 @@
timeup() {
this.isOvertime = true
this.sumbitPaper()
let that = this
let that = this
uni.showModal({
title: '提示',
content: "考试结束,系统已为您自动交卷",
content: "考试结束,系统已为您自动交卷,点击按钮返回所在班级",
confirmText: '知道了',
showCancel: false,
success: (res) => {
if (res.confirm) {
// that.goToClass()
// that.goToClass()
uni.navigateTo({
url: `/pages/miniClass/classInfo?id=${that.classId}`
})
}
}
})
@@ -274,16 +302,19 @@
}
},
})
}else{
that.sumbitPaper()
}
},
// q请求提交试卷
sumbitPaper(ids) {
let that = this
$http.request({
url: "common/classExam/submitExamPaper",
method: "POST",
data: {
id: this.examId
id: that.examId
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
@@ -292,11 +323,34 @@
.then(res => {
uni.hideLoading()
if (res.code == 0) {
console.log('交卷结果',res);
uni.showToast({
title: '交卷成功',
icon: 'success'
})
this.isOvertime = true
setTimeout( ()=>{
that.exameResult = res.examPaper
// this.timeup()
that.showQuestIndex = false
that.secondTimeDif = 0
that.isOvertime = true
uni.setStorage({
key:'paperEndTime',
data:{
time: 0,
examId: undefined
},
success: function () {
console.log('时间存储成功');
}
})
},300)
}else{
uni.showToast({
title: e.errMsg,
icon: 'error'
})
}
}).catch(e => {
@@ -304,7 +358,7 @@
console.log(e, '数据报错')
// this.status = 3
uni.showToast({
title: e.errorMsg,
title: e.errMsg,
icon: 'error'
})
});
@@ -369,11 +423,11 @@
}
return letterArr
},
getTestPage() {
async getTestPage() {
uni.showLoading({
title: '正在生成试卷'
})
$http.request({
await $http.request({
url: "common/classExam/generateExamPaper",
method: "POST",
data: {
@@ -383,7 +437,7 @@
'Content-Type': 'application/json'
},
})
.then(res => {
.then(async res => {
uni.hideLoading()
if (res.code == 0) {
// that.isHave = true
@@ -401,16 +455,37 @@
this.examId = res.id
this.paperCreateTime = 1
this.endTime = this.hourUp(res.startTime,2) // 结束的时间戳
this.secondTimeDif = this.endTime - Date.now() // 时间差 毫秒
var severNowTime = await this.getServerTime()
this.secondTimeDif = this.endTime - severNowTime // 时间差 毫秒
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.setPaperEndTime({time:this.endTime})
uni.setStorage({
key:'paperEndTime',
data:{
time: this.endTime,
examId: this.examId,
},
success: function () {
console.log('时间存储成功');
}
})
this.timeDif.hour = parseInt((this.secondTimeDif % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))
this.timeDif.minutes = parseInt((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)
uni.setStorage({
key:'paperEndTime',
data:{
time: 0,
examId: undefined,
},
success: function () {
console.log('时间存储成功');
}
})
}
console.log('本地存储的结束时间', this.$store.state.paperEndTime);
this.curQuestion = {
@@ -613,7 +688,7 @@
.item {
border: 1px solid #eee;
padding: 16rpx 12rpx;
padding: 20rpx 16rpx;
margin-bottom: 16rpx;
}