封装获取作业成员的方法
This commit is contained in:
parent
19fc84afee
commit
29fa624e9d
|
@ -18,6 +18,13 @@ class HomeworkAttachController < ApplicationController
|
||||||
@project = @homework.bid.courses[0]
|
@project = @homework.bid.courses[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#获取作业的成员
|
||||||
|
def get_homework_member homework
|
||||||
|
@hoemwork_users = users_for_homework(@homework)
|
||||||
|
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
||||||
|
@members = paginateHelper @members,10
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@homeworks = HomeworkAttach.all
|
@homeworks = HomeworkAttach.all
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -40,9 +47,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@homework.save
|
@homework.save
|
||||||
@hoemwork_users = users_for_homework(@homework)
|
get_homework_member @homework
|
||||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
|
||||||
@members = paginateHelper @members,10
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -57,9 +62,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
if User.current.admin? || User.current == @homework.user
|
if User.current.admin? || User.current == @homework.user
|
||||||
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
||||||
homework_user.destroy
|
homework_user.destroy
|
||||||
@hoemwork_users = users_for_homework(@homework)
|
get_homework_member @homework
|
||||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
|
||||||
@members = paginateHelper @members,10
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
|
@ -136,11 +139,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
@homework = HomeworkAttach.find(params[:bid_id])
|
@homework = HomeworkAttach.find(params[:bid_id])
|
||||||
course = @homework.bid.courses.first
|
course = @homework.bid.courses.first
|
||||||
if User.current.admin? || User.current.member_of?(course)
|
if User.current.admin? || User.current.member_of?(course)
|
||||||
@hoemwork_users = users_for_homework(@homework)
|
get_homework_member @homework
|
||||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
|
||||||
#该课程的学生的集合
|
|
||||||
#@members = course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
|
||||||
@members = paginateHelper @members,10
|
|
||||||
else
|
else
|
||||||
raise "error"
|
raise "error"
|
||||||
end
|
end
|
||||||
|
@ -165,9 +164,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
||||||
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
||||||
@hoemwork_users = users_for_homework(@homework)
|
get_homework_member @homework
|
||||||
@members = members_for_homework(@homework,@hoemwork_users,params[:q])
|
|
||||||
@members = paginateHelper @members,10
|
|
||||||
else
|
else
|
||||||
render_403 :message => :notice_not_authorized
|
render_403 :message => :notice_not_authorized
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue