|
@@ -4,46 +4,7 @@ Page({
|
|
|
data: {
|
|
|
index: 0, // 题目序列
|
|
|
chooseValue: [], // 选择的答案序列
|
|
|
- questionList: [
|
|
|
- // {
|
|
|
- // id: 10,
|
|
|
- // "QuestStem": "以下属于传统协同办公应用开发的典型问题的是?",
|
|
|
- // 'QuestChoice': [{
|
|
|
- // name: 'a',
|
|
|
- // value: 'aaaaaaa',
|
|
|
- // checked: false
|
|
|
- // },
|
|
|
- // {
|
|
|
- // name: 'aa',
|
|
|
- // value: 'sdsdsd',
|
|
|
- // checked: false
|
|
|
- // },
|
|
|
- // {
|
|
|
- // name: 'a3',
|
|
|
- // value: 'ewewewe',
|
|
|
- // checked: false
|
|
|
- // },
|
|
|
- // ],
|
|
|
- // "QuestType": 1,
|
|
|
- // "checked": false
|
|
|
- // },
|
|
|
- // {
|
|
|
- // id: 12,
|
|
|
- // "QuestStem": "企业微信建立开放办公应用生态的主要策略是000?",
|
|
|
- // "QuestChoice": ['A', 'B'],
|
|
|
- // "QuestType": 2,
|
|
|
- // "scores": 10,
|
|
|
- // "checked": false
|
|
|
- // },
|
|
|
-
|
|
|
- // {
|
|
|
- // id: 123,
|
|
|
- // "QuestStem": "企业微信建立开放办公应用生态的主要策略是?",
|
|
|
- // "QuestType": 3,
|
|
|
- // "scores": 10,
|
|
|
- // "checked": false
|
|
|
- // },
|
|
|
- ],
|
|
|
+ questionList: [],
|
|
|
totalScore: 0,
|
|
|
id: '', //考试主键id(可取list接口中id)
|
|
|
paperId: '', //试卷id(可取list接口中paperId)
|
|
@@ -54,12 +15,10 @@ Page({
|
|
|
* 单选事件
|
|
|
*/
|
|
|
radioChange: function (e) {
|
|
|
- console.log('checkbox发生change事件,携带value值为:', e.detail.value)
|
|
|
let json = {};
|
|
|
json.currentAnswer = e.detail.value;
|
|
|
json.id = e.currentTarget.dataset.idx;
|
|
|
json.questType = e.currentTarget.dataset.questtypes;
|
|
|
- console.log("题目", this.data.questionList)
|
|
|
this.data.chooseValue[this.data.index] = json;
|
|
|
this.data.questionList[this.data.index].checked = e.detail.value;
|
|
|
|
|
@@ -71,8 +30,8 @@ Page({
|
|
|
wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
|
|
|
wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
|
|
|
|
|
|
- }, radioChange: function (e) {
|
|
|
- console.log('checkbox发生change事件,携带value值为:', e.detail.value)
|
|
|
+ },
|
|
|
+ radioChange: function (e) {
|
|
|
let json = {};
|
|
|
json.currentAnswer = e.detail.value;
|
|
|
json.id = e.currentTarget.dataset.idx;
|
|
@@ -82,21 +41,17 @@ Page({
|
|
|
for (let i = 0, len = items.length; i < len; ++i) {
|
|
|
items[i].checked = items[i].value === e.detail.value
|
|
|
}
|
|
|
- console.log( this.data.chooseValue,"尅额么");
|
|
|
- console.log(this.data.questionList);
|
|
|
this.setData({
|
|
|
questionList: this.data.questionList
|
|
|
})
|
|
|
wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
|
|
|
wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
|
|
|
wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
|
|
|
-
|
|
|
},
|
|
|
/*
|
|
|
* 多选事件
|
|
|
*/
|
|
|
checkboxChange: function (e) {
|
|
|
- console.log('checkbox发生change事件,携带value值为:', e.detail.value)
|
|
|
let json = {};
|
|
|
let aa = e.detail.value.join("||")
|
|
|
json.currentAnswer = aa;
|
|
@@ -117,20 +72,14 @@ Page({
|
|
|
this.setData({
|
|
|
questionList: this.data.questionList
|
|
|
})
|
|
|
- console.log(this.data.questionList, "7878787878");
|
|
|
-
|
|
|
wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
|
|
|
wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
|
|
|
wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), this.data.chooseValue);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
/*
|
|
|
* 解答事件
|
|
|
*/
|
|
|
bindTextAreaBlur(e) {
|
|
|
- console.log(e.detail.value);
|
|
|
let json = {};
|
|
|
json.currentAnswer = e.detail.value;
|
|
|
json.id = e.currentTarget.dataset.idx;
|
|
@@ -157,7 +106,6 @@ Page({
|
|
|
})
|
|
|
wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
|
|
|
} else {
|
|
|
- console.log(this.data.chooseValue);
|
|
|
if (wx.getStorageSync('chooseValue' + this.data.answersId)) {
|
|
|
this.setData({
|
|
|
chooseValue: wx.getStorageSync('chooseValue' + this.data.answersId)
|
|
@@ -171,116 +119,22 @@ Page({
|
|
|
index: this.data.index - 1
|
|
|
})
|
|
|
wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), this.data.index);
|
|
|
- console.log(this.data.chooseValue, "88888888888888888888888888");
|
|
|
- console.log(this.data.chooseValue[this.data.index]);
|
|
|
-
|
|
|
- //this.data.chooseValue[this.data.index].currentAnswer
|
|
|
-
|
|
|
},
|
|
|
- // onLoad: function (options) {
|
|
|
- // let a = [{
|
|
|
- // "QuestType": "3",
|
|
|
- // "QuestStem": "子类从父类那里继承什么方法和状态?",
|
|
|
- // "QuestAnswer": "",
|
|
|
- // "QuestChoice": "",
|
|
|
- // "Id": 39
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "QuestType": "0",
|
|
|
- // "QuestStem": "MyObject 的什么方法会对if表达式的正确性产生影响\n List l = new LinkedList();\n l.add(new MyObject(\"A\"));\n if(l.contains(new MyObject(\"A\"))){}",
|
|
|
- // "QuestAnswer": "equals ()",
|
|
|
- // "QuestChoice": "toString()||equals ()||hashCode()||clone()",
|
|
|
- // "Id": 36
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "QuestType": "1",
|
|
|
- // "QuestStem": "MyObject 的什么方法会对if表达式的正确性产生影响(多选) Map m = new HashMap; m.add(new MyObject(\"A\")); if(m.contains(new MyObject(\"A\"))){}",
|
|
|
- // "QuestAnswer": "equals ()||\nhashCode()||",
|
|
|
- // "QuestChoice": "toString()||\nequals ()||\nhashCode()||\nclone()||",
|
|
|
- // "Id": 38
|
|
|
- // },
|
|
|
- // {
|
|
|
- // "QuestType": "2",
|
|
|
- // "QuestStem": "1+1=2",
|
|
|
- // "QuestAnswer": "是",
|
|
|
- // "QuestChoice": "是||否",
|
|
|
- // "Id": 42
|
|
|
- // },
|
|
|
-
|
|
|
- // ];
|
|
|
- // let jsonArr = a.map(item => {
|
|
|
- // let json = {};
|
|
|
- // json.QuestType = item.QuestType;
|
|
|
- // json.id = item.Id;
|
|
|
- // json.QuestAnswer = item.QuestAnswer;
|
|
|
- // json.QuestStem = item.QuestStem;
|
|
|
- // if (item.QuestChoice) {
|
|
|
- // let arr = item.QuestChoice.split('||');
|
|
|
- // json.QuestChoice = arr;
|
|
|
- // }
|
|
|
- // return json;
|
|
|
- // })
|
|
|
- // this.setData({
|
|
|
- // questionList: jsonArr
|
|
|
- // })
|
|
|
-
|
|
|
- // }
|
|
|
onShow: function () {
|
|
|
- console.log("show0000000000000000000000000000000000000000000000000000000000000000000000");
|
|
|
- console.log(wx.getStorageSync('answersId'),"onshow 的 answeid");
|
|
|
- // console.log(wx.getStorageSync('questionList'+((wx.getStorageSync('answersId'))),"78978978979877777");
|
|
|
- if (wx.getStorageSync('questionList'+wx.getStorageSync('answersId'))) {
|
|
|
- console.log("缓村了锕");
|
|
|
- const questionList = wx.getStorageSync('questionList'+wx.getStorageSync('answersId'));
|
|
|
+ if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
|
|
|
+ const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
|
|
|
this.setData({
|
|
|
questionList: questionList,
|
|
|
- index: wx.getStorageSync('titleINDEX'+wx.getStorageSync('answersId')),
|
|
|
- answersId: wx.getStorageSync('answersId'+wx.getStorageSync('answersId')),
|
|
|
- chooseValue:wx.getStorageSync('chooseValue'+wx.getStorageSync('answersId')),
|
|
|
+ index: wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId')),
|
|
|
+ answersId: wx.getStorageSync('answersId' + wx.getStorageSync('answersId')),
|
|
|
+ chooseValue: wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId')),
|
|
|
})
|
|
|
- console.log(this.data.questionList,"show 缓存的数据");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.allShi(this.data.id, this.data.paperId, this.data.sessionKey);
|
|
|
- console.log(this.data.questionList,"show 没有缓存");
|
|
|
}
|
|
|
},
|
|
|
async onLoad(options) {
|
|
|
- // //const sessionKey = await tools.checkSessionAndLogin();
|
|
|
- // console.log("onload..................................");
|
|
|
- // wx.setStorageSync('answersId', options.answersId);
|
|
|
- // console.log(options.answersId,"传值的缓冲answersId");
|
|
|
- // console.log(wx.getStorageSync('answersId'),"1111111111111111111");
|
|
|
-
|
|
|
- // const sessionKey = 'yoa0rZTt2bAiTVDsiRjysw==';
|
|
|
- // this.setData({
|
|
|
- // sessionKey: sessionKey,
|
|
|
- // paperId:options.paperId,
|
|
|
- // answersId:options.answersId,
|
|
|
- // id:options.id,
|
|
|
- // })
|
|
|
- // console.log(wx.getStorageSync('answersId'),"onload中 的 answeid");
|
|
|
-
|
|
|
- // //....................
|
|
|
- // console.log(wx.getStorageSync('questionList'+wx.getStorageSync('answersId')),"111111111111111111111");
|
|
|
- // if (wx.getStorageSync('questionList'+wx.getStorageSync('answersId'))) {
|
|
|
- // this.setData({
|
|
|
- // questionList: wx.getStorageSync('questionList'+wx.getStorageSync('answersId')),
|
|
|
- // index: wx.getStorageSync('titleINDEX'+wx.getStorageSync('answersId')),
|
|
|
- // answersId: wx.getStorageSync('answersId'+wx.getStorageSync('answersId')),
|
|
|
- // chooseValue:wx.getStorageSync('chooseValue'+wx.getStorageSync('answersId')),
|
|
|
- // })
|
|
|
- // console.log("onload 有缓存");
|
|
|
- // console.log(this.data.questionList,"onload 有缓存的数据");
|
|
|
- // } else {
|
|
|
- // console.log("onload 没有缓存");
|
|
|
-
|
|
|
- // this.allShi(options.id, options.paperId, sessionKey);
|
|
|
- // }
|
|
|
- // //....................
|
|
|
-
|
|
|
const sessionKey = await tools.checkSessionAndLogin();
|
|
|
- //const sessionKey = 'BqQROCKCxn7R2NXdQLud9Q==';
|
|
|
- console.log("onloading.....................");
|
|
|
wx.setStorageSync('answersId', options.answersId);
|
|
|
this.setData({
|
|
|
sessionKey: sessionKey,
|
|
@@ -288,32 +142,20 @@ Page({
|
|
|
answersId: options.answersId,
|
|
|
id: options.id,
|
|
|
})
|
|
|
- console.log(options.answersId, "00000000000000000000000000");
|
|
|
- console.log(wx.getStorageSync('answersId'), "1111111111111");
|
|
|
if (wx.getStorageSync('questionList' + wx.getStorageSync('answersId'))) {
|
|
|
- console.log("缓村了锕");
|
|
|
const questionList = wx.getStorageSync('questionList' + wx.getStorageSync('answersId'));
|
|
|
- const titleINDEX = wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId'));
|
|
|
- const chooseValue = wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId'));
|
|
|
- console.log(titleINDEX,"打印下看看");
|
|
|
- console.log(chooseValue,"choosevalue");
|
|
|
+ const titleINDEX = wx.getStorageSync('titleINDEX' + wx.getStorageSync('answersId'));
|
|
|
+ const chooseValue = wx.getStorageSync('chooseValue' + wx.getStorageSync('answersId'));
|
|
|
this.setData({
|
|
|
questionList: questionList,
|
|
|
answersId: wx.getStorageSync('answersId'),
|
|
|
- chooseValue:chooseValue,
|
|
|
+ chooseValue: chooseValue,
|
|
|
index: titleINDEX
|
|
|
})
|
|
|
-
|
|
|
- console.log(this.data.questionList, "show 缓存的数据");
|
|
|
- console.log(this.data.index, "indexindex");
|
|
|
} else {
|
|
|
- console.log("无缓存");
|
|
|
this.allShi(options.id, options.paperId, sessionKey);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
-
|
|
|
allShi(id, paperId, sessionKey) {
|
|
|
wx.request({
|
|
|
url: app.globalData.publicUrl + '/wx/paper/detail',
|
|
@@ -372,14 +214,13 @@ Page({
|
|
|
this.setData({
|
|
|
questionList: jsonArr
|
|
|
})
|
|
|
- wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'),0);
|
|
|
- wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'),[]),
|
|
|
- wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
|
|
|
+ wx.setStorageSync('titleINDEX' + wx.getStorageSync('answersId'), 0);
|
|
|
+ wx.setStorageSync('chooseValue' + wx.getStorageSync('answersId'), []),
|
|
|
+ wx.setStorageSync('questionList' + wx.getStorageSync('answersId'), this.data.questionList);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
submitAll(currentAnswerTemp) {
|
|
|
- console.log();
|
|
|
wx.request({
|
|
|
url: app.globalData.publicUrl + '/wx/paper/commit',
|
|
|
method: "post",
|
|
@@ -389,20 +230,7 @@ Page({
|
|
|
answersId: wx.getStorageSync('answersId')
|
|
|
},
|
|
|
success: (res) => {
|
|
|
- console.log(res);
|
|
|
- // if (res.data.msg == '请勿重复提交') {
|
|
|
- // wx.showModal({
|
|
|
- // showCancel: false,
|
|
|
- // content: '当前老师批阅中,' + res.data.msg,
|
|
|
- // success(res) {}
|
|
|
- // })
|
|
|
- // } else {
|
|
|
if (res.data.code == 0) {
|
|
|
- console.log(res, "为我么我们微妙"); // 提交答案是后
|
|
|
- // this.setData({
|
|
|
- // answersId: res.data.answersId
|
|
|
- // })
|
|
|
- // this.allShi(id, paperId, sessionKey);
|
|
|
wx.showModal({
|
|
|
showCancel: false,
|
|
|
content: '恭喜您,提交答案成功,请耐心等待老师判卷',
|
|
@@ -412,23 +240,19 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- // wx.switchTab({
|
|
|
- // url: '/pages/testAnswer/testAnswer',
|
|
|
- // })
|
|
|
-
|
|
|
- } else {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: res.data.msg,
|
|
|
- success() {
|
|
|
- wx.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
}
|
|
|
+ // else {
|
|
|
+ // wx.showModal({
|
|
|
+ // showCancel: false,
|
|
|
+ // content: res.data.msg,
|
|
|
+ // success() {
|
|
|
+ // wx.navigateBack({
|
|
|
+ // delta: 1
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
})
|