From 409e808a3c603041c853e36bf8dc110f1441618d Mon Sep 17 00:00:00 2001
From: "@fawn-nine" <1271023382@qq.com>
Date: Thu, 5 Sep 2024 17:10:11 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages.json | 3 +-
pages/miniClass/classInfo.vue | 302 +++++++++++++++++----
pages/miniClass/classInfoMan.vue | 1 -
pages/miniClass/paperBack.vue | 444 ++++++++++++-------------------
pages/miniClass/test.vue | 222 ++++++++++------
store/modules/user.js | 14 +
6 files changed, 578 insertions(+), 408 deletions(-)
diff --git a/pages.json b/pages.json
index fe9e4c7..e83b932 100644
--- a/pages.json
+++ b/pages.json
@@ -715,7 +715,8 @@
"path" : "pages/miniClass/test",
"style" :
{
- "navigationBarTitleText" : "考试页面"
+ "navigationBarTitleText" : "考试页面",
+ "enablePullDownRefresh": false
}
},
{
diff --git a/pages/miniClass/classInfo.vue b/pages/miniClass/classInfo.vue
index 5df062b..291a28c 100644
--- a/pages/miniClass/classInfo.vue
+++ b/pages/miniClass/classInfo.vue
@@ -38,6 +38,58 @@
class="mainTxt">{{students.length}}/{{thisClass.number}}人
管理成员点击查看
+
+
+
+ 笔试分
+
+
+
+
+
+
+
+
+
+ 去考试{{showCountDown}}
+
+
+
+
+
+
+
+ {{paperSore}}
+ 分
+
+
+
+ 再考一次
+
+
+
+
+
+
+ 恭喜您获得A证, 查看证书
+ 很遗憾,您的成绩未达标
+
+ 加入新班级重修
+
+
+
+
+
+
@@ -67,29 +119,7 @@
{{performanceScore.questionScore}}分
-->
-
-
-
-
- 去考试
-
-
- 卷面成绩:60分再考一次
-
-
-
-
- 恭喜您获得A证, 查看证书
- 很遗憾,您的成绩未达标
-
- 加入新班级重修
-
- 总成绩为:90分 (50考试分+40平时表现分)
-
-
@@ -178,7 +208,7 @@
考试成绩
{{item.student.score.testScoreNumber}}
-
+
@@ -212,7 +242,7 @@
- 全部同学的
+ 全部同学的
只看我自己的
@@ -237,7 +267,8 @@
- {{item.zhedie ? '收起' : '展开'}}
+ {{item.zhedie ? '收起' : '展开'}}
+
日期:{{item.createTime}}
@@ -254,10 +285,12 @@
已提交答案
-
+
未提交答案 点击开始答题
-
+
未作答 已不可作答
@@ -332,6 +365,50 @@
+
+
+ 考试说明
+
+ ①、每位学员共有两次考试的机会,考试成绩以两次成绩的最高分作为最终的卷面成绩,请认真对待每次考试;
+ ②、请在倒计时结束前完成答题,倒计时结束后将自动交卷。
+
+
+
+
+
+
+ 试卷列表
+
+
+
+
+
+
+ 未参加考试
+
+
+
+
+
+
+ {{index1 == 0 ? '一' : '二'}}次考试成绩
+
+
+ {{item1.score}} 分
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -373,6 +450,8 @@
active: false
},
],
+timeDif:{},
+showCountDown:false,
thisClass: {},
students: [],
@@ -481,7 +560,11 @@
},
roleCode: [],
firstLoad: true, // 是否是第一次请求
- blankNumber: 0
+ blankNumber: 0,
+ paperList: [],
+ paperSore: 0, // 最终的笔试成绩
+ showTestTips: false,
+ showPaperList:false,
}
},
onLoad(e) {
@@ -515,10 +598,32 @@
this.getList()
uni.stopPullDownRefresh()
},
- onShow() {
- this.getClassInfo()
+ async onShow() {
+ var ss = await this.getClassInfo()
this.getScore()
-
+ console.log('this.thisClass.state', this.thisClass.state);
+ console.log('this.$store.state.paperEndTime',this.$store.state);
+ if(this.$store.state.paperEndTime && this.$store.state.paperEndTime.time - Date.now() > 0){
+ var secondTimeDif = this.$store.state.paperEndTime.time - Date.now()
+ this.timeDif.hour = (secondTimeDif % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
+ this.timeDif.minutes = (secondTimeDif % (1000 * 60 * 60)) / (1000 * 60);
+ this.timeDif.second = (secondTimeDif % (1000 * 60)) / 1000
+ this.showCountDown = true
+ console.log('时间符合吗?',this.showCountDown, secondTimeDif);
+ }
+ if (this.thisClass.state == '3') {
+ var ll = await this.getPaperList()
+ console.log('this.paperList.length',this.paperList.length);
+ if (!this.showAlert && this.paperList.length <= 0 ) {
+ uni.showModal({
+ title: '提示',
+ content: '您好,当前教学进度已进入考试周,请尽快完成最终的笔试考试,如在结班(endTime)之前未完成考试,则卷面成绩记为0分',
+ confirmText: '好的',
+ showCancel: false
+ })
+ this.showAlert = true
+ }
+ }
},
computed: {
...mapState(["userInfo"]),
@@ -552,6 +657,7 @@
}
return list
},
+
// 获得提交项目的tab
getTijiaoTitleList() {
var _list = []
@@ -589,6 +695,65 @@
}
},
methods: {
+ goToPaper(id){
+ uni.navigateTo({
+ url: `/pages/miniClass/paperBack?id=${id}`
+ })
+ },
+ timeup(){
+ this.showCountDown = false
+ },
+
+ // 获取试卷列表
+ async getPaperList() {
+ console.log('--------------',parseInt(this.classId),this.userInfo.id);
+ await $http.request({
+ url: "common/classExam/getExamPaperList",
+ method: "POST",
+ data: {
+ "classId": parseInt(this.classId),
+ "userId": this.userInfo.id
+ },
+ header: { //默认 无 说明:请求头
+ 'Content-Type': 'application/json'
+ },
+ })
+ .then((res) => {
+ if (res.code == 0) {
+ console.log('获取试卷列表', res);
+ this.paperList = res.examPaper
+ if (this.paperList.length > 0) {
+ var _list = [...this.paperList]
+ _list = _list.map(item => {
+ return item.score
+ })
+ var maxNmber = 0
+ for (var i = 0; i < _list.length; i++) {
+ if (_list[i] > maxNmber) {
+ maxNmber = _list[i]
+ }
+ }
+ this.paperSore = maxNmber
+ } else {
+ this.paperSore = 0
+ }
+ } else {
+ this.paperSore = 0
+ uni.showToast({
+ title: errMsg,
+ icon: 'none'
+ })
+ }
+
+ }).catch(e => {
+ this.paperSore = 0
+ console.log('获取试卷列表失败', e);
+ uni.showToast({
+ title: '获取试卷列表失败',
+ icon: 'none'
+ })
+ });
+ },
// 查询考试成绩
getPaperScore() {
console.log('获取卷面成绩');
@@ -761,6 +926,7 @@
}
})
},
+
getList() {
console.log('进入函数了吗');
this.status = 1;
@@ -943,6 +1109,8 @@
},
closeManager() {
this.showMan = false
+ this.showTestTips = false
+ this.showPaperList = false
},
fabClick() {
// uni.showToast({
@@ -1088,7 +1256,7 @@
uni.showLoading({
title: '正在加载'
})
- $http.request({
+ await $http.request({
url: "common/class/getClassInfo",
method: "POST", // POST、GET、PUT、DELETE,具体说明查看官方文档
data: {
@@ -1103,16 +1271,7 @@
if (res.code == 0) {
res = classData // 测试数据
this.isHave = res.result.isJoin
- this.thisClass = res.result.class
- if (!this.showAlert && this.thisClass.state == '3') {
- uni.showModal({
- title: '提示',
- content: '您好,当前教学进度已进入考试周,请尽快完成最终的笔试考试,如在结班(endTime)之前未完成考试,则卷面成绩记为0分',
- confirmText: '好的',
- showCancel: false
- })
- this.showAlert = true
- }
+ this.thisClass = res.result.class
if (this.thisClass.state == '0') {
this.tabId = '0'
} else {
@@ -1288,6 +1447,15 @@
}
}
+ .testBox {
+ .mainTxt{color: #55aa00 !important;}
+ .scoreTitle {
+ .titles {
+ background-color: #55aa00;
+ }
+ }
+ }
+
.pingfenBox {
border: 2px dotted #bed4ee;
padding: 20rpx;
@@ -1321,6 +1489,11 @@
}
}
+ .testBox {
+ border-color: #aee5b5;
+ margin-bottom: 20rpx;
+ }
+
.zhengshu {
color: #ffaa7f;
border: 1px solid #ffaa7f
@@ -1346,7 +1519,29 @@
.scoreNumber {
font-size: 60rpx;
}
+
+.upopBox {
+ padding: 40rpx;
+ max-height: 80vh;
+ overflow-y: scroll;
+ color: #666;
+ .item {
+ padding: 10rpx 0;
+ border-bottom: 1px solid #eee;
+ }
+ }
+ .scoreBox{
+ align-items: center;
+ border: none !important;
+ margin-top: 20rpx;
+ text-align: center; background-color: #fff; padding: 10rpx 20rpx;
+ .ciyao{color: #999; margin-bottom: 20rpx;}
+ .score{color: #258feb; font-weight: bold; font-size: 36rpx;}
+ .seePaper{width: 50rpx; height: 50rpx;
+ image{width: 100%; height: 100%;}
+ }
+ }
.chengji {
padding-top: 20rpx;
margin-top: 20rpx;
@@ -1461,6 +1656,7 @@
color: #ff9277;
text-align: center;
}
+
.leve3.cantAnswer {
color: #999;
text-align: center;
@@ -1537,9 +1733,7 @@
}
.gotoExams {
- margin: 20rpx 0;
- margin-top: -10rpx;
-
+ margin: 60rpx 0;
text {
display: block;
text-align: center;
@@ -1552,15 +1746,17 @@
}
}
- .scoreBox { border-top: 1px solid #eee; padding-top: 10rpx;
- justify-content: space-around;
+ .scoreBox {
+ border-top: 1px solid #eee;
+ padding-top: 10rpx;
+ justify-content: space-around;
align-items: center;
margin-top: 20rpx;
text-align: center;
background-color: #fff;
-
+
font-size: 26rpx;
-
+
.ciyao {
color: #999;
}
@@ -1570,7 +1766,7 @@
font-weight: bold;
font-size: 36rpx;
}
-
+
}
.classMateBox {
@@ -1826,8 +2022,10 @@
}
}
+ .optionsBox {}
+
.retake {
- border: 1px solid #5049cf;
- color: #5049cf;
+ border: 1px solid #55aa00;
+ color: #55aa7f;
}
\ No newline at end of file
diff --git a/pages/miniClass/classInfoMan.vue b/pages/miniClass/classInfoMan.vue
index 00e5075..84a04a5 100644
--- a/pages/miniClass/classInfoMan.vue
+++ b/pages/miniClass/classInfoMan.vue
@@ -258,7 +258,6 @@
-
创建日期
{{thisClass.createTime.substring(0,10)}}
diff --git a/pages/miniClass/paperBack.vue b/pages/miniClass/paperBack.vue
index 350cd3a..81d31b9 100644
--- a/pages/miniClass/paperBack.vue
+++ b/pages/miniClass/paperBack.vue
@@ -1,7 +1,7 @@
-
+
考试说明
@@ -9,58 +9,59 @@
- 本次考试卷面成绩为:90分
+ {{testPaper.score}}分
-
-
-
-
-
+
+
+ 总题数
+ {{questionList.length}}
+
+
+ 已答
+ {{questionList.length - haveNoAnswerNumber}}
+
+
+ 未答
+ {{haveNoAnswerNumber}}
+
+
+ 正确率
+ {{rightNumber / questionList.length * 100}} %
+
-
-
-
-
- {{curIndex1+1}}
- / {{testPaper.length}}
-
-
-
- 剩余时间:
-
-
-
-
-
-
-
-
{{curQuestion.type == 0 ? '单选题' : '多选题'}}
+
+ {{curIndex1+1}}
+ / {{questionList.length}}
+
{{curQuestion.content}}
-
-
-
- {{item.content}}
+
+
+
+
+ {{item.content}}
+ {{item.rightWrong == 1 ? '正确':'错误'}}
+
+
@@ -72,25 +73,9 @@
+ :disabled="curIndex1 == questionList.length-1" size="mini">下一题
-
-
-
-
-
-
-
- 题目索引
-
-
-
- {{index}}
-
-
@@ -100,8 +85,8 @@
考试说明
①、每位学员共有两次考试的机会,考试成绩以两次成绩的最高分作为最终的卷面成绩,请认真对待每次考试;
- ②、请在倒计时结束前完成答题,倒计时结束后将自动交卷;
- ③、考试结束前中途离开视为放弃此次考试,成绩为0分。
+ ②、请在倒计时结束前完成答题,倒计时结束后将自动交卷。
+
@@ -119,93 +104,50 @@
return {
showPopup: false,
code: 0, // 英文code
- classId: undefined,
+ exameId: undefined,
testPaper: [],
curQuestion: {
answerIds: []
},
+ questionList: [], // 试题列表
result: {}, // 考试结果
curIndex1: 0,
- paperCreateTime: 0,
- examId: undefined,
- endTime: undefined, // 结束时间戳
- isOvertime: false, // 是否超时
- step: 8, /// 步长
- // questIndexList: [],
- nowPart: 1,
-
- maxNumber: 0,
- minNumber: 0,
- noAnswerList: [],
- haveAnswerList:[]
+ answerIdsList: [],
+ haveNoAnswerNumber: 0, // 未作答数量
+ rightNumber: 0 // 答题正确个数
}
},
async onLoad(e) {
- console.log('收到得值');
- this.classId = e.classId
-
- if (this.testPaper.length == 0) {
- this.getTestPage()
- }
- // this.questIndexList = await this.getNowList('add')
- },
- onHide() {
- if (!this.isOvertime) {}
- },
- onShow() {
- this.endTime = this.hourUp(1)
- console.log('this.endTime', this.endTime.getTime());
- },
- beforeDestroy() {
- if (!this.isOvertime) { // 如果中途退出
- this.giveZero()
- }
-
+ console.log('收到得值', e);
+ this.exameId = e.id
+ this.getTestPage()
},
+ onHide() {},
+ onShow() {},
computed: {
...mapState(["userInfo"]),
- getallLIst() {
- const numbers = Array.from(Array(100).keys(), n => n + 1);
- console.log('numbers', numbers);
- return numbers
- }
-
+ // getallLIst() {
+ // const numbers = Array.from(Array(100).keys(), n => n + 1);
+ // console.log('numbers', numbers);
+ // return numbers
+ // }
},
methods: {
- // 单个题的提交
- saveQuestAnswer(paperId,questIndex,ids){
- console.log('收到的值',paperId,questIndex,ids);
- $http.request({
- url: "common/classExam/submitOption",
- method: "POST",
- data: {
- "id": paperId, //试卷id
- "no": questIndex, // 提索引 1....
- "answer": ids // 答案id
- },
- header: { //默认 无 说明:请求头
- 'Content-Type': 'application/json'
- },
- })
- .then(res => {
-
- if (res.code == 0) {
- console.log('提交成功');
- }else{
- uni.showToast({
- title: e.errMsg,
- icon: 'error'
- })
- }
-
- }).catch(e => {
- console.log(e, '数据报错')
- uni.showToast({
- title: e.errMsg,
- icon: 'error'
- })
- });
- },
+checkAnswer(id){
+ var _list = [...this.answerIdsList]
+ var _list1 = []
+ _list = _list.map( item => {
+ return item.split(',')
+ })
+ for (var i = 0; i < _list.length; i++) {
+ for (var j = 0; j < _list[i].length; j++) {
+ if(id == _list[i][j]){
+ return true
+ }
+ }
+ }
+ return false
+},
getNoAnswerList() {
var list = []
if (this.curIndex1 > 0) {
@@ -229,79 +171,20 @@
}
}
return list
- },
- // 倒计时结束 (超时)
- timeup() {
- this.isOvertime = true
- this.sumitAnswer()
- let that = this
- uni.showModal({
- title: '提示',
- content: "考试结束,系统已为您自动交卷",
- confirmText: '知道了',
- showCancel: false,
- success: (res) => {
- if (res.confirm) {
- // that.goToClass()
- }
- }
- })
},
+
// 获取交卷数据
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()
},
- // q请求提交试卷
- sumbitPaper(ids) {
- $http.request({
- url: "common/classExam/submitExamPaper",
- method: "POST",
- data: {
- id: this.examId
- },
- header: { //默认 无 说明:请求头
- 'Content-Type': 'application/json'
- },
- })
- .then(res => {
- uni.hideLoading()
- if (res.code == 0) {
- uni.showToast({
- title: '交卷成功',
- icon: 'success'
- })
- this.isOvertime = true
- }
-
- }).catch(e => {
- uni.hideLoading()
- console.log(e, '数据报错')
- // this.status = 3
- uni.showToast({
- title: e.errorMsg,
- icon: 'error'
- })
- });
- },
showPrevQuestion() {
// 上一题
this.curIndex1--
// this.curQuestion.answerIds = []
this.curQuestion = {
- ...this.testPaper[this.curIndex1]
+ ...this.questionList[this.curIndex1]
}
- console.log('----------------', this.testPaper );
+ // console.log('----------------', this.testPaper );
// this.haveAnswerList = this.gethaveAnswerList()
},
showNextQuestion() {
@@ -309,38 +192,9 @@
this.curIndex1++
// this.curQuestion.answerIds = []
this.curQuestion = {
- ...this.testPaper[this.curIndex1]
+ ...this.questionList[this.curIndex1]
}
- console.log('+++++++++++++++', this.testPaper, );
- this.haveAnswerList = this.gethaveAnswerList()
- },
- clickOption(item, index) {
- console.log('item', item, index, this.curIndex1);
- if (this.curQuestion.type == 0) {
- this.testPaper[this.curIndex1].answerIds = [item.id]
- this.curQuestion.answerIds = [item.id]
- // console.log('666666666', this.testPaper, this.curQuestion.answerIds);
- this.$forceUpdate()
- } else if (this.curQuestion.type == 1) {
- console.log('多选');
- var isIN = this.curQuestion.answerIds.findIndex(itemss => {
- return itemss == item.id
- })
- if (isIN >= 0) {
- console.log('有重复的,删除对应的', isIN);
- this.testPaper[this.curIndex1].answerIds.splice(isIN, 1)
- this.curQuestion.answerIds.splice(isIN, 1)
- } else {
- this.testPaper[this.curIndex1].answerIds.push(item.id)
- this.curQuestion.answerIds = [...this.testPaper[this.curIndex1].answerIds]
- }
- }
- this.noAnswerList = this.getNoAnswerList()
- this.haveAnswerList = this.gethaveAnswerList()
- console.log('this.testPaper.',this.testPaper.id);
- this.saveQuestAnswer(this.examId,this.curIndex1+1,this.curQuestion.answerIds.join(','))
- console.log('noAnswerList', this.noAnswerList)
},
setDesc() {
const letterArr = []
@@ -352,13 +206,13 @@
},
getTestPage() {
uni.showLoading({
- title: '正在生成试卷'
+ title: '正在展开试卷'
})
$http.request({
- url: "common/classExam/generateExamPaper",
+ url: "common/classExam/getExamPaperInfo",
method: "POST",
data: {
- "classId": this.classId
+ "id": this.exameId
},
header: { //默认 无 说明:请求头
'Content-Type': 'application/json'
@@ -367,9 +221,11 @@
.then(res => {
uni.hideLoading()
if (res.code == 0) {
- // that.isHave = true
- res.examPaper.forEach(item => {
- item.answerIds = []
+ // that.isHave = true
+ var subOptions = JSON.parse(res.examPaper.subject)
+
+
+ subOptions.forEach(item => {
var code = 0
item.options.forEach(item1 => {
const randomAbc = this.setDesc().splice(65)
@@ -377,22 +233,38 @@
code++
})
})
+
+ this.questionList = subOptions
this.testPaper = res.examPaper
- this.examId = res.id
- this.paperCreateTime = 1
- this.endTime = this.hourUp(1)
- console.log('this.endTime', this.endTime);
- this.curQuestion = {
- ...this.testPaper[this.curIndex1]
- }
- uni.showToast({
- title: '获取成功',
- icon: 'success'
+ this.answerIdsList = JSON.parse(res.examPaper.answer)
+ var newList = JSON.parse(res.examPaper.answer)
+ newList = newList.map(item => {
+ // console.log('item.substring(0,item.length - 2)',item.substring(0,item.length - 2));
+ return item.substr(item.length - 1)
})
- console.log(res, '试卷', this.curQuestion)
- // setTimeout(() => {
- // this.getClassInfo()
- // }, 500)
+ this.rightNumber = 0
+ newList.forEach(item => {
+ if (item == '1') {
+ this.rightNumber += 1
+ }
+ })
+ console.log('newList', newList);
+ this.answerIdsList = this.answerIdsList.map(item => {
+ // console.log('item.substring(0,item.length - 2)',item.substring(0,item.length - 2));
+ return item.substring(0, item.length - 2)
+ })
+ this.haveNoAnswerNumber = 0
+ this.answerIdsList.forEach(item => {
+ if (item == '') {
+ this.haveNoAnswerNumber += 1
+ }
+ })
+ // this.examId = res.id
+ this.curQuestion = {
+ ...this.questionList[this.curIndex1]
+ }
+ console.log('subOptions', subOptions, 'answerIdsList', this.answerIdsList);
+ // console.log(questionList, '试卷', this.curQuestion)
} else {
uni.showToast({
title: res.errMsg,
@@ -412,15 +284,7 @@
})
});
},
- giveZero() {
- // 没有完成完成考试,记为0分
- },
- showElart() {
- // uni.showModal({
- // title:'提示',
- // content:"您还没有完成考试,确定要离开吗?离开后成绩会记为0分,是否继续?"
- // })
- },
+
goToClass() {
uni.navigateTo({
url: `/pages/miniClass/classInfo?id=${this.classId}`
@@ -430,21 +294,12 @@
this.showPopup = false
},
clickIndex(val) {
-
this.curIndex1 = val - 1
console.log('val', val, this.curIndex1, this.testPaper.length);
this.curQuestion = this.testPaper[this.curIndex1]
this.noAnswerList = this.getNoAnswerList()
this.haveAnswerList = this.gethaveAnswerList()
},
- hourUp(e) {
- // 比现在多几个小时
- var end = Date.now()
- var start = 1000 * 60 * 60 * e
- var interval = end + start; //结束 - 开始 = 毫秒值
- var a = new Date(interval)
- return a
- },
}
}
@@ -452,14 +307,26 @@