微信增加作业发送,修改发送的权限,修改菜单

weixin_guange
yuanke 9 years ago
parent f3d74fcd55
commit ff13d2e572

@ -217,7 +217,7 @@ module Mobile
get "homeworks/:id" do get "homeworks/:id" do
cs = CoursesService.new cs = CoursesService.new
homeworks = cs.homework_list params,current_user 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 present :status, 0
end end
@ -264,7 +264,7 @@ module Mobile
post ":course_id/attachments" do post ":course_id/attachments" do
cs = CoursesService.new cs = CoursesService.new
count = cs.course_attachments params 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 present :status, 0
end end
@ -398,7 +398,7 @@ module Mobile
course = Course.find(params[:course_id]) course = Course.find(params[:course_id])
exercises = course.exercises.where("exercise_status <> 1").order("created_at desc") 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 present :status,0
end end

@ -3,6 +3,7 @@ module Mobile
class Attachment < Grape::Entity class Attachment < Grape::Entity
include Redmine::I18n include Redmine::I18n
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include ApplicationHelper
def self.attachment_expose(field) def self.attachment_expose(field)
expose field do |f,opt| expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field) if f.is_a?(Hash) && f.key?(field)
@ -22,6 +23,7 @@ module Mobile
(number_to_human_size(f.filesize)).gsub("ytes", "").to_s (number_to_human_size(f.filesize)).gsub("ytes", "").to_s
when :coursename when :coursename
f.course.nil? ? "" : f.course.name f.course.nil? ? "" : f.course.name
end end
end end
end end
@ -36,6 +38,12 @@ module Mobile
attachment_expose :file_dir attachment_expose :file_dir
attachment_expose :attafile_size attachment_expose :attafile_size
attachment_expose :coursename #所属班级名 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 end
end end

@ -27,6 +27,14 @@ module Mobile
expose :exercise_name expose :exercise_name
expose :exercise_description expose :exercise_description
exercise_expose :coursename #所属班级名 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 end
end end

@ -98,6 +98,13 @@ module Mobile
homework_expose :coursename #所属班级名 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 end
end end

@ -78,12 +78,7 @@ class WechatsController < ActionController::Base
end end
# When user view URL in the menu button # When user view URL in the menu button
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
uw = user_binded?(request[:FromUserName]) request.reply.text "#{request[:FromUserName]} view #{view}"
unless uw
sendBind(request)
else
request.reply.text "#{request[:FromUserName]} view #{view}"
end
end end
# When user sent the imsage # When user sent the imsage
@ -147,6 +142,14 @@ class WechatsController < ActionController::Base
default_msg(request) default_msg(request)
end 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| on :click, with: 'JOIN_CLASS' do |request, key|
uw = user_binded?(request[:FromUserName]) uw = user_binded?(request[:FromUserName])
unless uw unless uw

@ -2,18 +2,22 @@ button:
- -
type: "view" type: "view"
name: "我的动态" 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: sub_button:
- -
type: "view" type: "view"
name: "课程" 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" 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" type: "view"
name: "资源" 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" 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: "更多" name: "更多"
@ -22,6 +26,10 @@ button:
type: "click" type: "click"
name: "加入班级" name: "加入班级"
key: "JOIN_CLASS" key: "JOIN_CLASS"
-
type: "click"
name: "加入项目"
key: "JOIN_PROJECT"
- -
type: "click" type: "click"
name: "反馈" name: "反馈"

@ -23,7 +23,7 @@
</div> </div>
<div ng-class="{'undis': !showResources}"> <div ng-class="{'undis': !showResources}">
<div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in resources|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2" ng-click="sendFile(r,1)">发送</a><div class="cl"></div></div>
<p ng-show="resources_tag == true && resources.length<=0" class="class-test-tip">暂无课件,<br /> <p ng-show="resources_tag == true && resources.length<=0" class="class-test-tip">暂无课件,<br />
请登录Trustie网站在PC浏览器中上传课件。</p> 请登录Trustie网站在PC浏览器中上传课件。</p>
</div> </div>
@ -42,14 +42,14 @@
</div> </div>
<div ng-class="{'undis': !showHomework}"> <div ng-class="{'undis': !showHomework}">
<div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in homeworks|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 " ng-click="sendFile(r,2)">发送</a><div class="cl"></div></div>
<p ng-show="homeworks_tag == true && homeworks.length<=0" class="class-test-tip">暂无作业,<br /> <p ng-show="homeworks_tag == true && homeworks.length<=0" class="class-test-tip">暂无作业,<br />
请登录Trustie网站在PC浏览器中上传作业。</p> 请登录Trustie网站在PC浏览器中上传作业。</p>
</div> </div>
<div ng-class="{'undis': !showTestcase}"> <div ng-class="{'undis': !showTestcase}">
<div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r)">发送</a><div class="cl"></div></div> <div ng-repeat="r in exercises|filter:searchText" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="isTeacher" herf="javascript:void(0);" class="fr mr10 link-blue2 undis" ng-click="sendFile(r,3)">发送</a><div class="cl"></div></div>
<p ng-show="exercises_tag == true && exercises.length<=0" class="class-test-tip">暂无小测验,<br /> <p ng-show="exercises_tag == true && exercises.length<=0" class="class-test-tip">暂无小测验,<br />
请登录Trustie网站在PC浏览器中上传小测验。</p> 请登录Trustie网站在PC浏览器中上传小测验。</p>
</div> </div>

