From d14d4c675226e7399fe0111bfb6580f7ce2d3bf0 Mon Sep 17 00:00:00 2001 From: unissww Date: Thu, 1 Jun 2023 11:08:31 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E8=80=83=E8=AF=95?= =?UTF-8?q?=E8=BF=87=E7=A8=8B=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/allPreview/index.js | 62 ++---- component/allPreview/index.wxml | 3 + component/questionType/CheckQuestion/index.js | 39 +--- component/questionType/RadioQuestion/index.js | 28 +-- .../questionType/RigOrWroQuestion/index.js | 21 +- .../questionType/ShortAnswerQuestion/index.js | 46 +++-- .../ShortAnswerQuestion/index.wxml | 6 +- component/questionType/index.js | 148 +++++++++----- component/questionType/index.wxml | 5 +- component/questionType/pageConta/index.js | 6 - pages/exam/do/index.js | 119 +++++++----- pages/exam/do/index.txt | 183 ------------------ pages/exam/do/index2.txt | 9 - pages/exam/do/index3.txt | 83 -------- pages/exam/do/index4.txt | 69 ------- 15 files changed, 251 insertions(+), 576 deletions(-) delete mode 100644 pages/exam/do/index.txt delete mode 100644 pages/exam/do/index2.txt delete mode 100644 pages/exam/do/index3.txt delete mode 100644 pages/exam/do/index4.txt diff --git a/component/allPreview/index.js b/component/allPreview/index.js index 1bedc7f..453e585 100644 --- a/component/allPreview/index.js +++ b/component/allPreview/index.js @@ -6,7 +6,6 @@ Page({ * 页面的初始数据 */ data: { - id:12345678, questionAll:{}, allAnswer:[], answerSheet:{ //答题卡 @@ -30,46 +29,40 @@ Page({ this.data.allAnswer.forEach((el,index)=>{ if(el.index == e.detail.index){ let xx = "allAnswer["+index+"].answer" - this.setData({ - [xx] : e.detail.answer - }) + this.setData({ [xx] : e.detail.answer }) } }) }, hanPaper(){ console.log(app.globalData.studentId,app.globalData.paperId,this.data.allAnswer); + console.log(app.globalData.studentId); app.formPost('/testAnswer/add',{ stu_test_id:app.globalData.studentId, paper_id:app.globalData.paperId, linkAnswerVos:this.data.allAnswer - }).then(res=>{ - console.log(res); }) - }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - + wx.request({ + url: 'http://localhost:8090/testStatus/updateSubmitPaperTime', + data:{ + stu_id:app.globalData.studentId, + } + }) + wx.request({ + url: 'http://localhost:8090/testStatus/updateHandPaper', + data:{ + stu_id:app.globalData.studentId, + } + }) + wx.redirectTo({ + url:`/component/handPaper/index` + }) }, - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - /** - * 生命周期函数--监听页面隐藏 - */ onHide() { console.log("我隐藏了"); }, - /** - * 生命周期函数--监听页面卸载 - */ onUnload() { var that = this; var pages = getCurrentPages(); @@ -78,25 +71,4 @@ Page({ Ansswer:that.data.allAnswer }) }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } }) \ No newline at end of file diff --git a/component/allPreview/index.wxml b/component/allPreview/index.wxml index 3fdf755..f4b8763 100644 --- a/component/allPreview/index.wxml +++ b/component/allPreview/index.wxml @@ -31,6 +31,9 @@ diff --git a/component/questionType/CheckQuestion/index.js b/component/questionType/CheckQuestion/index.js index a44a177..e4266a0 100644 --- a/component/questionType/CheckQuestion/index.js +++ b/component/questionType/CheckQuestion/index.js @@ -24,9 +24,9 @@ Component({ IsChecked(e){ const xx = e.target.dataset.test; const found = this.data._num.find(el=>el==e.target.dataset.test); - if(!found){ - this.setData({ _num:this.data._num.concat(xx) }) - }else{ + + if(!found) this.setData({ _num:this.data._num.concat(xx) }) + else{ const filterxx = this.data._num.filter(el=>el!=e.target.dataset.test); this.setData({ _num:filterxx }) } @@ -38,11 +38,9 @@ Component({ } let xxx = this.properties.allAnswer.find( el => el.index == this.properties.questionIndex ); - if(xxx){ - this.triggerEvent("changeAnswer",Answer); - }else{ - this.triggerEvent("insertAnswer",Answer); - } + + if(xxx) this.triggerEvent("changeAnswer",Answer); + else this.triggerEvent("insertAnswer",Answer); }, trxxxon(){ @@ -52,37 +50,14 @@ Component({ ],200) }, }, - //生命周期钩子 lifetimes: { - //在组件实例进入页面节点树时执行 attached: function() { this.trxxxon(); this.properties.allAnswer.forEach(el=>{ if(el.index == this.properties.questionIndex){ - this.setData({ - _num:el.answer - }) + if(el.index == this.properties.questionIndex) this.setData({ _num:el.answer }) } }) }, - // 在组件实例被从页面节点树移除时执行 - detached: function() { - // let flagxx = true; - - // const Answer = { - // index:this.properties.questionIndex, - // answer:this.data._num - // } - - // this.properties.checkAnswer.forEach(el =>{ - // if(el.index == this.properties.questionIndex){ - // this.triggerEvent("changeCheckAnswer",Answer); - // flagxx = false - // } - // }) - // if(flagxx){ - // this.triggerEvent("insertCheckAnswer",Answer); - // } - }, }, }) diff --git a/component/questionType/RadioQuestion/index.js b/component/questionType/RadioQuestion/index.js index 01cb596..8799c0a 100644 --- a/component/questionType/RadioQuestion/index.js +++ b/component/questionType/RadioQuestion/index.js @@ -16,22 +16,18 @@ Component({ IsChecked(e){ let arr = []; arr[0] = e.target.dataset.test; - this.setData({ - _num:arr - }); - console.log("看看你到底是什么",this.data._num); + this.setData({ _num:arr }); + const Answer = { index:this.properties.questionIndex, question_id:this.properties.question.questionId, answer:this.data._num } - let xx = this.properties.allAnswer.find( el => el.index == this.properties.questionIndex ); - if(xx){ - this.triggerEvent("changeAnswer",Answer); - }else{ - this.triggerEvent("insertAnswer",Answer); - } + + if(xx) this.triggerEvent("changeAnswer",Answer); + else this.triggerEvent("insertAnswer",Answer); + }, trxxxon(){ @@ -41,19 +37,13 @@ Component({ ],200) }, }, - //生命周期钩子 + lifetimes: { attached: function() { this.trxxxon(); this.properties.allAnswer.forEach(el=>{ - if(el.index == this.properties.questionIndex){ - this.setData({ - _num:el.answer - }) - } + if(el.index == this.properties.questionIndex) this.setData({ _num:el.answer }) }) - }, - detached: function() { - }, + } }, }) diff --git a/component/questionType/RigOrWroQuestion/index.js b/component/questionType/RigOrWroQuestion/index.js index 7709974..06d0f30 100644 --- a/component/questionType/RigOrWroQuestion/index.js +++ b/component/questionType/RigOrWroQuestion/index.js @@ -20,9 +20,8 @@ Component({ IsChecked(e){ let arr = []; arr[0] = e.target.dataset.test; - this.setData({ - _num:arr - }); + this.setData({ _num:arr }); + const Answer = { index:this.properties.questionIndex, question_id:this.properties.question.questionId, @@ -30,11 +29,9 @@ Component({ } let xxx = this.properties.allAnswer.find( el => el.index == this.properties.questionIndex ); - if(xxx){ - this.triggerEvent("changeAnswer",Answer); - }else{ - this.triggerEvent("insertAnswer",Answer); - } + + if(xxx) this.triggerEvent("changeAnswer",Answer); + else this.triggerEvent("insertAnswer",Answer); }, trxxxon(){ this.animate('.containerxx',[ @@ -43,20 +40,14 @@ Component({ ],200) }, }, - //生命周期钩子 lifetimes: { - //在组件实例进入页面节点树时执行 attached: function() { this.trxxxon(); this.properties.allAnswer.forEach(el=>{ if(el.index == this.properties.questionIndex){ - this.setData({ _num:el.answer }) + if(el.index == this.properties.questionIndex) this.setData({ _num:el.answer }) } }) }, - // 在组件实例被从页面节点树移除时执行 - detached: function() { - - }, }, }) diff --git a/component/questionType/ShortAnswerQuestion/index.js b/component/questionType/ShortAnswerQuestion/index.js index d0a8a63..8f47e4a 100644 --- a/component/questionType/ShortAnswerQuestion/index.js +++ b/component/questionType/ShortAnswerQuestion/index.js @@ -6,7 +6,7 @@ Component({ */ properties: { question:{ }, - radioAnswer:{ + allAnswer:{ type:Array, value:[] }, @@ -17,17 +17,30 @@ Component({ * 组件的初始数据 */ data: { - _num:null + input:'', + _num:[], + originalInput:'', //第一次加载时保存input值 组件卸载时判断input值是否更改保存 }, - /** - * 组件的方法列表 - */ methods: { IsChecked(e){ - this.setData({ - _num:e.target.dataset.test + let arr = []; + arr[0] = this.data.input; + this.setData({ + _num:arr, + originalInput:arr[0] }); + + const Answer = { + index:this.properties.questionIndex, + question_id:this.properties.question.questionId, + answer:this.data._num + } + let xx = this.properties.allAnswer.find( el => el.index == this.properties.questionIndex ); + + if(xx) this.triggerEvent("changeAnswer",Answer); + else this.triggerEvent("insertAnswer",Answer); + }, trxxxon(){ this.animate('.containerxx',[ @@ -35,19 +48,24 @@ Component({ { opacity: 1, }, ],200) }, + inputnull(){}, + isUpdateInput(e){ + if(this.data.originalInput != this.data.input) return true + return false; + } }, //生命周期钩子 lifetimes: { - //在组件实例进入页面节点树时执行 attached: function() { this.trxxxon(); - this.setData({ - _num:"A" + this.properties.allAnswer.forEach(el=>{ + if(el.index == this.properties.questionIndex){ + this.setData({ + input:el.answer, + originalInput:el.answer + }) + } }) }, - // 在组件实例被从页面节点树移除时执行 - detached: function() { - console.log(this.data._num); - }, }, }) diff --git a/component/questionType/ShortAnswerQuestion/index.wxml b/component/questionType/ShortAnswerQuestion/index.wxml index eb826fc..42bbd73 100644 --- a/component/questionType/ShortAnswerQuestion/index.wxml +++ b/component/questionType/ShortAnswerQuestion/index.wxml @@ -11,9 +11,11 @@ + diff --git a/component/questionType/index.js b/component/questionType/index.js index 3b96c0a..a523d5e 100644 --- a/component/questionType/index.js +++ b/component/questionType/index.js @@ -11,21 +11,14 @@ Page({ //答题卡 answerSheet:{}, - //个类型问题个数 - questionTypeNumber:{}, - relativeIndex:{ - checkIndex:0, - rigorwroIndex:0, - shortanswerIndex:0 - }, - allAnswer:[], Type:[], show:false, //答题卡 questionAll:[], //全部题目 - + + }, onShow:function(){ wx.hideHomeButton(); @@ -51,24 +44,28 @@ Page({ //预览页传回的答案添加与修改 PreviewChangeAnswer(e){ - let flag = false; - e.forEach(ele=>{ - this.data.allAnswer.forEach((el,index)=>{ - if(el.index == ele.index){ - let xx = "allAnswer["+index+"].answer" - this.setData({ - [xx] : ele.answer - }) - flag = true - } - }); - if(!flag){ - this.setData({ - allAnswer:this.data.allAnswer.concat(e) - }) - } + this.setData({ + allAnswer:e }) - console.log(this.data.allAnswer); + // console.log("传进来了的e",e); + // let flagx = false; + // e.forEach(ele=>{ + // this.data.allAnswer.forEach((el,index)=>{ + // if(el.index == ele.index){ + // let xx = "allAnswer["+index+"].answer" + // this.setData({ [xx] : ele.answer }) + // flagx = true + // } + // console.log(el.index,ele.index,flagx); + // }); + // if(!flagx){ + // console.log("我找到不同的了",e); + // this.setData({ + // allAnswer:this.data.allAnswer.concat(e) + // }) + // } + // }) + // console.log("修改过后",this.data.allAnswer); }, //倒计时时间戳 @@ -94,43 +91,81 @@ Page({ //处理数据 handleDate(e){ const data = JSON.parse(decodeURIComponent(e)) - console.log(data); this.setData({ questionAll:data.questionAll, questionTypeNumber:data.questionTypeNumber, answerSheet:data.answerSheet, Type:data.Type, - relativeIndex:{ - checkIndex:data.questionTypeNumber.radioQues+data.questionTypeNumber.rigorwroQues, - rigorwroIndex:data.questionTypeNumber.radioQues, - shortanswerIndex:data.questionTypeNumber.radioQues+data.questionTypeNumber.rigorwroQues.checkQues - }, + allAnswer:data.Answer }) - console.log(this.data.questionAll,this.data.questionTypeNumber,this.data.relativeIndex); - }, + //传入简答题的方法 检测用户是否更改过数据 + isUpdateShortAnswer(){ + let flag = false; + if(this.selectComponent('.shortAnswer')){ + flag = this.selectComponent('.shortAnswer').isUpdateInput(); + } + return flag + }, //上一题 prev(){ - this.setData({ - answerSheet:{ - index:this.data.answerSheet.index-1, - all:this.data.answerSheet.all - }, - - }) + if(this.isUpdateShortAnswer()){ + wx.showModal({ + title: '提示', + content: '您还未保存噢,确定下一题吗', + complete: (res) => { + if (res.cancel) { + } + if (res.confirm) { + this.setData({ + answerSheet:{ + index:this.data.answerSheet.index-1, + all:this.data.answerSheet.all + }, + }) + } + } + }) + }else{ + this.setData({ + answerSheet:{ + index:this.data.answerSheet.index-1, + all:this.data.answerSheet.all + }, + }) + } }, //下一题 next(){ - this.setData({ - answerSheet:{ - index:this.data.answerSheet.index+1, - all:this.data.answerSheet.all - }, - - }) + if(this.isUpdateShortAnswer()){ + wx.showModal({ + title: '提示', + content: '您还未保存噢,确定下一题吗', + complete: (res) => { + if (res.cancel) { + } + if (res.confirm) { + this.setData({ + answerSheet:{ + index:this.data.answerSheet.index+1, + all:this.data.answerSheet.all + }, + }) + } + } + }) + }else{ + this.setData({ + answerSheet:{ + index:this.data.answerSheet.index+1, + all:this.data.answerSheet.all + }, + }) + } }, - + + //选题作答 弹出层 selectQuestion(){ this.setData({ @@ -153,7 +188,6 @@ Page({ }) }, goPageConta(){ - console.log("进来了"); this.setData({ pageAllQuestion:this.data.questionAll }) @@ -177,5 +211,17 @@ Page({ } }) }, - + onHide: function() { + console.log("你切后台了"); + }, + onUnload() { + console.log("我卸载了"); + wx.request({ + url: 'http://localhost:8090/testAnswer/saveAnswer', + data:{ + stu_id:20203779, + paper_id:10 + }, + }) + }, }) \ No newline at end of file diff --git a/component/questionType/index.wxml b/component/questionType/index.wxml index 57e37da..ff6f4f7 100644 --- a/component/questionType/index.wxml +++ b/component/questionType/index.wxml @@ -22,12 +22,10 @@ bind:beforeenter="goPageConta" > @@ -74,8 +72,9 @@ bindchangeAnswer="changeAnswer" allAnswer="{{allAnswer}}" questionIndex="{{index+1}}" + class="shortAnswer" > - + diff --git a/component/questionType/pageConta/index.js b/component/questionType/pageConta/index.js index 351b371..36070ab 100644 --- a/component/questionType/pageConta/index.js +++ b/component/questionType/pageConta/index.js @@ -1,7 +1,6 @@ // component/questionType/pageContainer/index.js Component({ properties: { - questionTypeNumber:{}, questionIndex:1, allAnswer:{ type:Array, @@ -12,11 +11,7 @@ Component({ value:[] }, pageAllQuestion:{}, - relativeIndex:{} - }, - - data: { }, @@ -29,7 +24,6 @@ Component({ //选题 selectQues(e){ this.triggerEvent('selectQuestionIndex',e.target.dataset.text); - console.log(e.target.dataset.text); //撤销弹出层 this.triggerEvent('exit',false); }, diff --git a/pages/exam/do/index.js b/pages/exam/do/index.js index 1b457db..a2e6b9e 100644 --- a/pages/exam/do/index.js +++ b/pages/exam/do/index.js @@ -19,18 +19,16 @@ Page({ all:0 }, studentInfo:{ - student_id:20203778, + student_id:20203779, name:"张三", date:"2023-05-11", cutNum:0 }, countDown:2, + allAnswer:[], + + isHandPaper:null, - answer:{ - index:0, - question_id:0, - answer:'' - }, Type:[], isChecked:false, @@ -50,11 +48,8 @@ Page({ }] }, onTest(){ - if(this.data.countDown > 0){ - this.setData({ - isChecked:!this.data.isChecked - }) - }else{ + if(this.data.countDown > 0) this.setData({ isChecked:!this.data.isChecked }) + else{ this.setData({ isChecked:!this.data.isChecked, isButtonDisabled:!this.data.isChecked @@ -63,18 +58,11 @@ Page({ }, req(){ wx.request({ - // url: 'http://localhost:8090/get/paper', - // data:{ - // id:4 - // }, url: 'http://localhost:8090/testExam/get', data:{ courseId:1, grade:1 }, - succsee:function(res){ - console.log(res.data); - }, complete : (res)=>{ const data = res.data[0]; console.log(data); @@ -106,9 +94,7 @@ Page({ if(el.type == 2) TypeNumber.checkQues=el.questionItems.length; if(el.type == 3) TypeNumber.shortanswerQues=el.questionItems.length; if(el.type == 4) TypeNumber.rigorwroQues=el.questionItems.length; - el.questionItems.forEach(ele=>{ - arr.push(ele) - }) + el.questionItems.forEach(ele=>{ arr.push(ele) }) }) this.setData({ @@ -127,29 +113,29 @@ Page({ wx.request({ url: 'http://localhost:8090/testStatus/add', data:{ - stu_id:20203778, + stu_id:app.globalData.studentId, name:"张三" }, - succsee:(res)=>{ - console.log("回来了",res); - }, complete:(res)=>{ - if(res.data == app.globalData.studentId){ - this.getAnswer(); - } + if(res.data == app.globalData.studentId) this.getAnswer(); } }) - - const object = { - questionAll:this.data.questionAll, - questionTypeNumber:this.data.questionTypeNumber, - answerSheet:this.data.answerSheet, - Type:this.data.Type, - Answer:this.data.answer - } - wx.redirectTo({ - url:`/component/questionType/index?object=${encodeURIComponent(JSON.stringify(object))}` - }) + let timer = setInterval(()=>{ + if(this.data.allAnswer != 'null'){ + clearInterval(timer) + const object = { + questionAll:this.data.questionAll, + questionTypeNumber:this.data.questionTypeNumber, + answerSheet:this.data.answerSheet, + Type:this.data.Type, + Answer:this.data.allAnswer + } + wx.redirectTo({ + url:`/component/questionType/index?object=${encodeURIComponent(JSON.stringify(object))}` + }) + } + },1000) + }, getAnswer(){ wx.request({ @@ -158,19 +144,62 @@ Page({ paper_id:app.globalData.paperId, stu_id:app.globalData.studentId }, - succsee:(res)=>{ - console.log("回来了",res); - }, complete:res=>{ - this.setData({ - answer:res.data + const arr = [] + res.data.forEach(el=>{ + const answer = { + index:el.index, + question_id:el.question_id, + answer:JSON.parse(el.answer) + } + arr.push(answer) }) - console.log(this.data.answer); + this.setData({ allAnswer:arr }) } }) }, + getTestTime(){ + wx.request({ + url: 'http://localhost:8090/testTime/get', + data:{ + paperId:7 + }, + complete:(res)=>{ + const date = new Date().getTime(); + console.log("返回的时间",res.data,date); + } + }) + }, + TimestampToDate2(Timestamp) { +   let now = new Date(Timestamp), +   y = now.getFullYear(), +   m = now.getMonth() + 1, +   d = now.getDate(); +   return y + "年" + (m < 10 ? "0" + m : m) + "月" + (d < 10 ? "0" + d : d) + "日 " + now.toTimeString().substr(0, 8); + }, + isHandPaper(){ + wx.request({ + url: 'http://localhost:8090/testStatus/selStuHandPaper', + data:{ + stu_id:app.globalData.studentId + }, + complete:res=>{ + this.setData({ isHandPaper:res.data }) + } + }) + }, onShow() { + this.getTestTime(); + this.isHandPaper(); + let timer = setInterval(()=>{ + if(this.data.isHandPaper != 'null' && this.data.isHandPaper == 1){ + clearInterval(timer) + wx.redirectTo({ + url:`/component/handPaper/index` + }) + }else if(this.data.isHandPaper != 'null' && this.data.isHandPaper == 0) clearInterval(timer) + },1000) this.req(); diff --git a/pages/exam/do/index.txt b/pages/exam/do/index.txt deleted file mode 100644 index 666255f..0000000 --- a/pages/exam/do/index.txt +++ /dev/null @@ -1,183 +0,0 @@ -let app = getApp() -Page({ - data:{ - over_time:'2023-05-29 19:00:00', //考试倒计时时间戳 - countdown:{ - bell_h:0, - bell_m:0, - bell_s:0, - }, - - //答题卡 - answerSheet:{}, - - //个类型问题个数 - questionTypeNumber:{}, - relativeIndex:{ - checkIndex:0, - rigorwroIndex:0, - shortanswerIndex:0 - }, - - //为什么不存为一个对象 小程序中 改变对象其中一个值 其他值会被删掉 - // radioAnswer:[], //单选答案 - // checkAnswer:[], //多选答案 - // rigorwroAnswer:[], //判断答案 - // shortanswerAnswer:[], //简答答案 - allAnswer:[], - - show:false, //答题卡 - questionAll:[], //全部题目 - - }, - onShow:function(){ - wx.hideHomeButton(); - this.setCountdown(); - - //整卷预览页面传回的数据 - let pages = getCurrentPages(); - let currPage = pages[pages.length - 1]; //当前页 - console.log("传回来的数据",currPage.data.Ansswer); - - if( currPage.data.Ansswer == undefined){ - console.log("unfined"); - }else if(currPage.data.Ansswer.length == 0){ - console.log("长度为0"); - }else{ - this.PreviewChangeAnswer(currPage.data.Ansswer); - } - - }, - onLoad(e){ - this.handleDate(e.object); - }, - - //预览页传回的答案添加与修改 - PreviewChangeAnswer(e){ - let flag = false; - e.forEach(ele=>{ - this.data.allAnswer.forEach((el,index)=>{ - if(el.index == ele.index){ - let xx = "allAnswer["+index+"].answer" - this.setData({ - [xx] : ele.answer - }) - flag = true - } - }); - if(!flag){ - this.setData({ - allAnswer:this.data.allAnswer.concat(e) - }) - } - }) - console.log(this.data.allAnswer); - }, - - //倒计时时间戳 - setCountdown(){ - const time = new Date(this.data.over_time).getTime(); - setInterval(()=>{ - const date = +new Date(); - let interval = (time-date)/1000; - let hh = Math.floor(interval/60/60%24); - let mm = Math.floor(interval/60%60); - mm = mm>10 ? mm : '0'+mm; - let ss = Math.floor(interval%60); - ss = ss>10 ? ss : '0'+ss; - this.setData({ - countdown:{ - bell_h : hh, - bell_m : mm, - bell_s : ss, - } - }) - },1000) - }, - //处理数据 - handleDate(e){ - const data = JSON.parse(decodeURIComponent(e)) - console.log(data); - this.setData({ - questionAll:data.questionAll, - questionTypeNumber:data.questionTypeNumber, - answerSheet:data.answerSheet, - relativeIndex:{ - checkIndex:data.questionTypeNumber.radioQues+data.questionTypeNumber.rigorwroQues, - rigorwroIndex:data.questionTypeNumber.radioQues, - shortanswerIndex:data.questionTypeNumber.radioQues+data.questionTypeNumber.rigorwroQues.checkQues - }, - }) - console.log(this.data.questionAll,this.data.questionTypeNumber,this.data.relativeIndex); - - }, - - //上一题 - prev(){ - this.setData({ - answerSheet:{ - index:this.data.answerSheet.index-1, - all:this.data.answerSheet.all - }, - - }) - }, - //下一题 - next(){ - this.setData({ - answerSheet:{ - index:this.data.answerSheet.index+1, - all:this.data.answerSheet.all - }, - - }) - }, - - //选题作答 弹出层 - selectQuestion(){ - this.setData({ - show:true - }) - }, - //答题卡中的关闭按钮 - exit(e){ - this.setData({ - show:e.detail - }) - }, - //答题卡中选题 - selectQuestionIndex(e){ - this.setData({ - answerSheet:{ - index:e.detail, - all:this.data.answerSheet.all - } - }) - }, - goPageConta(){ - console.log("进来了"); - this.setData({ - pageAllQuestion:this.data.questionAll - }) - - }, - - //组件添加答案和修改答案 - insertAnswer(e){ - this.setData({ - allAnswer:this.data.allAnswer.concat(e.detail) - }) - }, - - changeAnswer(e){ - this.data.allAnswer.forEach((el,index)=>{ - if(el.index == e.detail.index){ - let xx = "allAnswer["+index+"].answer" - this.setData({ - [xx] : e.detail.answer - }) - } - }) - }, - -}) \ No newline at end of file diff --git a/pages/exam/do/index2.txt b/pages/exam/do/index2.txt deleted file mode 100644 index 1e185fc..0000000 --- a/pages/exam/do/index2.txt +++ /dev/null @@ -1,9 +0,0 @@ -{ - "usingComponents": { - "RadioQuestion":"/component/questionType/RadioQuestion/index", - "CheckQuestion":"/component/questionType/CheckQuestion/index", - "pageConta":"/component/questionType/pageConta/index", - "RigOrWroQuestion":"/component/questionType/RigOrWroQuestion/index", - "ShortAnswerQuestion":"/component/questionType/ShortAnswerQuestion/index" - } -} \ No newline at end of file diff --git a/pages/exam/do/index3.txt b/pages/exam/do/index3.txt deleted file mode 100644 index c4354bd..0000000 --- a/pages/exam/do/index3.txt +++ /dev/null @@ -1,83 +0,0 @@ - - - - - {{countdown.bell_h}} - : - {{countdown.bell_m}} - : - {{countdown.bell_s}} - - - - - 答题卡 - {{answerSheet.index}}/{{answerSheet.all}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/pages/exam/do/index4.txt b/pages/exam/do/index4.txt deleted file mode 100644 index bb42384..0000000 --- a/pages/exam/do/index4.txt +++ /dev/null @@ -1,69 +0,0 @@ -.conta{ - box-sizing: border-box; - display: flex; - flex-direction: column; - height: 100vh; - width: 100vw; - overflow: hidden; - position: fixed; /*设置页面高度100% 页面不可滑动 */ -} -.conta_Head{ - box-sizing: border-box; - width: 100%; - height: 10%; - display: flex; - align-items: center; - border-bottom: 1px solid rgb(177, 176, 176,0.2); - box-shadow: 1px 1px 3px rgb(177, 176, 176,0.2); -} -/* .title_center{ - box-sizing: border-box; - width: 100%; - height: 78%; - display: flex; - flex-direction: column; - white-space: nowrap; -} */ -.title_center{ - width: 100vh; - height: 78%; - white-space: nowrap; - display: flex; - flex-direction: row; - -} -.conta_foot{ - box-sizing: border-box; - width: 100%; - height: 8%; - display: flex; - border-top: 1px solid rgb(177, 176, 176,0.2); - border-bottom: 1px solid rgb(177, 176, 176,0.1); - justify-content: space-between; - align-items: center; - box-shadow: 1px -1px 3px rgb(177, 176, 176,0.2); -} -.conta_foot button{ - width: 200rpx; -} - -.selectQuestion{ - background: rgb(46, 134, 222,0.5); - border:solid rgb(46, 134, 222) 2px; - border-radius: 10px; - width: 16%; - height: 50%; - font-size: 16px; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - margin-left: 27%; -} -.divLine{ - background: #d4d4d4; - width: 100%; - height: 1rpx; - - } - -- Gitee From e770bf47b7e9aa37635c31d4ccdef162a134208c Mon Sep 17 00:00:00 2001 From: unissww Date: Thu, 1 Jun 2023 11:12:21 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E6=8F=90=E4=BA=A4=E5=AE=8C=E6=AF=95=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/handPaper/index.js | 36 ++++++++++++++++++++++++++++++++++ component/handPaper/index.json | 4 ++++ component/handPaper/index.wxml | 9 +++++++++ component/handPaper/index.wxss | 23 ++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 component/handPaper/index.js create mode 100644 component/handPaper/index.json create mode 100644 component/handPaper/index.wxml create mode 100644 component/handPaper/index.wxss diff --git a/component/handPaper/index.js b/component/handPaper/index.js new file mode 100644 index 0000000..bddc2e6 --- /dev/null +++ b/component/handPaper/index.js @@ -0,0 +1,36 @@ +// component/TTTest/index.js +const app = getApp(); +Page({ + data: { + name:'张三', + getPaperTime:'2023年05月29日17:00', + sumbitPaperTime:'2023年05月29日17:20', + }, + getData(){ + wx.request({ + url: 'http://localhost:8090/testStatus/selSubmitPaperTime', + data:{ + stu_id:app.globalData.studentId, + }, + complete:(res)=>{ + const getData = this.TimestampToDate2(res.data.getData); + const submitData = this.TimestampToDate2(res.data.submitData) + this.setData({ + name:res.data.name, + getPaperTime:getData, + sumbitPaperTime:submitData + }) + } + }) + }, + TimestampToDate2(Timestamp) { +   let now = new Date(Timestamp), +   y = now.getFullYear(), +   m = now.getMonth() + 1, +   d = now.getDate(); +   return y + "年" + (m < 10 ? "0" + m : m) + "月" + (d < 10 ? "0" + d : d) + "日 " + now.toTimeString().substr(0, 8); + }, + onShow(){ + this.getData(); + } +}) diff --git a/component/handPaper/index.json b/component/handPaper/index.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/component/handPaper/index.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/component/handPaper/index.wxml b/component/handPaper/index.wxml new file mode 100644 index 0000000..09a4cf8 --- /dev/null +++ b/component/handPaper/index.wxml @@ -0,0 +1,9 @@ + + 您已交卷 + + + 姓名:{{name}} + 领取时间:{{getPaperTime}} + 提交时间:{{sumbitPaperTime}} + + diff --git a/component/handPaper/index.wxss b/component/handPaper/index.wxss new file mode 100644 index 0000000..16cbab3 --- /dev/null +++ b/component/handPaper/index.wxss @@ -0,0 +1,23 @@ +/* component/TTTest/index.wxss */ +.containerx{ + width: 100vw; + height: 100vh; + display: flex; + + align-items: center; + box-sizing: border-box; + flex-direction: column; + position: fixed; + background: #ecf0f1; +} +.warnConta{ + width: 80%; + height: 20%; + border-radius:10px ; + background: #dadedf; + color: #2d3436; + display: flex; + flex-direction: column; + justify-content: center; + margin-top: 20rpx; +} \ No newline at end of file -- Gitee From e54b15bdec2c99393c8d39c875000bfab91f3340 Mon Sep 17 00:00:00 2001 From: unissww Date: Thu, 1 Jun 2023 18:34:18 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B7=B2=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 7 +- app.json | 3 +- assets/myNewIcon/bell.png | Bin 0 -> 4311 bytes component/allPreview/index.js | 86 ++++++++--- component/allPreview/index.wxml | 12 +- component/allPreview/index.wxss | 2 +- component/handPaper/index.js | 16 +- .../questionType/CheckQuestion/index.wxss | 4 +- .../questionType/RadioQuestion/index.wxss | 6 +- .../questionType/RigOrWroQuestion/index.wxss | 2 + .../ShortAnswerQuestion/index.wxml | 3 +- .../ShortAnswerQuestion/index.wxss | 3 + component/questionType/index.js | 144 ++++++++++-------- component/questionType/index.wxml | 10 +- component/questionType/index.wxss | 15 +- component/questionType/pageConta/index.js | 8 +- pages/exam/do/index.js | 123 +++++++++------ pages/exam/do/index.wxml | 5 +- pages/exam/do/index.wxss | 39 +++++ project.config.json | 2 +- project.private.config.json | 3 +- 21 files changed, 332 insertions(+), 161 deletions(-) create mode 100644 assets/myNewIcon/bell.png diff --git a/app.js b/app.js index c1f0a6e..d212abd 100644 --- a/app.js +++ b/app.js @@ -16,10 +16,11 @@ App({ //全局变量 globalData: { - baseAPI: "http://localhost:8090", + baseAPI: "http://192.168.3.122:8090", pageSize: 20, - studentId:20203778, //学生id - paperId:0 //试卷id + studentId:20205567, //学生id + paperId:0 , //试卷id + wxUrl:"http://192.168.3.122:8090" }, formPost: function(url, data) { let _this = this diff --git a/app.json b/app.json index 15e593b..72f4119 100644 --- a/app.json +++ b/app.json @@ -13,7 +13,8 @@ "pages/my/message/list/index", "pages/exam/edit/index", "pages/record/index", - "pages/Login/login" + "pages/Login/login", + "component/handPaper/index" ], "window": { "navigationBarBackgroundColor": "#ffffff", diff --git a/assets/myNewIcon/bell.png b/assets/myNewIcon/bell.png new file mode 100644 index 0000000000000000000000000000000000000000..bfa20b75ab310b304b25a54c32516ecf1bf58831 GIT binary patch literal 4311 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 + const date = +new Date(); + let interval = (time-date)/1000; + let hh = Math.floor(interval/60/60%24); + let mm = Math.floor(interval/60%60); + mm = mm>=10 ? mm : '0'+mm; + let ss = Math.floor(interval%60); + ss = ss>=10 ? ss : '0'+ss; + this.setData({ + countdown:{ + bell_h : hh, + bell_m : mm, + bell_s : ss, + } + }) + if(mm == 0 && ss == 0 && hh ==0) this.hanPaper() + },1000) + }, changeAnswer(e){ this.data.allAnswer.forEach((el,index)=>{ if(el.index == e.detail.index){ @@ -32,35 +62,42 @@ Page({ this.setData({ [xx] : e.detail.answer }) } }) + wx.setStorageSync("answer",JSON.stringify(this.data.allAnswer)) }, hanPaper(){ console.log(app.globalData.studentId,app.globalData.paperId,this.data.allAnswer); - console.log(app.globalData.studentId); + this.setData({ + isCutNum:true + }) app.formPost('/testAnswer/add',{ stu_test_id:app.globalData.studentId, paper_id:app.globalData.paperId, linkAnswerVos:this.data.allAnswer }) wx.request({ - url: 'http://localhost:8090/testStatus/updateSubmitPaperTime', - data:{ - stu_id:app.globalData.studentId, - } + url: `${app.globalData.wxUrl}/testStatus/updateSubmitPaperTime`, + data:{ stu_id:app.globalData.studentId } }) wx.request({ - url: 'http://localhost:8090/testStatus/updateHandPaper', - data:{ - stu_id:app.globalData.studentId, - } - }) - wx.redirectTo({ - url:`/component/handPaper/index` + url: `${app.globalData.wxUrl}/testStatus/updateHandPaper`, + data:{ stu_id:app.globalData.studentId } }) + wx.redirectTo({ url:`/component/handPaper/index` }) + }, + onShow(){ + this.setCountdown(); }, - onHide() { - console.log("我隐藏了"); + if(this.data.isCutNum){ + console.log("我只是前往下一级了"); + }else{ + wx.request({ + url: `${app.globalData.wxUrl}/testStatus/updateCunNum`, + data:{ stu_id:app.globalData.studentId } + }) + } + }, onUnload() { @@ -68,7 +105,10 @@ Page({ var pages = getCurrentPages(); let currPage = pages[pages.length - 2] //上一页 currPage.setData({ - Ansswer:that.data.allAnswer + Ansswer:that.data.allAnswer, + }) + this.setData({ + isCutNum:true }) }, }) \ No newline at end of file diff --git a/component/allPreview/index.wxml b/component/allPreview/index.wxml index f4b8763..202eba0 100644 --- a/component/allPreview/index.wxml +++ b/component/allPreview/index.wxml @@ -1,5 +1,14 @@ - 这里是头部 显示时间 + + + + {{countdown.bell_h}} + : + {{countdown.bell_m}} + : + {{countdown.bell_s}} + + + diff --git a/component/allPreview/index.wxss b/component/allPreview/index.wxss index 9fb1fb5..e6f12a4 100644 --- a/component/allPreview/index.wxss +++ b/component/allPreview/index.wxss @@ -43,5 +43,5 @@ } .conta_foot button{ width: 75%; - background: rgb(81, 81, 199); + background: rgb(46, 134, 222,0.8) } \ No newline at end of file diff --git a/component/handPaper/index.js b/component/handPaper/index.js index bddc2e6..58a9992 100644 --- a/component/handPaper/index.js +++ b/component/handPaper/index.js @@ -8,7 +8,7 @@ Page({ }, getData(){ wx.request({ - url: 'http://localhost:8090/testStatus/selSubmitPaperTime', + url: `${app.globalData.wxUrl}/testStatus/selSubmitPaperTime`, data:{ stu_id:app.globalData.studentId, }, @@ -28,9 +28,17 @@ Page({   y = now.getFullYear(),   m = now.getMonth() + 1,   d = now.getDate(); -   return y + "年" + (m < 10 ? "0" + m : m) + "月" + (d < 10 ? "0" + d : d) + "日 " + now.toTimeString().substr(0, 8); +   return y + "年" + (m < 10 ? "0" + m : m) + "月" + (d < 10 ? "0" + d : d) + "日 " + now.toTimeString().substr(0, 5); }, onShow(){ - this.getData(); - } + wx.hideHomeButton(); + + this.getData(); + }, + onUnload: function () { + /*关闭所有页,打开url指定页面*/ + wx.reLaunch({ + url: '/pages/index/index' + }) + }, }) diff --git a/component/questionType/CheckQuestion/index.wxss b/component/questionType/CheckQuestion/index.wxss index d4fed84..c17c380 100644 --- a/component/questionType/CheckQuestion/index.wxss +++ b/component/questionType/CheckQuestion/index.wxss @@ -2,6 +2,7 @@ box-sizing: border-box; width: 100vw; height: 100rpx; + margin-left: 20rpx; font-size: 18px; font-weight: 800; display: flex; @@ -10,6 +11,7 @@ .title{ box-sizing: border-box; width: 100vw; + margin-left: 20rpx; height: 200rpx; font-size: 18px; font-weight: 800; @@ -17,7 +19,7 @@ .answer{ box-sizing: border-box; width: 100vw; - height: 550rpx; + height: 600rpx; font-size: 18px; font-weight: 10; display: flex; diff --git a/component/questionType/RadioQuestion/index.wxss b/component/questionType/RadioQuestion/index.wxss index 6a4ba30..f21dad0 100644 --- a/component/questionType/RadioQuestion/index.wxss +++ b/component/questionType/RadioQuestion/index.wxss @@ -2,6 +2,7 @@ box-sizing: border-box; width: 100%; height: 100rpx; + margin-left: 20rpx; font-size: 18px; font-weight: 800; display: flex; @@ -10,6 +11,7 @@ .title{ box-sizing: border-box; width: 100%; + margin-left: 20rpx; height: 200rpx; font-size: 18px; font-weight: 800; @@ -17,7 +19,7 @@ .answer{ box-sizing: border-box; width: 100vw; - height: 550rpx; + height: 600rpx; font-size: 18px; font-weight: 10; display: flex; @@ -38,7 +40,7 @@ } .divLine{ background: #d4d4d4; - width: 100%; + width: 95%; height: 3rpx; opacity: 0.7; } \ No newline at end of file diff --git a/component/questionType/RigOrWroQuestion/index.wxss b/component/questionType/RigOrWroQuestion/index.wxss index d4fed84..ff4ea46 100644 --- a/component/questionType/RigOrWroQuestion/index.wxss +++ b/component/questionType/RigOrWroQuestion/index.wxss @@ -5,6 +5,7 @@ font-size: 18px; font-weight: 800; display: flex; + margin-left: 20rpx; align-items: center; } .title{ @@ -12,6 +13,7 @@ width: 100vw; height: 200rpx; font-size: 18px; + margin-left: 20rpx; font-weight: 800; } .answer{ diff --git a/component/questionType/ShortAnswerQuestion/index.wxml b/component/questionType/ShortAnswerQuestion/index.wxml index 42bbd73..6ab0224 100644 --- a/component/questionType/ShortAnswerQuestion/index.wxml +++ b/component/questionType/ShortAnswerQuestion/index.wxml @@ -16,6 +16,7 @@ model:value="{{input}}" > + - + diff --git a/component/questionType/ShortAnswerQuestion/index.wxss b/component/questionType/ShortAnswerQuestion/index.wxss index cbd5d3f..aef9e9c 100644 --- a/component/questionType/ShortAnswerQuestion/index.wxss +++ b/component/questionType/ShortAnswerQuestion/index.wxss @@ -6,10 +6,12 @@ font-weight: 800; display: flex; align-items: center; + margin-left: 20rpx; } .title{ box-sizing: border-box; width: 100vw; + margin-left: 20rpx; height: 200rpx; font-size: 18px; font-weight: 800; @@ -21,6 +23,7 @@ font-size: 18px; font-weight: 10; display: flex; + flex-direction: column; justify-content: center; align-items: center; diff --git a/component/questionType/index.js b/component/questionType/index.js index a523d5e..b90ee62 100644 --- a/component/questionType/index.js +++ b/component/questionType/index.js @@ -1,7 +1,8 @@ let app = getApp() Page({ data:{ - over_time:'2023-05-29 19:00:00', //考试倒计时时间戳 + over_time:'', //考试倒计时时间戳 + countdown:{ bell_h:0, bell_m:0, @@ -15,12 +16,23 @@ Page({ Type:[], + isCutNum:false, //判断是切后台还是跳转下一级 + show:false, //答题卡 questionAll:[], //全部题目 }, onShow:function(){ + wx.getStorage({ + key: 1, + success (res) { + console.log("这里是storage成功",res.data) + }, + complete(res){ + console.log("这里是storage都执行",res.data) + } + }) wx.hideHomeButton(); this.setCountdown(); @@ -44,28 +56,10 @@ Page({ //预览页传回的答案添加与修改 PreviewChangeAnswer(e){ - this.setData({ - allAnswer:e + this.setData({ + allAnswer:e, + isCutNum:false }) - // console.log("传进来了的e",e); - // let flagx = false; - // e.forEach(ele=>{ - // this.data.allAnswer.forEach((el,index)=>{ - // if(el.index == ele.index){ - // let xx = "allAnswer["+index+"].answer" - // this.setData({ [xx] : ele.answer }) - // flagx = true - // } - // console.log(el.index,ele.index,flagx); - // }); - // if(!flagx){ - // console.log("我找到不同的了",e); - // this.setData({ - // allAnswer:this.data.allAnswer.concat(e) - // }) - // } - // }) - // console.log("修改过后",this.data.allAnswer); }, //倒计时时间戳 @@ -76,9 +70,9 @@ Page({ let interval = (time-date)/1000; let hh = Math.floor(interval/60/60%24); let mm = Math.floor(interval/60%60); - mm = mm>10 ? mm : '0'+mm; + mm = mm>=10 ? mm : '0'+mm; let ss = Math.floor(interval%60); - ss = ss>10 ? ss : '0'+ss; + ss = ss>=10 ? ss : '0'+ss; this.setData({ countdown:{ bell_h : hh, @@ -86,6 +80,7 @@ Page({ bell_s : ss, } }) + if(mm == 0 && ss == 0 && hh ==0) this.hanPaper() },1000) }, //处理数据 @@ -96,7 +91,8 @@ Page({ questionTypeNumber:data.questionTypeNumber, answerSheet:data.answerSheet, Type:data.Type, - allAnswer:data.Answer + allAnswer:data.Answer, + over_time:data.delayTime }) }, @@ -164,19 +160,32 @@ Page({ }) } }, - + //交卷 + hanPaper(){ + console.log(app.globalData.studentId,app.globalData.paperId,this.data.allAnswer); + app.formPost('/testAnswer/add',{ + stu_test_id:app.globalData.studentId, + paper_id:app.globalData.paperId, + linkAnswerVos:this.data.allAnswer + }) + wx.request({ + url: `${app.globalData.wxUrl}'/testStatus/updateSubmitPaperTime`, + data:{ stu_id:app.globalData.studentId } + }) + wx.request({ + url: `${app.globalData.wxUrl}/testStatus/updateHandPaper`, + data:{ stu_id:app.globalData.studentId } + }) + wx.redirectTo({ url:`/component/handPaper/index` }) + }, //选题作答 弹出层 selectQuestion(){ - this.setData({ - show:true - }) + this.setData({ show:true }) }, //答题卡中的关闭按钮 exit(e){ - this.setData({ - show:e.detail - }) + this.setData({ show:e.detail }) }, //答题卡中选题 selectQuestionIndex(e){ @@ -188,40 +197,55 @@ Page({ }) }, goPageConta(){ - this.setData({ - pageAllQuestion:this.data.questionAll + this.setData({ + pageAllQuestion:this.data.questionAll, + isCutNum:true }) - }, //组件添加答案和修改答案 - insertAnswer(e){ - this.setData({ - allAnswer:this.data.allAnswer.concat(e.detail) - }) + insertAnswer(e){ + this.setData({ allAnswer:this.data.allAnswer.concat(e.detail) }) + wx.setStorageSync("answer",JSON.stringify(this.data.allAnswer)) }, - changeAnswer(e){ - this.data.allAnswer.forEach((el,index)=>{ - if(el.index == e.detail.index){ - let xx = "allAnswer["+index+"].answer" - this.setData({ - [xx] : e.detail.answer - }) - } - }) - }, - onHide: function() { - console.log("你切后台了"); - }, - onUnload() { - console.log("我卸载了"); + changeAnswer(e){ + this.data.allAnswer.forEach((el,index)=>{ + if(el.index == e.detail.index){ + let xx = "allAnswer["+index+"].answer" + this.setData({ [xx] : e.detail.answer }) + } + }) + wx.setStorageSync("answer",JSON.stringify(this.data.allAnswer)) + }, + + goLookAll(){ + const object = { + questionAll:this.data.questionAll, + allAnswer:this.data.allAnswer, + over_time:this.data.over_time + } + wx.navigateTo({ + url: `/component/allPreview/index?object=${encodeURIComponent(JSON.stringify(object))}`, + }) + this.triggerEvent('exit',false); + }, + onHide: function() { + if(this.data.isCutNum){ + console.log("我只是前往下一级了"); + }else{ wx.request({ - url: 'http://localhost:8090/testAnswer/saveAnswer', - data:{ - stu_id:20203779, - paper_id:10 - }, + url: `${app.globalData.wxUrl}/testStatus/updateCunNum`, + data:{ stu_id:app.globalData.studentId } }) - }, + } + }, + onUnload:function() { + console.log("我是questionType我卸载了"); + app.formPost('/testAnswer/saveAnswer',{ + stu_test_id:app.globalData.studentId, + paper_id:app.globalData.paperId, + linkAnswerVos:this.data.allAnswer + }) + }, }) \ No newline at end of file diff --git a/component/questionType/index.wxml b/component/questionType/index.wxml index ff6f4f7..ee6914b 100644 --- a/component/questionType/index.wxml +++ b/component/questionType/index.wxml @@ -1,7 +1,8 @@ - + + {{countdown.bell_h}} : {{countdown.bell_m}} @@ -27,6 +28,7 @@ allAnswer="{{allAnswer}}" pageAllQuestion="{{questionAll}}" Type="{{Type}}" + over_time="{{over_time}}" > @@ -80,7 +82,11 @@ - + + \ No newline at end of file diff --git a/component/questionType/index.wxss b/component/questionType/index.wxss index 5b962bb..a3c4f40 100644 --- a/component/questionType/index.wxss +++ b/component/questionType/index.wxss @@ -26,14 +26,6 @@ border-bottom: 1px solid rgb(177, 176, 176,0.2); box-shadow: 1px 1px 3px rgb(177, 176, 176,0.2); } -/* .title_center{ - box-sizing: border-box; - width: 100%; - height: 78%; - display: flex; - flex-direction: column; - white-space: nowrap; -} */ .title_center{ width: 100vh; height: 78%; @@ -59,16 +51,15 @@ .selectQuestion{ background: rgb(46, 134, 222,0.5); - border:solid rgb(46, 134, 222) 2px; border-radius: 10px; - width: 16%; - height: 50%; + width: 18%; + height: 60%; font-size: 16px; display: flex; flex-direction: column; justify-content: center; align-items: center; - margin-left: 27%; + margin-left: 17%; } .divLine{ background: #d4d4d4; diff --git a/component/questionType/pageConta/index.js b/component/questionType/pageConta/index.js index 36070ab..57b4821 100644 --- a/component/questionType/pageConta/index.js +++ b/component/questionType/pageConta/index.js @@ -11,6 +11,7 @@ Component({ value:[] }, pageAllQuestion:{}, + over_time:0 }, data: { @@ -28,8 +29,13 @@ Component({ this.triggerEvent('exit',false); }, goLookAll(){ + const object = { + questionAll:this.properties.pageAllQuestion, + allAnswer:this.properties.allAnswer, + over_time:this.properties.over_time + } wx.navigateTo({ - url: `/component/allPreview/index?questionAll=${encodeURIComponent(JSON.stringify(this.properties.pageAllQuestion))}&allAnswer=${encodeURIComponent(JSON.stringify(this.properties.allAnswer))}`, + url: `/component/allPreview/index?object=${encodeURIComponent(JSON.stringify(object))}`, }) this.triggerEvent('exit',false); }, diff --git a/pages/exam/do/index.js b/pages/exam/do/index.js index a2e6b9e..eb3093a 100644 --- a/pages/exam/do/index.js +++ b/pages/exam/do/index.js @@ -6,8 +6,8 @@ Page({ * 页面的初始数据 */ data: { + loading:true, questionAll:[], - questionTypeNumber : { radioQues:0, rigorwroQues:0, @@ -24,13 +24,10 @@ Page({ date:"2023-05-11", cutNum:0 }, - countDown:2, + countDown:5, allAnswer:[], - isHandPaper:null, - Type:[], - isChecked:false, isButtonDisabled:false, @@ -45,7 +42,10 @@ Page({ { title:"考试时间", content:"2023-04-27 16:00:00 值 2023-04-27 17:30:00", - }] + }], + //考试时间和结束时间 + testTime:0, + delayTime:0, }, onTest(){ if(this.data.countDown > 0) this.setData({ isChecked:!this.data.isChecked }) @@ -58,13 +58,14 @@ Page({ }, req(){ wx.request({ - url: 'http://localhost:8090/testExam/get', + url: `${app.globalData.wxUrl}/testExam/get`, data:{ courseId:1, grade:1 }, complete : (res)=>{ const data = res.data[0]; + let testName = "testInfo[0].content" console.log(data); app.globalData.paperId = data.paperId; const arr = [];//题目 @@ -104,20 +105,34 @@ Page({ answerSheet:{ index:1, all:arr.length - } + }, + [testName]:data.paperName }) } }) }, goDo(){ + this.setData({ loading:true }) wx.request({ - url: 'http://localhost:8090/testStatus/add', + url:`${app.globalData.wxUrl}/testStatus/add`, data:{ stu_id:app.globalData.studentId, name:"张三" }, complete:(res)=>{ - if(res.data == app.globalData.studentId) this.getAnswer(); + if(res.data.studentId == app.globalData.studentId){ + let date = new Date(res.data.getData) + date.setTime(date.setMinutes(date.getMinutes()+this.data.testInfo[1].content)); + this.data.testTime = this.TimestampToDate2(new Date().getTime()); + this.data.delayTime = this.TimestampToDate2(date.getTime()); + let testDuration = "testInfo[1].content" + let testTime = "testInfo[2].content" + this.setData({ + [testDuration]:res.data, + [testTime]: this.data.testTime+" 至 \r\n"+this.data.delayTime + }) + this.getAnswer(); + } } }) let timer = setInterval(()=>{ @@ -128,45 +143,57 @@ Page({ questionTypeNumber:this.data.questionTypeNumber, answerSheet:this.data.answerSheet, Type:this.data.Type, - Answer:this.data.allAnswer + Answer:this.data.allAnswer, + delayTime:this.data.delayTime } + console.log(object); wx.redirectTo({ url:`/component/questionType/index?object=${encodeURIComponent(JSON.stringify(object))}` }) } },1000) - + }, getAnswer(){ - wx.request({ - url: 'http://localhost:8090/testAnswer/selAnswer', - data:{ - paper_id:app.globalData.paperId, - stu_id:app.globalData.studentId - }, - complete:res=>{ + // wx.request({ + // url: `${app.globalData.wxUrl}/testAnswer/selAnswer`, + // data:{ + // paper_id:app.globalData.paperId, + // stu_id:app.globalData.studentId + // }, + // complete:res=>{ + const data= JSON.parse(wx.getStorageSync('answer')); const arr = [] - res.data.forEach(el=>{ + data.forEach(el=>{ const answer = { index:el.index, question_id:el.question_id, - answer:JSON.parse(el.answer) + answer:el.answer } arr.push(answer) }) + console.log("传回来的答案",data); this.setData({ allAnswer:arr }) - } - }) + //} + //}) }, getTestTime(){ wx.request({ - url: 'http://localhost:8090/testTime/get', + url: `${app.globalData.wxUrl}/testTime/get`, data:{ paperId:7 }, complete:(res)=>{ - const date = new Date().getTime(); - console.log("返回的时间",res.data,date); + let date = new Date(); + date.setTime(date.setMinutes(date.getMinutes()+res.data)); + this.data.testTime = this.TimestampToDate2(new Date().getTime()); + this.data.delayTime = this.TimestampToDate2(date.getTime()); + let testDuration = "testInfo[1].content" + let testTime = "testInfo[2].content" + this.setData({ + [testDuration]:res.data, + [testTime]: this.data.testTime+" 至 \r\n"+this.data.delayTime + }) } }) }, @@ -175,11 +202,11 @@ Page({   y = now.getFullYear(),   m = now.getMonth() + 1,   d = now.getDate(); -   return y + "年" + (m < 10 ? "0" + m : m) + "月" + (d < 10 ? "0" + d : d) + "日 " + now.toTimeString().substr(0, 8); - }, +   return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 5); + }, isHandPaper(){ wx.request({ - url: 'http://localhost:8090/testStatus/selStuHandPaper', + url: `${app.globalData.wxUrl}/testStatus/selStuHandPaper`, data:{ stu_id:app.globalData.studentId }, @@ -190,29 +217,33 @@ Page({ }, onShow() { + const xxl = `${app.globalData.wxUrl}/testStatus/selStuHandPaper` + console.log(xxl); + //计算考试时间 this.getTestTime(); + //查看时候交过卷 this.isHandPaper(); + //加载试卷 + this.req(); + let timer = setInterval(()=>{ if(this.data.isHandPaper != 'null' && this.data.isHandPaper == 1){ clearInterval(timer) - wx.redirectTo({ - url:`/component/handPaper/index` - }) - }else if(this.data.isHandPaper != 'null' && this.data.isHandPaper == 0) clearInterval(timer) - },1000) - this.req(); - - - const time = setInterval(()=>{ - if(this.data.countDown <= 1){ - clearInterval(time); - this.setData({ - isButtonDisabled:this.data.isChecked - }); + wx.redirectTo({ url:`/component/handPaper/index` }) + }else if(this.data.isHandPaper != 'null' && this.data.isHandPaper == 0){ + clearInterval(timer) + this.setData({ loading:false}) } - this.setData({ - countDown:this.data.countDown-1 - }) },1000) + + if(this.data.loading){ + const time = setInterval(()=>{ + if(this.data.countDown <= 1){ + clearInterval(time); + this.setData({ isButtonDisabled:this.data.isChecked }); + } + this.setData({ countDown:this.data.countDown-1 }); + },1000) + } }, }) \ No newline at end of file diff --git a/pages/exam/do/index.wxml b/pages/exam/do/index.wxml index 74ba0b6..995dd2a 100644 --- a/pages/exam/do/index.wxml +++ b/pages/exam/do/index.wxml @@ -1,4 +1,7 @@ - + + 数据加载中 + + 姓名: 学号: diff --git a/pages/exam/do/index.wxss b/pages/exam/do/index.wxss index 3d86ea2..1426d56 100644 --- a/pages/exam/do/index.wxss +++ b/pages/exam/do/index.wxss @@ -1,3 +1,42 @@ +.loading{ + width: 100vw; + height: 100vh; + position: fixed; + display: flex; + align-items: center; + justify-content: center; +} +.loading text{ + position: relative; + +} +.loading text::after{ + content: " "; + display: inline-block; /* 块级元素 */ + width: 5px; + height: 5px; + border-radius: 50%; + position: absolute; + right: 0; + top: 50%; + animation-name: loadingAn; + animation-duration: 1.5s; + animation-iteration-count: infinite; +} +@keyframes loadingAn{ +0%{ + box-shadow: none ; +} +30%{ + box-shadow: 8px 1px 0 currentColor ; +} +60%{ + box-shadow: 8px 1px 0 currentColor , 16px 1px 0 currentColor; +} +90%{ + box-shadow: 8px 1px 0 currentColor , 16px 1px 0 currentColor , 24px 1px 0 currentColor; +} +} .conta{ position: absolute; width: 100vw; diff --git a/project.config.json b/project.config.json index c6493ea..f958ecb 100644 --- a/project.config.json +++ b/project.config.json @@ -49,7 +49,7 @@ }, "compileType": "miniprogram", "libVersion": "2.25.3", - "appid": "wxc0bda46a215e6cbd", + "appid": "wx68e64a9816939d46", "projectname": "demo2", "condition": {}, "editorSetting": { diff --git a/project.private.config.json b/project.private.config.json index 435fbbb..ff24fb2 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -6,5 +6,6 @@ "bigPackageSizeSupport": false, "preloadBackgroundData": false, "urlCheck": false - } + }, + "libVersion": "2.32.1" } \ No newline at end of file -- Gitee