YNUtdPlatform/pages/YNEduApp/exam/examinationDetails.vue

377 lines
9.1 KiB
Vue
Raw Normal View History

2024-08-14 18:55:18 +08:00
<template>
<view class="wrapper">
2024-08-15 17:47:52 +08:00
<div class="arrow-left">
<u-icon name="arrow-left" size="20" color="#fff" @click="handleArrow" />
</div>
2024-08-14 18:55:18 +08:00
<div class="result">
<div class="result-item">{{ result }}</div>
<div class="result-tip">最新记录</div>
</div>
<div class="center-container">
<div class="top-wrapper">
<div class="item">
<div>{{ scoreRate }}</div>
2024-08-23 16:00:43 +08:00
<div class="tip">得分</div>
2024-08-14 18:55:18 +08:00
</div>
<div class="item">
2024-08-23 16:00:43 +08:00
<div>{{ rightRate }}%</div>
2024-08-14 18:55:18 +08:00
<div class="tip">正确率</div>
</div>
<div class="item">
2024-08-23 16:00:43 +08:00
<div>{{ answerTime }}分钟</div>
2024-08-14 18:55:18 +08:00
<div class="tip">作答用时</div>
</div>
</div>
<div class="bottom-wrapper">
<div class="item">总分{{ totalScore }}</div>
<div class="item">及格分{{ passScore }}</div>
<div class="item">考试时长{{ duration }}分钟</div>
<div class="item">试题{{ questionCount }}</div>
</div>
</div>
<div class="bottom-container">
<h2 class="title">榜上有名</h2>
<div class="title-tab">
<div>排名</div>
<div>姓名/部门</div>
<div>得分</div>
<div>得分率</div>
</div>
<div v-for="(item, index) in rankList" :key="index" class="rank-list">
<div class="icon">
2024-08-15 17:47:52 +08:00
<u-icon :name="iconLit[index]" size="30" />
2024-08-23 16:00:43 +08:00
<u-avatar src="/static/images/user.png" size="40" />
2024-08-14 18:55:18 +08:00
</div>
2024-08-23 16:00:43 +08:00
<div>{{ `${item.userName}/${item.orgName}` }}</div>
<div>{{ item.examGrade }}</div>
<div>{{ item.gradeAverage }}</div>
2024-08-14 18:55:18 +08:00
</div>
</div>
<!-- 底部按钮 -->
<div class="bottom-btn">
2024-08-23 16:00:43 +08:00
<!-- <div class="btn">
2024-08-15 17:47:52 +08:00
<u-button
size="small"
shape="circle"
text="考试记录"
style="color: #1989fa; border-color: #1989fa"
@click="handleExamination"
/>
2024-08-23 16:00:43 +08:00
</div> -->
2024-08-14 18:55:18 +08:00
<div class="btn">
2024-08-23 16:00:43 +08:00
<u-button type="primary" size="small" shape="circle" text="重新考试" @click="handleResetExamination" />
2024-08-14 18:55:18 +08:00
</div>
</div>
</view>
</template>
<script>
2024-08-23 16:00:43 +08:00
import { getExamRankById } from '@/api/eduApp'
2024-08-28 09:51:05 +08:00
import config from '@/config'
2024-08-23 16:00:43 +08:00
2024-08-14 18:55:18 +08:00
export default {
data() {
return {
2024-08-23 16:00:43 +08:00
examId: '',
2024-08-14 18:55:18 +08:00
result: '不及格',
2024-08-23 16:00:43 +08:00
// 得分
scoreRate: '',
2024-08-14 18:55:18 +08:00
// 正确率
rightRate: '60%',
// 作答用时
2024-08-23 16:00:43 +08:00
answerTime: '',
2024-08-14 18:55:18 +08:00
// 总分
totalScore: 100,
// 及格分
passScore: 60,
// 考试时长
2024-08-23 16:00:43 +08:00
duration: 0,
2024-08-14 18:55:18 +08:00
// 试题
2024-08-23 16:00:43 +08:00
questionCount: 0,
// 考试次数
examNum: 0,
2024-09-04 15:18:01 +08:00
examCount: '', // 考试次数 1: 不限次 2: 及格终止 3: 自定义
2024-08-23 16:00:43 +08:00
examCustom: 0, // 自定义次数
results: 0, // 考试结果
2024-08-26 21:46:08 +08:00
studyId: '',
2024-08-15 17:47:52 +08:00
iconLit: ['/static/images/top-one.png', '/static/images/top-two.png', '/static/images/top-three.png'],
2024-08-14 18:55:18 +08:00
// 榜上有名 - 列表
2024-08-23 16:00:43 +08:00
rankList: []
2024-08-14 18:55:18 +08:00
}
},
2024-08-23 16:00:43 +08:00
onLoad(opt) {
opt = JSON.parse(opt.params)
console.log('🚀 ~ onLoad ~ opt:', opt)
this.examId = opt.examId
this.result = opt.examResult == 1 ? '及格' : '不及格'
this.scoreRate = opt.examGrade
this.rightRate = opt.gradeAverage
this.answerTime = opt.answerTime
this.duration = opt.examTime
this.questionCount = opt.questionCount
this.examNum = opt.examNum
this.examCount = opt.examCount
this.examCustom = opt.examCustom
this.results = opt.results
2024-08-26 21:46:08 +08:00
this.studyId = opt.studyId || ''
2024-08-28 09:51:05 +08:00
this.totalScore = opt.score || 100
this.passScore = opt.passScore || 60
2024-08-23 16:00:43 +08:00
},
mounted() {
this.getExamRankById()
},
2024-08-15 17:47:52 +08:00
methods: {
2024-08-23 16:00:43 +08:00
// handleExamination() {
// uni.navigateTo({
// url: '/pages/YNEduApp/exam/examinationList'
// })
// },
// 重新考试
handleResetExamination() {
2024-08-29 18:12:47 +08:00
let from = ''
if (this.studyId) {
from = '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.studyId
} else {
from = '/pages/YNEduApp/exam/exam'
2024-08-23 16:00:43 +08:00
}
2024-09-04 15:18:01 +08:00
2024-08-23 16:00:43 +08:00
// examCount 1: 不限次 2: 及格终止 3: 自定义
if (this.examCount == 2 && this.results == 1) {
uni.showToast({
title: '此考试及格终止, 考试以及格, 无需再次考试',
icon: 'none'
})
2024-08-29 18:12:47 +08:00
setTimeout(() => {
2024-09-04 15:18:01 +08:00
uni.reLaunch({
2024-08-29 18:12:47 +08:00
url: from
})
}, 1000)
2024-08-23 16:00:43 +08:00
} else if (this.examCount == 3 && this.examNum >= this.examCustom) {
uni.showToast({
title: '此考试有次数限制, 考试次数已达上限, 无法再考试了',
icon: 'none'
})
2024-08-29 18:12:47 +08:00
setTimeout(() => {
2024-09-04 15:18:01 +08:00
uni.reLaunch({
2024-08-29 18:12:47 +08:00
url: from
})
}, 1000)
2024-09-04 15:18:01 +08:00
} else {
const params = {
examId: this.examId,
examNum: this.examNum,
examCount: this.examCount,
examCustom: this.examCustom,
switchCount: this.switchCount,
studyId: this.studyId
}
console.log('🚀 ~ handleResetExamination ~ params:', params)
uni.navigateTo({
url: `/pages/YNEduApp/exam/examination?params=${JSON.stringify(params)}`
})
2024-08-23 16:00:43 +08:00
}
2024-08-15 17:47:52 +08:00
},
handleArrow() {
2024-08-26 21:46:08 +08:00
let from = ''
if (this.studyId) {
2024-08-28 09:51:05 +08:00
from = '/pages/YNEduApp/learnProj/learnProjDetail?id=' + this.studyId
2024-08-26 21:46:08 +08:00
} else {
2024-08-28 09:51:05 +08:00
from = '/pages/YNEduApp/exam/exam'
2024-08-26 21:46:08 +08:00
}
console.log('🚀 ~ handleArrow ~ from:', from)
2024-08-15 17:47:52 +08:00
uni.navigateTo({
url: from
})
2024-08-23 16:00:43 +08:00
},
// 获取考试排名
async getExamRankById() {
const params = {
examId: this.examId
}
2024-08-28 09:51:05 +08:00
// const res = await getExamRankById(params)
// this.rankList = res.data
uni.request({
url: config.baseUrl + '/exam-student/studentExam/getExamRankById',
method: 'post',
data: params,
header: {
'Content-Type': 'application/x-www-form-urlencoded',
Authorization: uni.getStorageSync('access_token')
},
success: res => {
console.log('🚀 ~ getExamRankById ~ res:', res)
res = res.data
2024-08-29 18:12:47 +08:00
this.rankList = res.data.slice(0, 3)
2024-08-28 09:51:05 +08:00
},
fail: err => {
console.log(err)
}
})
2024-08-15 17:47:52 +08:00
}
}
2024-08-14 18:55:18 +08:00
}
</script>
<style lang="scss" scoped>
.wrapper {
height: 100vh;
2024-08-27 14:03:52 +08:00
background: url('/static/images/examine-detail-bg.png') no-repeat;
2024-08-14 18:55:18 +08:00
background-size: 100% 100%;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
2024-08-15 17:47:52 +08:00
.arrow-left {
position: fixed;
top: 50px;
left: 20px;
z-index: 99;
}
2024-08-14 18:55:18 +08:00
.result {
overflow: hidden;
width: 180.5px;
height: 118.6px;
background: url('/static/images/result-bg.png') no-repeat;
background-size: 100% 100%;
z-index: 9;
margin-top: 40px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
transform: translateY(40px);
.result-item {
font-size: 24px;
font-weight: bold;
}
.result-tip {
font-size: 12px;
margin-top: 5px;
}
}
.center-container {
margin: 0 10px;
width: calc(100% - 20px);
height: 250px;
background: #e8f2fe;
border-radius: 20px;
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
.top-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
margin: 0 10px;
.item {
margin-top: 25px;
width: 142px;
height: 73px;
background: #fff;
border-radius: 8px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-weight: 800;
font-size: 20px;
color: #08428d;
.tip {
font-weight: 400;
font-size: 12px;
}
}
}
.bottom-wrapper {
font-size: 12px;
color: #a1a1a1;
display: flex;
justify-content: space-between;
.item {
margin: 0 5px;
}
}
}
.bottom-container {
margin-top: 10px;
width: calc(100% - 20px);
height: 285px;
background: #e8f2fe;
border-radius: 20px;
.title {
font-weight: 800;
font-size: 20px;
color: #08428d;
margin: 15px auto;
text-align: center;
}
.title-tab {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
color: #a1a1a1;
margin: 0 10px;
> div {
width: 25%;
text-align: center;
}
}
.rank-list {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 13px;
color: #333;
2024-08-15 17:47:52 +08:00
margin: 20px 10px;
2024-08-14 18:55:18 +08:00
> div {
width: 25%;
text-align: center;
}
2024-08-15 17:47:52 +08:00
.icon {
display: flex;
justify-content: center;
align-items: center;
}
2024-08-14 18:55:18 +08:00
}
}
.bottom-btn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #fff;
padding: 10px 0;
display: flex;
2024-08-23 16:00:43 +08:00
justify-content: flex-end;
2024-08-14 18:55:18 +08:00
align-items: center;
.btn {
width: 100px;
margin-right: 10px;
}
}
}
</style>