@ -12,7 +12,7 @@
<div ng-class="{'undis': currentTab!=1}"> <div ng-class="{'undis': currentTab!=1}">
<div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"> <div ng-repeat="r in resources|filter:{filename:searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]">
<img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-click="sendFile(r,1)" class="fr mr10 link-blue2">发送</a><div class="cl"></div> <img src="/images/wechat/courseware.png" width="15" class="ml10 fl" /> <span class="fl ml10 resource-width">{{r.filename}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,1)" class="fr mr10 link-blue2">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 fl courseware-from-width hidden">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4 fl">大小:{{r.attafile_size}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 fl courseware-from-width hidden">课件来源:{{r.coursename}}</span><span class="f12 ml10 mt5 c-grey4 fl">大小:{{r.attafile_size}}</span><div class="cl"></div>
</div> </div>
<div ng-if="has_more"> <div ng-if="has_more">
@ -22,7 +22,7 @@
请登录Trustie网站在PC浏览器中上传课件。</p> 请登录Trustie网站在PC浏览器中上传课件。</p>
</div> </div>
<div ng-class="{'undis': currentTab!=2}"> <div ng-class="{'undis': currentTab!=2}">
<div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-click="sendFile(r,2)" class="fr mr10 link-blue2 ">发送</a><div class="cl"></div> <div ng-repeat="r in homeworks|filter:{homework_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/homework.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.homework_name}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,2)" class="fr mr10 link-blue2 ">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 fl other-from-width hidden">作业来源:{{r.coursename}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 fl other-from-width hidden">作业来源:{{r.coursename}}</span><div class="cl"></div>
</div> </div>
<div ng-if="homework_has_more"> <div ng-if="homework_has_more">
@ -32,7 +32,7 @@
请登录Trustie网站在PC浏览器中创建作业。</p> 请登录Trustie网站在PC浏览器中创建作业。</p>
</div> </div>
<div ng-class="{'undis': currentTab!=3}"> <div ng-class="{'undis': currentTab!=3}">
<div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-click="sendFile(r,3)" class="fr mr10 link-blue2 undis">发送</a><div class="cl"></div> <div ng-repeat="r in exercise|filter:{exercise_name: searchText}" ng-class="['class-detail-row', 'f13', 'c-grey3', {'border-top': $first}]"><img src="/images/wechat/test.png" width="15" class="ml10 fl" /><span class="fl ml10 resource-width">{{r.exercise_name}}</span><a ng-show="r.current_user_is_teacher" ng-click="sendFile(r,3)" class="fr mr10 link-blue2 undis">发送</a><div class="cl"></div>
<span class="f12 mt5 ml35 c-grey4 other-from-width hidden">题目来源:{{r.coursename}}</span><div class="cl"></div> <span class="f12 mt5 ml35 c-grey4 other-from-width hidden">题目来源:{{r.coursename}}</span><div class="cl"></div>
</div> </div>
<div ng-if="exercise_has_more"> <div ng-if="exercise_has_more">

@ -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 vm = $scope;
var courseid = $routeParams.id; var courseid = $routeParams.id;
@ -104,13 +104,18 @@ app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location
vm.homeworks = []; vm.homeworks = [];
vm.exercises = []; vm.exercises = [];
//发送类别 1课件 2作业 3测验
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
vm.alertService = alertService.create(); vm.alertService = alertService.create();
vm.invite = function(){ vm.invite = function(){
$location.path("/invite_code").search({id: courseid}); $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}); $location.path("/send_class_list").search({id: r.id});
} }

@ -46,7 +46,7 @@ app.controller('SendClassListController', ['$scope', '$http','$routeParams', 'co
}).then(function(response){ }).then(function(response){
console.log(response.data); console.log(response.data);
if(response.data.status == 0){ if(response.data.status == 0){
vm.alertService.showMessage('提示', '发送成功', function () { vm.alertService.showMessage('发送成功', '题目已发送到目标班级的作业列表但需要您访问Trustie网站设置发布和截止时间以激活相应作业谢谢', function () {
window.history.back(); window.history.back();
}); });
} else { } else {

Loading…
Cancel
Save