From ff13d2e572045bd6af626ae58f699e96e7462de2 Mon Sep 17 00:00:00 2001 From: yuanke <249218296@qq.com> Date: Mon, 18 Jul 2016 14:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=A2=9E=E5=8A=A0=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E5=8F=91=E9=80=81=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=8F=91?= =?UTF-8?q?=E9=80=81=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/apis/courses.rb | 6 +++--- app/api/mobile/entities/attachment.rb | 8 ++++++++ app/api/mobile/entities/exercise.rb | 8 ++++++++ app/api/mobile/entities/homework.rb | 7 +++++++ app/controllers/wechats_controller.rb | 15 ++++++++------ config/menu.yml.test | 20 +++++++++++++------ public/assets/wechat/class.html | 6 +++--- public/assets/wechat/myresource.html | 6 +++--- .../javascripts/wechat/controllers/class.js | 9 +++++++-- .../wechat/controllers/send_class_list.js | 2 +- 10 files changed, 63 insertions(+), 24 deletions(-) diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb index aa1e573ed..1c6fd7008 100644 --- a/app/api/mobile/apis/courses.rb +++ b/app/api/mobile/apis/courses.rb @@ -217,7 +217,7 @@ module Mobile get "homeworks/:id" do cs = CoursesService.new homeworks = cs.homework_list params,current_user - present :data, homeworks, with: Mobile::Entities::Homework + present :data, homeworks, with: Mobile::Entities::Homework,user: current_user present :status, 0 end @@ -264,7 +264,7 @@ module Mobile post ":course_id/attachments" do cs = CoursesService.new count = cs.course_attachments params - present :data, count, with: Mobile::Entities::Attachment + present :data, count, with: Mobile::Entities::Attachment,user: current_user present :status, 0 end @@ -398,7 +398,7 @@ module Mobile course = Course.find(params[:course_id]) exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") - present :data,exercises,with:Mobile::Entities::Exercise + present :data,exercises,with:Mobile::Entities::Exercise,user: current_user present :status,0 end diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 49cb6bd2b..028ad633d 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -3,6 +3,7 @@ module Mobile class Attachment < Grape::Entity include Redmine::I18n include ActionView::Helpers::NumberHelper + include ApplicationHelper def self.attachment_expose(field) expose field do |f,opt| if f.is_a?(Hash) && f.key?(field) @@ -22,6 +23,7 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + end end end @@ -36,6 +38,12 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end end end end \ No newline at end of file diff --git a/app/api/mobile/entities/exercise.rb b/app/api/mobile/entities/exercise.rb index 05066f8a4..ce6a2fb39 100644 --- a/app/api/mobile/entities/exercise.rb +++ b/app/api/mobile/entities/exercise.rb @@ -27,6 +27,14 @@ module Mobile expose :exercise_name expose :exercise_description exercise_expose :coursename #所属班级名 + + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb index 3f1631c96..cea15ece9 100644 --- a/app/api/mobile/entities/homework.rb +++ b/app/api/mobile/entities/homework.rb @@ -98,6 +98,13 @@ module Mobile homework_expose :coursename #所属班级名 + expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| + current_user = options[:user] + current_user_is_teacher = false + current_user_is_teacher = is_course_teacher(current_user,instance.course) + current_user_is_teacher + end + end end end \ No newline at end of file diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index ea305d967..c72e04e14 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -78,12 +78,7 @@ class WechatsController < ActionController::Base end # When user view URL in the menu button on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| - uw = user_binded?(request[:FromUserName]) - unless uw - sendBind(request) - else - request.reply.text "#{request[:FromUserName]} view #{view}" - end + request.reply.text "#{request[:FromUserName]} view #{view}" end # When user sent the imsage @@ -147,6 +142,14 @@ class WechatsController < ActionController::Base default_msg(request) end + on :click, with: 'PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + + on :click, with: 'JOIN_PROJECT' do |request, key| + request.reply.text "此功能正在开发中,很快就会上线,谢谢!" + end + on :click, with: 'JOIN_CLASS' do |request, key| uw = user_binded?(request[:FromUserName]) unless uw diff --git a/config/menu.yml.test b/config/menu.yml.test index a43d72816..521ff290a 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -2,18 +2,22 @@ button: - type: "view" name: "我的动态" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=activities#wechat_redirect" - - name: "我的课程" + name: "我的群组" sub_button: - type: "view" - name: "课程" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + name: "我的课程" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=class_list#wechat_redirect" + - + type: "click" + name: "我的项目" + key: "PROJECT" - type: "view" - name: "资源" - url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://ucloudtest.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" + name: "我的宝库" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=myresource#wechat_redirect" - name: "更多" @@ -22,6 +26,10 @@ button: type: "click" name: "加入班级" key: "JOIN_CLASS" + - + type: "click" + name: "加入项目" + key: "JOIN_PROJECT" - type: "click" name: "反馈" diff --git a/public/assets/wechat/class.html b/public/assets/wechat/class.html index 2f9af6554..01628c2f4 100644 --- a/public/assets/wechat/class.html +++ b/public/assets/wechat/class.html @@ -23,7 +23,7 @@
-
{{r.filename}}发送
+
{{r.filename}}发送

