You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/app/helpers/courses_helper.rb

29 lines
828 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## This helper be included in applicationHelper
module CoursesHelper
# 返回学生数量即roles表中定义的Reporter 返回结果 -1 为查询失败
def studentCount project
searchCountByRoles project, 5
end
# 返回教师数量即roles表中定义的Manager 返回结果 -1 为查询失败
def teacherCount project
searchCountByRoles project, 3
end
# 返回TA数量即roles表中定义的TA 返回结果 -1 为查询失败
def teacherAssistantCount project
searchCountByRoles project, 7
end
# 根据角色查询
def searchCountByRoles project, roles_id
count = -1
begin
count = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => roles_id }).count
rescue Exception => e
logger.error "[CoursesHelper] ===> #{e}"
end
count
end
end