|
|
@ -1,5 +1,5 @@
|
|
|
|
// pages/exercise_setting/exercise_setting.js
|
|
|
|
// pages/exercise_setting/exercise_setting.js
|
|
|
|
import { getNowFormatDate, getNowFormatTime} from "../../utils/dateutils"
|
|
|
|
import { getNowFormatDate, getNowFormatTime, getNextWeekFormatDate} from "../../utils/dateutils"
|
|
|
|
const app = getApp();
|
|
|
|
const app = getApp();
|
|
|
|
Page({
|
|
|
|
Page({
|
|
|
|
|
|
|
|
|
|
|
@ -7,23 +7,22 @@ Page({
|
|
|
|
* 页面的初始数据
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
exercise_id: null,
|
|
|
|
|
|
|
|
exercise: {},
|
|
|
|
exercise: {},
|
|
|
|
exercise_questions:[],
|
|
|
|
exercise_questions:[],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
start_publish: function(){
|
|
|
|
start_publish: function(){
|
|
|
|
if (!this.data.exercise_id) {
|
|
|
|
if (!this.exercise_id) {
|
|
|
|
console.error("请先保存试卷");
|
|
|
|
console.error("请先保存试卷");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log({
|
|
|
|
console.log({
|
|
|
|
course_id: this.course_id, exercise_ids: [this.data.exercise_id],
|
|
|
|
course_id: this.course_id, exercise_ids: [this.exercise_id],
|
|
|
|
end_time: getNowFormatDate() + " " + getNowFormatTime()
|
|
|
|
end_time: getNextWeekFormatDate() + " " + getNowFormatTime()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
let end_time = getNowFormatDate() + " " + getNowFormatTime();
|
|
|
|
let end_time = getNextWeekFormatDate() + " " + getNowFormatTime();
|
|
|
|
end_time = end_time.replace("-11", "-12");
|
|
|
|
//end_time = end_time.replace("-11", "-12");
|
|
|
|
app.client.publish_exercise({
|
|
|
|
app.client.publish_exercise({
|
|
|
|
course_id: this.course_id, exercise_ids: [this.data.exercise_id],
|
|
|
|
course_id: this.course_id, exercise_ids: [this.exercise_id],
|
|
|
|
end_time: end_time
|
|
|
|
end_time: end_time
|
|
|
|
}).then(res=>{
|
|
|
|
}).then(res=>{
|
|
|
|
console.log(res);
|
|
|
|
console.log(res);
|
|
|
@ -34,24 +33,53 @@ Page({
|
|
|
|
)
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
create_question: function(){
|
|
|
|
create_question: function(){
|
|
|
|
if(!this.data.exercise_id){
|
|
|
|
if(!this.exercise_id){
|
|
|
|
console.error("请先保存试卷");
|
|
|
|
console.error("请先保存试卷");
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '请先保存试卷',
|
|
|
|
|
|
|
|
icon:"none"
|
|
|
|
|
|
|
|
})
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
wx.navigateTo({
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `../question_setting/question_setting?exercise_id=${this.data.exercise_id}`,
|
|
|
|
url: `../question_setting/question_setting?exercise_id=${this.exercise_id}`,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
create_exercise: function({detail:{value}}){
|
|
|
|
create_exercise: function({detail:{value}}){
|
|
|
|
console.log(value);
|
|
|
|
console.log(value);
|
|
|
|
app.client.create_exercise({...value, course_id: this.course_id})
|
|
|
|
if(this.exercise_id){
|
|
|
|
.then(res=>{
|
|
|
|
app.client.update_exercise({...value, exercise_id: this.exercise_id})
|
|
|
|
console.log(res);
|
|
|
|
.then(res => {
|
|
|
|
this.setData({ exercise_id: res.data.data.exercise_id});
|
|
|
|
console.log(res);
|
|
|
|
})
|
|
|
|
wx.showToast({
|
|
|
|
.catch(error=>{
|
|
|
|
title: res.data.message,
|
|
|
|
console.error(error);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: error.toString(),
|
|
|
|
|
|
|
|
icon: "none"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
app.client.create_exercise({ ...value, course_id: this.course_id })
|
|
|
|
|
|
|
|
.then(res => {
|
|
|
|
|
|
|
|
console.log(res);
|
|
|
|
|
|
|
|
this.exercise_id = res.data.data.exercise_id
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: '创建成功',
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
|
|
title: error.toString(),
|
|
|
|
|
|
|
|
icon: "none"
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
@ -60,7 +88,7 @@ Page({
|
|
|
|
this.course_id = options.course_id;
|
|
|
|
this.course_id = options.course_id;
|
|
|
|
this.intent=options.intent;
|
|
|
|
this.intent=options.intent;
|
|
|
|
if(options.exercise_id){
|
|
|
|
if(options.exercise_id){
|
|
|
|
this.setData({exercise_id: options.exercise_id});
|
|
|
|
this.exercise_id = options.exercise_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -74,8 +102,8 @@ Page({
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
onShow: function () {
|
|
|
|
if(this.data.exercise_id){
|
|
|
|
if(this.exercise_id){
|
|
|
|
app.client.get_exercise_edit({exercise_id: this.data.exercise_id})
|
|
|
|
app.client.get_exercise_edit({exercise_id: this.exercise_id})
|
|
|
|
.then(res=>{
|
|
|
|
.then(res=>{
|
|
|
|
console.log(res);
|
|
|
|
console.log(res);
|
|
|
|
this.setData(
|
|
|
|
this.setData(
|
|
|
|