暂无课件,
请登录Trustie网站,在PC浏览器中上传课件。

@@ -42,14 +42,14 @@
-
{{r.homework_name}}发送
+
{{r.homework_name}}发送

暂无作业,
请登录Trustie网站,在PC浏览器中上传作业。

-
{{r.exercise_name}}发送
+
{{r.exercise_name}}发送

暂无小测验,
请登录Trustie网站,在PC浏览器中上传小测验。

diff --git a/public/assets/wechat/myresource.html b/public/assets/wechat/myresource.html index 28fc69cc3..c06c57238 100644 --- a/public/assets/wechat/myresource.html +++ b/public/assets/wechat/myresource.html @@ -12,7 +12,7 @@
- {{r.filename}}发送
+ {{r.filename}}发送
大小:{{r.attafile_size}}
@@ -22,7 +22,7 @@ 请登录Trustie网站,在PC浏览器中上传课件。

-
{{r.homework_name}}发送
+
{{r.homework_name}}发送
@@ -32,7 +32,7 @@ 请登录Trustie网站,在PC浏览器中创建作业。

-
{{r.exercise_name}}发送
+
{{r.exercise_name}}发送
diff --git a/public/javascripts/wechat/controllers/class.js b/public/javascripts/wechat/controllers/class.js index cf2a3ee88..75e1709cc 100644 --- a/public/javascripts/wechat/controllers/class.js +++ b/public/javascripts/wechat/controllers/class.js @@ -1,4 +1,4 @@ -app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService', function($scope, config, $http, auth, $location, $routeParams,alertService){ +app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){ var vm = $scope; var courseid = $routeParams.id; @@ -104,13 +104,18 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location vm.homeworks = []; vm.exercises = []; + //发送类别 1课件 2作业 3测验 + vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1; + vm.alertService = alertService.create(); vm.invite = function(){ $location.path("/invite_code").search({id: courseid}); }; - vm.sendFile = function(r){ + vm.sendFile = function(r,index){ + vm.myresource_sendIndex = index; + rms.save('myresource_sendIndex',index); $location.path("/send_class_list").search({id: r.id}); } diff --git a/public/javascripts/wechat/controllers/send_class_list.js b/public/javascripts/wechat/controllers/send_class_list.js index c80943e39..1eabfa94c 100644 --- a/public/javascripts/wechat/controllers/send_class_list.js +++ b/public/javascripts/wechat/controllers/send_class_list.js @@ -46,7 +46,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co }).then(function(response){ console.log(response.data); if(response.data.status == 0){ - vm.alertService.showMessage('提示', '发送成功', function () { + vm.alertService.showMessage('发送成功', '题目已发送到目标班级的作业列表,但需要您访问Trustie网站设置发布和截止时间,以激活相应作业,谢谢!', function () { window.history.back(); }); } else {