diff --git a/app.js b/app.js
index c1f0a6e285c18c8b515e4870853307ac8a44fe2b..d212abd5120465656c720d8c18e54f079f8ba93f 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 15e593b4f0eb17ff065600efa71b3a6e99299e99..72f411983ca3c1ec898236d588aead5822816fad 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
Binary files /dev/null and b/assets/myNewIcon/bell.png differ
diff --git a/component/allPreview/index.js b/component/allPreview/index.js
index 1bedc7f1c3586453906d6fdbc3b252f477a87337..7594cf2382457ebe2ec728a5e1aa35e006dd32fc 100644
--- a/component/allPreview/index.js
+++ b/component/allPreview/index.js
@@ -6,97 +6,109 @@ Page({
* 页面的初始数据
*/
data: {
- id:12345678,
questionAll:{},
allAnswer:[],
answerSheet:{ //答题卡
index:1,
all:43
- },
+ },
+ countdown:{
+ bell_h:0,
+ bell_m:0,
+ bell_s:0,
+ },
+ over_time:0,
+ isCutNum:false
},
onLoad(e) {
+ const object = JSON.parse(decodeURIComponent(e.object))
+ console.log("传入后的",object);
this.setData({
- questionAll:JSON.parse(decodeURIComponent(e.questionAll)),
- allAnswer:JSON.parse(decodeURIComponent(e.allAnswer))
+ questionAll:object.questionAll,
+ allAnswer:object.allAnswer,
+ over_time:object.over_time
})
},
//组件添加答案和修改答案
- 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))
+ },
+ //倒计时时间戳
+ 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,
+ }
+ })
+ if(mm == 0 && ss == 0 && hh ==0) this.hanPaper()
+ },1000)
+ },
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
- })
+ 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);
+ this.setData({
+ isCutNum:true
+ })
app.formPost('/testAnswer/add',{
stu_test_id:app.globalData.studentId,
paper_id:app.globalData.paperId,
linkAnswerVos:this.data.allAnswer
- }).then(res=>{
- console.log(res);
})
+ 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` })
},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
+ 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() {
var that = this;
var pages = getCurrentPages();
let currPage = pages[pages.length - 2] //上一页
currPage.setData({
- Ansswer:that.data.allAnswer
+ Ansswer:that.data.allAnswer,
+ })
+ this.setData({
+ isCutNum:true
})
},
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
})
\ No newline at end of file
diff --git a/component/allPreview/index.wxml b/component/allPreview/index.wxml
index 3fdf755dbee97d9aeeb786e206c061ed245cadb7..202eba0b132832b26893d208166402ca7b014a40 100644
--- a/component/allPreview/index.wxml
+++ b/component/allPreview/index.wxml
@@ -1,5 +1,14 @@
- 这里是头部 显示时间
+
+
+
+ {{countdown.bell_h}}
+ :
+ {{countdown.bell_m}}
+ :
+ {{countdown.bell_s}}
+
+
+
@@ -31,6 +41,9 @@
diff --git a/component/allPreview/index.wxss b/component/allPreview/index.wxss
index 9fb1fb513dee1d4e3f8ea74c0bc30f9e947ecda0..e6f12a48e52ac0b7fa8963509f21788b5ba03dd2 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
new file mode 100644
index 0000000000000000000000000000000000000000..58a999240994027e96176bbaef0ea7cb86689389
--- /dev/null
+++ b/component/handPaper/index.js
@@ -0,0 +1,44 @@
+// 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: `${app.globalData.wxUrl}/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, 5);
+ },
+ onShow(){
+ wx.hideHomeButton();
+
+ this.getData();
+ },
+ onUnload: function () {
+ /*关闭所有页,打开url指定页面*/
+ wx.reLaunch({
+ url: '/pages/index/index'
+ })
+ },
+})
diff --git a/component/handPaper/index.json b/component/handPaper/index.json
new file mode 100644
index 0000000000000000000000000000000000000000..e8cfaaf80c404eb97d3cf8b6277ec15f37e6905e
--- /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 0000000000000000000000000000000000000000..09a4cf816f5218010f9f8cb4e1c4ab98e649fad5
--- /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 0000000000000000000000000000000000000000..16cbab36d8ebabb72475a8d1bec64ceade90a921
--- /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
diff --git a/component/questionType/CheckQuestion/index.js b/component/questionType/CheckQuestion/index.js
index a44a1773ff1e2d81285ba1f75321cc1a076c95b8..e4266a02c18659562bb8036c0f644a7997ceab20 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/CheckQuestion/index.wxss b/component/questionType/CheckQuestion/index.wxss
index d4fed8436cfadb9b011aa7f11fd30418813b767c..c17c38096b330e26a17b356cb8e18bd8ebebe91e 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.js b/component/questionType/RadioQuestion/index.js
index 01cb596f1c56ae8f101e7e0e6a019d3bf33770fa..8799c0a81b993cef9cfba1808cce37755c0be099 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/RadioQuestion/index.wxss b/component/questionType/RadioQuestion/index.wxss
index 6a4ba304647a898e88803f16e70cf3fb0e36ecb5..f21dad089fa003d493e7c0d4efe84104eb5b951b 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.js b/component/questionType/RigOrWroQuestion/index.js
index 77099747a04b990b16f8ab93a1e18f912342ece3..06d0f308a3910bf6dd93b98c2679c6b8c50f8460 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/RigOrWroQuestion/index.wxss b/component/questionType/RigOrWroQuestion/index.wxss
index d4fed8436cfadb9b011aa7f11fd30418813b767c..ff4ea469666aff30e763a33445c554ce5dc4632c 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.js b/component/questionType/ShortAnswerQuestion/index.js
index d0a8a636837d2843298614524ff8935efaa26ad9..8f47e4ab091eb2acbf199c51b7a8bc861c0a9bb6 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 eb826fc0922e26832767c46219556d4b39b6d4a3..6ab0224dc1ce9efed393d6d54dd29aac52851418 100644
--- a/component/questionType/ShortAnswerQuestion/index.wxml
+++ b/component/questionType/ShortAnswerQuestion/index.wxml
@@ -11,9 +11,12 @@
+
+
diff --git a/component/questionType/ShortAnswerQuestion/index.wxss b/component/questionType/ShortAnswerQuestion/index.wxss
index cbd5d3f4fa138f9a133c83a67e887cf25b80b504..aef9e9c8bcc510301eb9d7954fae96e3695d2a9e 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 3b96c0a87b030c10323547f77dcfabeb56c2912b..b90ee62e47f347b40a52edb70596c50abcddd750 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,
@@ -11,23 +12,27 @@ Page({
//答题卡
answerSheet:{},
- //个类型问题个数
- questionTypeNumber:{},
- relativeIndex:{
- checkIndex:0,
- rigorwroIndex:0,
- shortanswerIndex:0
- },
-
allAnswer:[],
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();
@@ -51,24 +56,10 @@ 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,
+ isCutNum:false
})
- console.log(this.data.allAnswer);
},
//倒计时时间戳
@@ -79,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,
@@ -89,59 +80,112 @@ Page({
bell_s : ss,
}
})
+ if(mm == 0 && ss == 0 && hh ==0) this.hanPaper()
},1000)
},
//处理数据
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,
+ over_time:data.delayTime
})
- 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
+ },
+ })
+ }
+ },
+ //交卷
+ 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){
@@ -153,29 +197,55 @@ Page({
})
},
goPageConta(){
- console.log("进来了");
- 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
- })
- }
- })
- },
+ 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: `${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 57e37dae0450206bd6b10964e460841386fa36fe..ee6914bd1ae0ac78549cd48baecb5fb3b49d6379 100644
--- a/component/questionType/index.wxml
+++ b/component/questionType/index.wxml
@@ -1,7 +1,8 @@
-
+
+
{{countdown.bell_h}}
:
{{countdown.bell_m}}
@@ -22,13 +23,12 @@
bind:beforeenter="goPageConta"
>
@@ -74,14 +74,19 @@
bindchangeAnswer="changeAnswer"
allAnswer="{{allAnswer}}"
questionIndex="{{index+1}}"
+ class="shortAnswer"
>
-
+
\ No newline at end of file
diff --git a/component/questionType/index.wxss b/component/questionType/index.wxss
index 5b962bbe2a1922228a9fca2dd0d79bf7cefab3db..a3c4f404d477acc584cc7018a4de2414391f5e16 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 351b371e676e19f5fd0cd08b80e2d36c13df28aa..57b4821f965ca6d69212edc0aa5e1abf16637019 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,8 @@ Component({
value:[]
},
pageAllQuestion:{},
- relativeIndex:{}
-
+ over_time:0
},
-
-
data: {
},
@@ -29,13 +25,17 @@ Component({
//选题
selectQues(e){
this.triggerEvent('selectQuestionIndex',e.target.dataset.text);
- console.log(e.target.dataset.text);
//撤销弹出层
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 1b457db88f66efb1dcc28c5253359cde6cc1fbd1..eb3093af831f950d6c44239f0c4e0b03e7c81e65 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,
@@ -19,20 +19,15 @@ Page({
all:0
},
studentInfo:{
- student_id:20203778,
+ student_id:20203779,
name:"张三",
date:"2023-05-11",
cutNum:0
},
- countDown:2,
-
- answer:{
- index:0,
- question_id:0,
- answer:''
- },
+ countDown:5,
+ allAnswer:[],
+ isHandPaper:null,
Type:[],
-
isChecked:false,
isButtonDisabled:false,
@@ -47,14 +42,14 @@ 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
- })
- }else{
+ if(this.data.countDown > 0) this.setData({ isChecked:!this.data.isChecked })
+ else{
this.setData({
isChecked:!this.data.isChecked,
isButtonDisabled:!this.data.isChecked
@@ -63,20 +58,14 @@ Page({
},
req(){
wx.request({
- // url: 'http://localhost:8090/get/paper',
- // data:{
- // id:4
- // },
- url: 'http://localhost:8090/testExam/get',
+ url: `${app.globalData.wxUrl}/testExam/get`,
data:{
courseId:1,
grade:1
},
- succsee:function(res){
- console.log(res.data);
- },
complete : (res)=>{
const data = res.data[0];
+ let testName = "testInfo[0].content"
console.log(data);
app.globalData.paperId = data.paperId;
const arr = [];//题目
@@ -106,9 +95,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({
@@ -118,72 +105,145 @@ 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:20203778,
+ stu_id:app.globalData.studentId,
name:"张三"
},
- succsee:(res)=>{
- console.log("回来了",res);
- },
complete:(res)=>{
- if(res.data == app.globalData.studentId){
+ 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();
+ }
}
- }
- })
-
- 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,
+ delayTime:this.data.delayTime
+ }
+ console.log(object);
+ wx.redirectTo({
+ url:`/component/questionType/index?object=${encodeURIComponent(JSON.stringify(object))}`
+ })
+ }
+ },1000)
+
},
getAnswer(){
+ // 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 = []
+ data.forEach(el=>{
+ const answer = {
+ index:el.index,
+ question_id:el.question_id,
+ answer:el.answer
+ }
+ arr.push(answer)
+ })
+ console.log("传回来的答案",data);
+ this.setData({ allAnswer:arr })
+ //}
+ //})
+ },
+ getTestTime(){
wx.request({
- url: 'http://localhost:8090/testAnswer/selAnswer',
+ url: `${app.globalData.wxUrl}/testTime/get`,
+ data:{
+ paperId:7
+ },
+ complete:(res)=>{
+ 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
+ })
+ }
+ })
+ },
+ 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, 5);
+ },
+ isHandPaper(){
+ wx.request({
+ url: `${app.globalData.wxUrl}/testStatus/selStuHandPaper`,
data:{
- paper_id:app.globalData.paperId,
stu_id:app.globalData.studentId
},
- succsee:(res)=>{
- console.log("回来了",res);
- },
complete:res=>{
- this.setData({
- answer:res.data
- })
- console.log(this.data.answer);
+ this.setData({ isHandPaper:res.data })
}
- })
+ })
},
onShow() {
+ const xxl = `${app.globalData.wxUrl}/testStatus/selStuHandPaper`
+ console.log(xxl);
+ //计算考试时间
+ this.getTestTime();
+ //查看时候交过卷
+ this.isHandPaper();
+ //加载试卷
this.req();
-
-
- const time = setInterval(()=>{
- if(this.data.countDown <= 1){
- clearInterval(time);
- this.setData({
- isButtonDisabled:this.data.isChecked
- });
+
+ 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)
+ 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.txt b/pages/exam/do/index.txt
deleted file mode 100644
index 666255ff8e80004693bbc29ccd363e26db311f83..0000000000000000000000000000000000000000
--- 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/index.wxml b/pages/exam/do/index.wxml
index 74ba0b6c3f3d6969ee7f686a0c2aa13a6d5f0a21..995dd2a2f231f2d9e83bdfa86258a5031db8c047 100644
--- a/pages/exam/do/index.wxml
+++ b/pages/exam/do/index.wxml
@@ -1,4 +1,7 @@
-
+
+ 数据加载中
+
+