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