diff --git a/README.md b/README.md index 169190d..b27212c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ educoder微信小程序,帮助使用[educoder平台](https://www.educoder.net) [https://github/jinke18/smart_class](https://github.com/jinke18/smart_class) ## 小程序码 -![小程序码](./images/weapp_code.png) +![小程序码](/images/weapp_code.png) # 功能介绍 @@ -34,7 +34,7 @@ educoder微信小程序,帮助使用[educoder平台](https://www.educoder.net) - 试卷截止后并且老师选择了公开答案,学生可以看到公布的答案 -- 老师可以创建试卷,发布试卷,查看学员作答分数(developing) +- 老师可以创建试卷,发布试卷,查看学员作答分数 ## 其他 账号的注册、登陆、找回密码、头像更改等 diff --git a/app.json b/app.json index bd1752a..2d2fceb 100644 --- a/app.json +++ b/app.json @@ -2,8 +2,7 @@ "pages": [ "pages/my_courses/my_courses", "pages/findmore/findmore", - "pages/exercise_setting/exercise_setting", - + "pages/exercise_setting/exercise_setting", "pages/login/login", "pages/course_setting/course_setting", "pages/exercises/exercises", @@ -19,7 +18,10 @@ "pages/reset_password/reset_password", "pages/image_crop/image_crop", "pages/question_setting/question_setting", - "pages/exercise_grade/exercise_grade" + "pages/exercise_grade/exercise_grade", + "pages/course_invite/course_invite", + "pages/exercise_result/exercise_result" + ], "window": { "backgroundTextStyle": "dark", @@ -37,19 +39,18 @@ "iconPath": "images/tabbar-icon/tabbar_study_default.png", "selectedIconPath": "images/tabbar-icon/tabbar_study_pressed.png" }, - { "pagePath": "pages/courses/courses", "text": "课程列表", "iconPath": "images/tabbar-icon/tabbar_contact_default.png", "selectedIconPath": "images/tabbar-icon/tabbar_contact_pressed.png" }, - { - "pagePath": "pages/findmore/findmore", - "text": "发现", - "iconPath": "images/tabbar-icon/tabbar_findmore_default.png", - "selectedIconPath": "images/tabbar-icon/tabbar_findmore_pressed.png" - }, + { + "pagePath": "pages/findmore/findmore", + "text": "发现", + "iconPath": "images/tabbar-icon/tabbar_findmore_default.png", + "selectedIconPath": "images/tabbar-icon/tabbar_findmore_pressed.png" + }, { "pagePath": "pages/setting/setting", "iconPath": "images/tabbar-icon/tabbar_settings_default.png", diff --git a/data/client.js b/data/client.js index 7627593..5db587a 100644 --- a/data/client.js +++ b/data/client.js @@ -608,6 +608,29 @@ export class Client{ }) }) } + /** + * @todo change limit default 10 + */ + get_exercise_result({ exercise_id, sort = "asc", page = 1, limit=50, success, fail, complete}){ + return new Promise((resolve, reject)=>{ + Exercise.get_result({ + session: this.session, + exercise_id, sort, page, limit, + success: res => { + if (typeof success == "function") { + success(res); + } + resolve(res); + }, + fail: error => { + if (typeof fail == "function") { + fail(error); + } + reject(error); + } + }) + }) + } get_exercise_grade({exercise_id,order="end_at", search="", success, fail, complete}){ return new Promise((resolve, reject) => { Exercise.get_grade({ diff --git a/data/eduapi.js b/data/eduapi.js index 25504c2..428e71f 100644 --- a/data/eduapi.js +++ b/data/eduapi.js @@ -420,6 +420,28 @@ export class Exercise{ complete: complete }) } + /**@todo limit change */ + static get_result({session, exercise_id, sort="asc", page=1, limit=50,success, fail, complete}){ + let data={sort, page, limit}; + session.request({ + url: api_base_url +`/exercises/${exercise_id}/exercise_result.json`, + method: "GET", + data, + success(res) { + if ("status" in res.data) { + if (res.data.status < 0) { + fail(new Error(res.data.message)); + return; + } + } + if (typeof success == "function") { + success(res); + } + }, + fail: fail, + complete: complete + }) + } static publish({session,course_id, exercise_ids, end_time, success, fail, complete}){ let data = {check_ids: exercise_ids, end_time}; session.request({ diff --git a/images/invite.png b/images/invite.png new file mode 100644 index 0000000..d7b75a7 Binary files /dev/null and b/images/invite.png differ diff --git a/pages/about/about.js b/pages/about/about.js index 348927c..4bbfd63 100644 --- a/pages/about/about.js +++ b/pages/about/about.js @@ -6,7 +6,8 @@ Page({ /** * 页面的初始数据 */ - md: '# 简介\neducoder微信小程序,帮助使用[educoder平台](https://www.educoder.net)的应用,方便在手机上使用。利用educoder网站的API搭建\n\n## 源码\n[https://github/jinke18/smart_class](https://github.com/jinke18/smart_class)\n\n## 小程序码\n![小程序码](../../images/weapp_code.png)\n\n\n# 功能介绍\n\n## 教室\n- 学员可以输入邀请码进入课堂\n\n- 进入教室界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像\n\n- 教员在教室界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作\n\n- 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答”\n\n- 教室内有讨论区,可以交流\n\n## 课程资源\n\n- 在课程界面进入“资源”可以查看本课堂的课程文件资源\n\n- 支持打开ppt doc xls pdf文件\n\n## 试卷作答\n\n- 学员在课程内可以看到老师发布的试卷,并且回答\n\n- 试卷截止后可以学生可以看到公布的答案', + md: '# 简介\neducoder微信小程序,帮助使用[educoder平台](https://www.educoder.net)的应用,方便在手机上使用。利用educoder网站的API搭建\n\n## 源码\n[https://github/jinke18/smart_class](https://github.com/jinke18/smart_class)\n\n## 小程序码\n![小程序码](/images/weapp_code.png)\n\n# 功能介绍\n\n## 教室\n- 学员可以输入邀请码进入课堂\n\n- 进入教室界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像\n\n- 教员在教室界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作\n\n- 在分数列表中可以看到加减分记录(数据在后台可以导出)\n\n- 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答”\n\n- 教室内有讨论区,可以交流\n\n## 课程资源\n\n- 在课程界面进入“资源”可以查看本课堂的课程文件资源\n\n- 支持打开ppt doc xls pdf文件\n\n## 试卷作答\n\n- 学员在课程内可以看到老师发布的试卷,并且回答\n\n- 试卷截止后并且老师选择了公开答案,学生可以看到公布的答案\n\n- 老师可以创建试卷,发布试卷,查看学员作答分数(developing)\n\n## 其他\n账号的注册、登陆、找回密码、头像更改等\n\n# 实现\n## educoder平台接入\n使用HTTP与平台的api接口交互\n\n接口列表如下\n- 搜索课堂https://www.educoder.net/api/courses.json\n\n- 查询用户的课堂https://www.educoder.net/api/users//courses.json\n\n- 查询学校https://www.educoder.net/api/schools/school_list.json\n\n- 新建课堂https://www.educoder.net/api/courses.json\n\n- 加入课堂https://www.educoder.net/api/courses/apply_to_join_course.json\n\n- 新建试卷https://www.educoder.net/api/courses//exercises/new.json\n\n- 查询试卷https://www.educoder.net/api/courses//exercises.json\n\n- 班级文件资源https://www.educoder.net/api/files.json\n\n# 教室学员在位情况及分数的同步实现\n使用了[leancloud](https://www.leancloud.cn/)提供的javascript开发包实现数据同步功能, 如学员在位情况、分数的同步, 其底部技术为websocket' +, data: { article: {} diff --git a/pages/course/course.js b/pages/course/course.js index b476af4..fa2c211 100644 --- a/pages/course/course.js +++ b/pages/course/course.js @@ -1,4 +1,5 @@ // pages/course_detail/course_detail.js +const app = getApp(); Page({ /** @@ -39,7 +40,8 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - this.setData({"course.id": options.course_id}) + this.course_id = options.course_id; + this.setData({course_id: options.course_id}) if(options.course_name && options.course_name!="undefined"){ wx.setNavigationBarTitle({ title: options.course_name @@ -59,7 +61,11 @@ Page({ * 生命周期函数--监听页面显示 */ onShow: function () { - + app.client.get_course_info({course_id: this.course_id}) + .then(res=>{ + console.log(res); + this.setData({course: res.data}); + }); }, /** @@ -93,7 +99,16 @@ Page({ /** * 用户点击右上角分享 */ - onShareAppMessage: function () { - + onShareAppMessage: function (options) { + let course = this.data.course; + let next_week_time = new Date().getTime()+7*24*3600*1000; + let current_user = app.client.current_user; + if(options.from=="button"){ + return{ + path: `/pages/course_invite/course_invite?course_id=${this.course_id}&invite_code=${course.invite_code}&deadline=${next_week_time}&course_name=${course.name}&inviter=${current_user.real_name}&avatar_url=https://www.educoder.net/images/${current_user.image_url}`, + imageUrl:"/images/invite.png", + title: "课堂邀请--"+course.name + } + } } }) \ No newline at end of file diff --git a/pages/course/course.wxml b/pages/course/course.wxml index 31ad5d0..b8dbb16 100644 --- a/pages/course/course.wxml +++ b/pages/course/course.wxml @@ -1,5 +1,6 @@ + {{course.name}} @@ -7,8 +8,9 @@ - 进入教室 - 试卷 - 资源 + 进入教室 + 试卷 + 资源 + \ No newline at end of file diff --git a/pages/course_invite/course_invite.js b/pages/course_invite/course_invite.js new file mode 100644 index 0000000..b77baea --- /dev/null +++ b/pages/course_invite/course_invite.js @@ -0,0 +1,110 @@ +// pages/course_join/course_invite.js +const app = getApp(); +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + + join_course: function(event) { + const { invite_code, identities } = this.data; + let data = { invite_code: invite_code, student: 1}; + console.log(data); + console.log({ ...data }); + app.client.join_course({ ...data }) + .then(res => { + if (res.data.status == 401) { + wx.showToast({ + title: "请先登陆", + icon: "none" + }); + wx.navigateTo({ + url: '../login/login', + }) + return; + } + console.log(res); + wx.showToast({ + title: res.data.message + }) + wx.navigateTo({ + url: "../course/course?course_id=" + res.data.course_id + }); + }) + .catch(error => { + wx.showToast({ + title: error.toString(), + icon: "none" + }); + console.warn(error); + }) + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + console.log(options); + this.invite_code = options.invite_code; + this.deadline = options.deadline; + this.inviter = options.inviter; + this.course_name = options.course_name; + this.setData(options); + let current_time = new Date().getTime(); + this.setData({current_time: current_time}); + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () { + + } +}) \ No newline at end of file diff --git a/pages/course_invite/course_invite.json b/pages/course_invite/course_invite.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/course_invite/course_invite.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/course_invite/course_invite.wxml b/pages/course_invite/course_invite.wxml new file mode 100644 index 0000000..d4b8c42 --- /dev/null +++ b/pages/course_invite/course_invite.wxml @@ -0,0 +1,13 @@ + + + + \n{{inviter}}\n + 邀请你加入课程\n + {{course_name}}\n + + + + 该邀请链接已失效 + + diff --git a/pages/course_invite/course_invite.wxss b/pages/course_invite/course_invite.wxss new file mode 100644 index 0000000..f352e92 --- /dev/null +++ b/pages/course_invite/course_invite.wxss @@ -0,0 +1 @@ +/* pages/course_join/course_invite.wxss */ \ No newline at end of file diff --git a/pages/exercise_result/exercise_result.js b/pages/exercise_result/exercise_result.js new file mode 100644 index 0000000..7b6fcd1 --- /dev/null +++ b/pages/exercise_result/exercise_result.js @@ -0,0 +1,99 @@ +// 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; + this.exercise_id = 2996; + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + 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 () { + + } +}) \ No newline at end of file diff --git a/pages/exercise_result/exercise_result.json b/pages/exercise_result/exercise_result.json new file mode 100644 index 0000000..e4ea3bc --- /dev/null +++ b/pages/exercise_result/exercise_result.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "试卷结果" +} \ No newline at end of file diff --git a/pages/exercise_result/exercise_result.wxml b/pages/exercise_result/exercise_result.wxml new file mode 100644 index 0000000..bdbfcf4 --- /dev/null +++ b/pages/exercise_result/exercise_result.wxml @@ -0,0 +1,44 @@ + + + 结果未公布 + + + {{error}} + + + + + + 第{{result.ques_position}}题 + {{result.ques_title}} + {{result.effictive_counts||0}}人作答 + 正确率:{{result.right_percent}}% + + + + + + {{detail.choice_text}} + {{detail.choice_users_count}}人 + + + + + + + + + {{detail.choice_text}} + {{detail.choice_users_count}}人 + + + + + + 暂不支持此类题目 + + + + + + \ No newline at end of file diff --git a/pages/exercise_result/exercise_result.wxss b/pages/exercise_result/exercise_result.wxss new file mode 100644 index 0000000..b8287df --- /dev/null +++ b/pages/exercise_result/exercise_result.wxss @@ -0,0 +1 @@ +/* pages/exercise_result/exercise_result.wxss */ \ No newline at end of file diff --git a/pages/exercise_setting/exercise_setting.js b/pages/exercise_setting/exercise_setting.js index d0c4cd1..018b150 100644 --- a/pages/exercise_setting/exercise_setting.js +++ b/pages/exercise_setting/exercise_setting.js @@ -143,10 +143,5 @@ Page({ }, - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } + }) \ No newline at end of file diff --git a/pages/exercises/exercises.js b/pages/exercises/exercises.js index 306378a..38f2591 100644 --- a/pages/exercises/exercises.js +++ b/pages/exercises/exercises.js @@ -53,6 +53,11 @@ Page({ currentTab: 0, navScrollLeft: 0 }, + exercise_result: function ({ currentTarget: { dataset } }){ + wx.navigateTo({ + url: `../exercise_result/exercise_result?exercise_id=${dataset.exercise_id}`, + }) + }, see_grade: function({currentTarget:{dataset}}){ wx.navigateTo({ url: `../exercise_grade/exercise_grade?exercise_id=${dataset.exercise_id}`, diff --git a/pages/exercises/exercises.wxml b/pages/exercises/exercises.wxml index 33d9bae..26e7bbc 100644 --- a/pages/exercises/exercises.wxml +++ b/pages/exercises/exercises.wxml @@ -23,13 +23,15 @@ - + - {{exercise.exercise_name}} + {{exercise.exercise_name}} 还有{{exercise.exercise_left_time||' '}}截止 - {{exercise.exercise_tips[0]}} + + {{exercise_tip}} + 进入答题 查看答题 编辑