From 374aa9918c27167466ef7dc60699cf3b078fc61f Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 11 Jul 2016 14:49:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=88=91=E7=9A=84=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E9=87=8C=E9=9D=A2=E9=83=BD=E6=98=BE=E7=A4=BA=E6=9C=AA=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E7=9A=84=EF=BC=8C=E6=96=B0=E5=BB=BA=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=90=8E=E8=BF=94=E5=9B=9E=E4=BC=9A=E5=88=B7=E6=96=B0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/resources.rb | 10 ++++-- app/services/resources_service.rb | 36 +++++++++++++++++++ .../wechat/controllers/new_class.js | 6 ++-- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/app/api/mobile/apis/resources.rb b/app/api/mobile/apis/resources.rb index 6dfe8e599..9bd07a0d5 100644 --- a/app/api/mobile/apis/resources.rb +++ b/app/api/mobile/apis/resources.rb @@ -11,7 +11,9 @@ module Mobile end get do authenticate! - data = current_user.course_attachments + rs = ResourcesService.new + # data = current_user.course_attachments + data = rs.all_course_attachments current_user present :data, data, with: Mobile::Entities::Attachment present :status, 0 @@ -26,7 +28,8 @@ module Mobile get 'homeworks' do authenticate! - homeworks = current_user.homework_commons + rs = ResourcesService.new + homeworks = rs.all_homework_commons current_user present :data, homeworks, with: Mobile::Entities::Homework present :status, 0 @@ -40,7 +43,8 @@ module Mobile get 'exercies' do authenticate! - exercises = current_user.exercises + rs = ResourcesService.new + exercises = rs.all_exercises current_user present :data, exercises, with: Mobile::Entities::Exercise present :status, 0 end diff --git a/app/services/resources_service.rb b/app/services/resources_service.rb index a0fec585a..96034b4ce 100644 --- a/app/services/resources_service.rb +++ b/app/services/resources_service.rb @@ -50,4 +50,40 @@ class ResourcesService [@ori, @flag, @save_message] end + # 我的资源-课件 已发布的 + def all_course_attachments user + + courses = user.courses.not_deleted + + courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")" + + attchments = Attachment.where("(author_id = #{user.id} and is_publish = 1 and container_id in #{courses_ids} and container_type = 'Course') or (container_type = 'Course' and is_publish = 1 and container_id in #{courses_ids})" ).order("created_on desc") + + attchments + end + + # 我的资源-作业 已发布的 + def all_homework_commons user + + courses = user.courses.not_deleted + + courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")" + + homeworks = HomeworkCommon.where("course_id in #{courses_ids} and publish_time <= ?",Time.now.strftime("%Y-%m-%d")).order("created_at desc") + + homeworks + end + + # 我的资源-测验 已发布的 + def all_exercises user + + courses = user.courses.not_deleted + + courses_ids = courses.empty? ? '(-1)' :"(" + courses.map(&:id).join(",") + ")" + + exercises = Exercise.where("exercise_status <> 1 and course_id in #{courses_ids}").order("created_at desc") + + exercises + end + end \ No newline at end of file diff --git a/public/javascripts/wechat/controllers/new_class.js b/public/javascripts/wechat/controllers/new_class.js index ef46fc4ba..5e9f339a1 100644 --- a/public/javascripts/wechat/controllers/new_class.js +++ b/public/javascripts/wechat/controllers/new_class.js @@ -1,6 +1,6 @@ -app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location', function($scope, $http, auth, config, alertService, $location){ +app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'alertService','$location','rms', function($scope, $http, auth, config, alertService, $location,rms){ var vm = $scope; vm.alertService = alertService.create(); @@ -40,7 +40,9 @@ app.controller('NewClassController', ['$scope', '$http', 'auth', 'config', 'aler vm.alertService.showMessage('出错了', response.data.message); } else { vm.alertService.showMessage('提示', '新建课程成功', function(){ - window.history.back(); +// window.history.back(); + rms.save('syllabuses',[]); + $location.path("/class_list"); }); } console.log(response.data.data); From 70ed5790b8b8ffdcb031471e4fab70043c123a40 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 11 Jul 2016 16:46:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E8=AF=A6=E6=83=85=E7=82=B9=E8=B5=9E=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=92=8C=E7=82=B9=E8=B5=9E=E7=8A=B6=E6=80=81=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/wechat/class_list.html | 47 ++++++------- .../wechat/controllers/activity.js | 3 + public/javascripts/wechat/others/factory.js | 69 ++++++++++++++++++- 3 files changed, 93 insertions(+), 26 deletions(-) diff --git a/public/assets/wechat/class_list.html b/public/assets/wechat/class_list.html index 69a3db43c..dafce2cfc 100644 --- a/public/assets/wechat/class_list.html +++ b/public/assets/wechat/class_list.html @@ -1,34 +1,35 @@
暂无课件,
请登录Trustie网站,在PC浏览器中上传课件。
暂无作业,
请登录Trustie网站,在PC浏览器中创建作业。
暂无测验,
请登录Trustie网站,在PC浏览器中创建测验。