You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.1 KiB

// pages/exercise_result/exercise_result.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
results: [],
page_status: 0,
error:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.exercise_id = options.exercise_id;
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
app.client.get_exercise_result({ exercise_id: this.exercise_id })
.then(res => {
this.setData({ error: "" })
console.log(res);
if (res.data.commit_results) {
let results = res.data.commit_results;
for (var result of results) {
if (result.ques_type == 4) {
for (var detail of result.ques_details) {
if (detail.choice_text == 1) detail.choice_text = "满分作答";
else if (detail.choice_text == 2) detail.choice_text = "部分得分作答";
else if (detail.choice_text == 3) detail.choice_text = "零分作答";
else if (detail.choice_text == 4) detail.choice_text = "未批";
}
}
if (result.ques_type == 3) {
for (var detail of result.ques_details) {
if (detail.choice_text == "wrong") detail.choice_text = "错误答案";
}
}
}
console.log(results);
this.setData({ results, page_status: 1 })
}
})
.catch(error => {
console.log(error);
this.setData({ error: error.message })
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})