diff --git a/app.js b/app.js index 07375f5582a1024b5e43edc73f54c451f1795007..c1f0a6e285c18c8b515e4870853307ac8a44fe2b 100644 --- a/app.js +++ b/app.js @@ -13,9 +13,13 @@ App({ } }) }, + + //全局变量 globalData: { baseAPI: "http://localhost:8090", - pageSize: 20 + pageSize: 20, + studentId:20203778, //学生id + paperId:0 //试卷id }, formPost: function(url, data) { let _this = this diff --git a/app.json b/app.json index cfe9a705b3ac8721cbeb9d1ca4744369ee0f70fb..34d9085a45af4a5979e3f82753ec000dd7e60202 100644 --- a/app.json +++ b/app.json @@ -4,7 +4,6 @@ "pages/index/index", "pages/exam/do/index", "pages/logs/logs", - "pages/exam/do", "component/questionType/index", "component/allPreview/index", diff --git a/component/allPreview/index.js b/component/allPreview/index.js index 4cf9b5e21c6eff66e6ab73575879a66da72b84ef..c8ec17f0322347875c6785d2993e940d7dfc9f07 100644 --- a/component/allPreview/index.js +++ b/component/allPreview/index.js @@ -1,4 +1,5 @@ // component/allPreview/index.js +const app = getApp() Page({ /** @@ -35,7 +36,17 @@ 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, + question_id:1111, + stu_answer:['A','B'] + }).then(res=>{ + console.log(res); + }) + }, /** * 生命周期函数--监听页面初次渲染完成 */ diff --git a/component/allPreview/index.wxml b/component/allPreview/index.wxml index e92971c6740ed2446d2921428e575c36ca992179..43805e23d96aee0be9d5c2557321d92c354c2e03 100644 --- a/component/allPreview/index.wxml +++ b/component/allPreview/index.wxml @@ -48,7 +48,7 @@ - + \ No newline at end of file diff --git a/component/questionType/CheckQuestion/index.js b/component/questionType/CheckQuestion/index.js index 2f429fb1739f29329bcc71bec8128b9a9f1ea462..09d14549652f0a050702da8e34f947e1101441d0 100644 --- a/component/questionType/CheckQuestion/index.js +++ b/component/questionType/CheckQuestion/index.js @@ -33,6 +33,7 @@ Component({ const Answer = { index:this.properties.questionIndex, + questionId:this.properties.question.questionId, answer:this.data._num } diff --git a/component/questionType/RadioQuestion/index.js b/component/questionType/RadioQuestion/index.js index ac3c0c12b4139962f2e8c16d518500bd2e8c6f00..c3aa04891118f887fedbcbb1bd3954156869fc0c 100644 --- a/component/questionType/RadioQuestion/index.js +++ b/component/questionType/RadioQuestion/index.js @@ -29,6 +29,7 @@ Component({ }); const Answer = { index:this.properties.questionIndex, + questionId:this.properties.question.questionId, answer:e.target.dataset.test } diff --git a/component/questionType/RigOrWroQuestion/index.js b/component/questionType/RigOrWroQuestion/index.js index 9dff5a8498509870179624d60f55a52e73a18a1c..69ef88a76bb778f96f77005afd48bbabc748a4b7 100644 --- a/component/questionType/RigOrWroQuestion/index.js +++ b/component/questionType/RigOrWroQuestion/index.js @@ -23,6 +23,7 @@ Component({ }); const Answer = { index:this.properties.questionIndex, + questionId:this.properties.question.questionId, answer:e.target.dataset.test } diff --git a/component/questionType/index.js b/component/questionType/index.js new file mode 100644 index 0000000000000000000000000000000000000000..666255ff8e80004693bbc29ccd363e26db311f83 --- /dev/null +++ b/component/questionType/index.js @@ -0,0 +1,183 @@ +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/component/questionType/index.json b/component/questionType/index.json new file mode 100644 index 0000000000000000000000000000000000000000..1e185fc3af176298a066bc0e3f0866ee7efc6411 --- /dev/null +++ b/component/questionType/index.json @@ -0,0 +1,9 @@ +{ + "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/component/questionType/index.wxml b/component/questionType/index.wxml new file mode 100644 index 0000000000000000000000000000000000000000..c4354bdf31089e0a28997d5e443236e0832a1c1f --- /dev/null +++ b/component/questionType/index.wxml @@ -0,0 +1,83 @@ + + + + + {{countdown.bell_h}} + : + {{countdown.bell_m}} + : + {{countdown.bell_s}} + + + + + 答题卡 + {{answerSheet.index}}/{{answerSheet.all}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/component/questionType/index.wxss b/component/questionType/index.wxss new file mode 100644 index 0000000000000000000000000000000000000000..5b962bbe2a1922228a9fca2dd0d79bf7cefab3db --- /dev/null +++ b/component/questionType/index.wxss @@ -0,0 +1,78 @@ +.conta{ + box-sizing: border-box; + display: flex; + flex-direction: column; + height: 100vh; + width: 100vw; + overflow: hidden; + position: fixed; /*设置页面高度100% 页面不可滑动 */ +} +/* .conta::before{ + width: 100%; + height: 100%; + background: rebeccapurple; + background-attachment: fixed; + position: absolute; + content: "20203778"; + z-index: -1; + -webkit-filter: opacity(70%); +} */ +.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; + + } \ No newline at end of file diff --git a/pages/exam/do.js b/pages/exam/do.js deleted file mode 100644 index f7718f73e8ff015758d14e81ab0fab8551c0e8dd..0000000000000000000000000000000000000000 --- a/pages/exam/do.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/exam/do.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/exam/do.wxml b/pages/exam/do.wxml deleted file mode 100644 index de1d96f4a69e68781a4c15ca13812f4b47fd0815..0000000000000000000000000000000000000000 --- a/pages/exam/do.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/exam/do.wxml diff --git a/pages/exam/do/index.js b/pages/exam/do/index.js index 674a2686eb1a1ab8d85d4605e9da4f65d6db174c..4d10bb07f69cd47de50e69bce33da0623d42389b 100644 --- a/pages/exam/do/index.js +++ b/pages/exam/do/index.js @@ -56,6 +56,8 @@ Page({ console.log(res.data); }, complete : (res)=>{ + console.log(res.data.paperId); + app.globalData.paperId = res.data.paperId; const arr = [];//题目 const TypeNumber = { radioQues:0, @@ -169,5 +171,5 @@ Page({ */ onShareAppMessage() { - } + }, }) \ No newline at end of file diff --git a/pages/exam/do/index.txt b/pages/exam/do/index.txt new file mode 100644 index 0000000000000000000000000000000000000000..666255ff8e80004693bbc29ccd363e26db311f83 --- /dev/null +++ b/pages/exam/do/index.txt @@ -0,0 +1,183 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..1e185fc3af176298a066bc0e3f0866ee7efc6411 --- /dev/null +++ b/pages/exam/do/index2.txt @@ -0,0 +1,9 @@ +{ + "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 new file mode 100644 index 0000000000000000000000000000000000000000..c4354bdf31089e0a28997d5e443236e0832a1c1f --- /dev/null +++ b/pages/exam/do/index3.txt @@ -0,0 +1,83 @@ + + + + + {{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 new file mode 100644 index 0000000000000000000000000000000000000000..bb42384768ad5dc4991f227f13cfdc09d8b9d43a --- /dev/null +++ b/pages/exam/do/index4.txt @@ -0,0 +1,69 @@ +.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; + + } +