From e620d7248b8e291f3f6630e5e7bf164620e77ea1 Mon Sep 17 00:00:00 2001 From: educoder_weapp Date: Sat, 16 Nov 2019 16:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=95=E5=8D=B7=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=BB=9F=E8=AE=A1=E7=BB=93=E6=9E=9C=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- app.json | 21 ++-- data/client.js | 23 +++++ data/eduapi.js | 22 +++++ images/invite.png | Bin 0 -> 5125 bytes pages/about/about.js | 3 +- pages/course/course.js | 23 ++++- pages/course/course.wxml | 8 +- pages/course_invite/course_invite.js | 110 +++++++++++++++++++++ pages/course_invite/course_invite.json | 3 + pages/course_invite/course_invite.wxml | 13 +++ pages/course_invite/course_invite.wxss | 1 + pages/exercise_result/exercise_result.js | 99 +++++++++++++++++++ pages/exercise_result/exercise_result.json | 4 + pages/exercise_result/exercise_result.wxml | 44 +++++++++ pages/exercise_result/exercise_result.wxss | 1 + pages/exercise_setting/exercise_setting.js | 7 +- pages/exercises/exercises.js | 5 + pages/exercises/exercises.wxml | 8 +- 19 files changed, 370 insertions(+), 29 deletions(-) create mode 100644 images/invite.png create mode 100644 pages/course_invite/course_invite.js create mode 100644 pages/course_invite/course_invite.json create mode 100644 pages/course_invite/course_invite.wxml create mode 100644 pages/course_invite/course_invite.wxss create mode 100644 pages/exercise_result/exercise_result.js create mode 100644 pages/exercise_result/exercise_result.json create mode 100644 pages/exercise_result/exercise_result.wxml create mode 100644 pages/exercise_result/exercise_result.wxss 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 0000000000000000000000000000000000000000..d7b75a75db8999060aa95a21d36059b2b0115c54 GIT binary patch literal 5125 zcmbVQWmFVU(s#i6z;G}K4}-zrqPR2~gX@OAFB^@)wL-(uU=S`127%tg zJ8-4HudWY{F5qYk7z~EIL*qKB=%%9K;N{hWh3|X5A$60}TWB<{2O0zdKeI2~*gDEC z`fTY^BCZ(6^&pb{e)!JrDJ~BN!*O%qU|ehP+4*Gy`ddxoS48C~295qUhrPvM6rLtm z)P4zsG`jnvo_m$syO;jE3&*5ne}bdYPmD8Vm6Ap#)_VHCqj4bN@Ubr&==NC<4lf)h z;HbEdXgFwSY_+|60gi(U$Cctx;Y@gJN*B(*MZ@vHuia*a*AHC3j)JGKktz@nw_-Foa;t=!$NTMo8ia2&Q z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L1D!uDQ9rXjkb;fVy6Cj7gC zd8`GaZFu0sVb~TO&j!o_BI?;`CzQOT+D>@gnbq3uND^X5Xt2Yd&X)qQfmYVhO=JfN z2FZ#c6pp$`^_>qFXMFp-L_TW6f`Y8aq(D1GTcT5+18&61&a&k=T!e{GXV_n*{^VqO zZLQT`E0*p^Q$OGmI!bQN@dAY%)>IQu*xJjAP2h(k*atjK9}k1 z3v$&f-N=ZzF9Ye`NWQb=2xpxi%NXv{;v>W097aPAJ_A7?USFkwD+|^NT`~P8{}Xeu zMx`6mv4n9UhVqPAr}^clU|r?*lDB>@Rs{Dq><4E(>HEeb!kqSu3Qul{NfKAO!#j?? z{nPh$x~7FKa2KjU(J8}8qS?tPal^5-rW4h{z-6Yo2mursL}uDYH8>{ Ju2pl0{69Mf-6sG5 literal 0 HcmV?d00001 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}} + 进入答题 查看答题 编辑