## 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 people = searchPeopleByRoles project, roles_id people.count end # 根据角色查人 def searchPeopleByRoles project, roles_id people = [] begin people = project.members.joins(:member_roles).where("member_roles.role_id = :role_id", {:role_id => roles_id }) rescue Exception => e logger.error "[CoursesHelper] ===> #{e}" end people end end