diff --git a/pages/courses/courses.wxml b/pages/courses/courses.wxml index 88076b2..b6cb196 100644 --- a/pages/courses/courses.wxml +++ b/pages/courses/courses.wxml @@ -1,9 +1,9 @@ - + - + 没有可以加入的课程了 diff --git a/pages/exercise_grade/exercise_grade.js b/pages/exercise_grade/exercise_grade.js index 9d80d43..fb8c451 100644 --- a/pages/exercise_grade/exercise_grade.js +++ b/pages/exercise_grade/exercise_grade.js @@ -6,7 +6,8 @@ Page({ * 页面的初始数据 */ data: { - grades:[] + grades:[], + page_status:0 }, /** @@ -17,7 +18,7 @@ Page({ app.client.get_exercise_grade({exercise_id: this.exercise_id}) .then(res=>{ console.log(res); - this.setData({ grades: res.data.exercise_users}) + this.setData({ grades: res.data.exercise_users, page_status: 1}) }) }, diff --git a/pages/exercise_grade/exercise_grade.json b/pages/exercise_grade/exercise_grade.json index 8835af0..4221b52 100644 --- a/pages/exercise_grade/exercise_grade.json +++ b/pages/exercise_grade/exercise_grade.json @@ -1,3 +1,4 @@ { - "usingComponents": {} + "usingComponents": {}, + "navigationBarTitleText": "分数列表" } \ No newline at end of file diff --git a/pages/exercise_grade/exercise_grade.wxml b/pages/exercise_grade/exercise_grade.wxml index bf66ac0..baa6a71 100644 --- a/pages/exercise_grade/exercise_grade.wxml +++ b/pages/exercise_grade/exercise_grade.wxml @@ -3,11 +3,11 @@ {{grade.user_name}} - {{grade.score||'--'}} + {{grade.score==0?grade.score:grade.score||'--'}} - + 分数未公布 diff --git a/pages/exercise_setting/exercise_setting.js b/pages/exercise_setting/exercise_setting.js index f3af882..d0c4cd1 100644 --- a/pages/exercise_setting/exercise_setting.js +++ b/pages/exercise_setting/exercise_setting.js @@ -1,5 +1,5 @@ // pages/exercise_setting/exercise_setting.js -import { getNowFormatDate, getNowFormatTime} from "../../utils/dateutils" +import { getNowFormatDate, getNowFormatTime, getNextWeekFormatDate} from "../../utils/dateutils" const app = getApp(); Page({ @@ -7,23 +7,22 @@ Page({ * 页面的初始数据 */ data: { - exercise_id: null, exercise: {}, exercise_questions:[], }, start_publish: function(){ - if (!this.data.exercise_id) { + if (!this.exercise_id) { console.error("请先保存试卷"); return; } console.log({ - course_id: this.course_id, exercise_ids: [this.data.exercise_id], - end_time: getNowFormatDate() + " " + getNowFormatTime() + course_id: this.course_id, exercise_ids: [this.exercise_id], + end_time: getNextWeekFormatDate() + " " + getNowFormatTime() }); - let end_time = getNowFormatDate() + " " + getNowFormatTime(); - end_time = end_time.replace("-11", "-12"); + let end_time = getNextWeekFormatDate() + " " + getNowFormatTime(); + //end_time = end_time.replace("-11", "-12"); 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 }).then(res=>{ console.log(res); @@ -34,24 +33,53 @@ Page({ ) }, create_question: function(){ - if(!this.data.exercise_id){ + if(!this.exercise_id){ console.error("请先保存试卷"); + wx.showToast({ + title: '请先保存试卷', + icon:"none" + }) return; } 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}}){ console.log(value); - app.client.create_exercise({...value, course_id: this.course_id}) - .then(res=>{ - console.log(res); - this.setData({ exercise_id: res.data.data.exercise_id}); - }) - .catch(error=>{ - console.error(error); - }); + if(this.exercise_id){ + app.client.update_exercise({...value, exercise_id: this.exercise_id}) + .then(res => { + console.log(res); + wx.showToast({ + title: res.data.message, + }) + }) + .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.intent=options.intent; if(options.exercise_id){ - this.setData({exercise_id: options.exercise_id}); + this.exercise_id = options.exercise_id; } }, @@ -74,8 +102,8 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - if(this.data.exercise_id){ - app.client.get_exercise_edit({exercise_id: this.data.exercise_id}) + if(this.exercise_id){ + app.client.get_exercise_edit({exercise_id: this.exercise_id}) .then(res=>{ console.log(res); this.setData( diff --git a/pages/exercise_setting/exercise_setting.wxml b/pages/exercise_setting/exercise_setting.wxml index 4289961..ad55efe 100644 --- a/pages/exercise_setting/exercise_setting.wxml +++ b/pages/exercise_setting/exercise_setting.wxml @@ -16,7 +16,7 @@ - + 第{{question.q_position}}题 diff --git a/pages/exercises/exercises.wxss b/pages/exercises/exercises.wxss index 3837931..e32a90c 100644 --- a/pages/exercises/exercises.wxss +++ b/pages/exercises/exercises.wxss @@ -42,6 +42,11 @@ text.start-answer{ position: fixed; right: 8rpx; } +text.edit-exercise{ + position: fixed; + right: 8rpx; +} + .exercise{ background: white; padding: 15rpx 15rpx; @@ -65,12 +70,13 @@ text.start-answer{ view.no-content{ display: flex; - flex-direction: column; + flex-direction: row; + justify-content: center; } image.no-content{ - width: 300rpx; - height: 300rpx; + width: 200rpx; + height: 200rpx; } .require-login{ diff --git a/pages/question_setting/question_setting.js b/pages/question_setting/question_setting.js index 131c92b..d403c68 100644 --- a/pages/question_setting/question_setting.js +++ b/pages/question_setting/question_setting.js @@ -11,13 +11,23 @@ Page({ create_question: function({detail:{value}}){ console.log(value); let data = { - question_title:value.question_title,question_type:0,question_score:5,question_choices:[value.question_choices_0, value.question_choices_1, value.question_choices_2, value.question_choices_3],standard_answers:value.standard_answers} + question_title:value.question_title, + question_type:0, + question_score:5, + question_choices:[value.question_choices_0, value.question_choices_1, value.question_choices_2, value.question_choices_3], + standard_answers:value.standard_answers + } app.client.create_question({exercise_id: this.exercise_id, data}) .then(res=>{ console.log(res); wx.navigateBack({ delta: 1 }) + }).catch(error=>{ + wx.showToast({ + title: error.toString(), + icon: "none" + }) }) }, /** diff --git a/pages/question_setting/question_setting.wxml b/pages/question_setting/question_setting.wxml index 1dccbb0..e202a4c 100644 --- a/pages/question_setting/question_setting.wxml +++ b/pages/question_setting/question_setting.wxml @@ -5,10 +5,10 @@ - + - \ No newline at end of file + diff --git a/utils/dateutils.js b/utils/dateutils.js index 6483c3e..3b2fe99 100644 --- a/utils/dateutils.js +++ b/utils/dateutils.js @@ -14,6 +14,22 @@ export function getNowFormatDate() { return currentdate; } +export function getNextWeekFormatDate(){ + var now = new Date(); + var date = new Date(now.getTime() + 7 * 24 * 3600 * 1000); + var seperator1 = "-"; + var year = date.getFullYear(); + var month = date.getMonth() + 1; + var strDate = date.getDate(); + if (month >= 1 && month <= 9) { + month = "0" + month; + } + if (strDate >= 0 && strDate <= 9) { + strDate = "0" + strDate; + } + var currentdate = year + seperator1 + month + seperator1 + strDate; + return currentdate; +} export function getNowFormatTime(){ var now = new Date(); var hour = now.getHours();//得到小时