diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 5553990e6..5a87286b4 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -332,33 +332,45 @@ module UsersHelper end def get_create_course_count(user) - if user == User.current - user.courses.count - else - user.courses.where("is_public = 1").count - end + user.courses.visible.where("tea_id = ?",user.id).count end + + #获取加入课程数 def get_join_course_count(user) - user.coursememberships.count - get_create_course_count(user) + user.courses.visible.count - get_create_course_count(user) end + + #发布作业数 def get_homework_commons_count(user) HomeworkCommon.where("user_id = ?",user.id).count end + + #资源数 def get_projectandcourse_attachment_count(user) Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count end + + #创建项目数 def get_create_project_count(user) - Project.where("user_id = ? and project_type = ?",user.id,Project::ProjectType_project).count + user.projects.visible.where("projects.user_id=#{user.id}").count end + + #加入项目数 def get_join_project_count(user) - user.memberships.count(conditions: "projects.project_type = #{Project::ProjectType_project}") - get_create_project_count(user) + user.projects.visible.count - get_create_project_count(user) end + + #创建缺陷数 def get_create_issue_count(user) Issue.where("author_id = ?",user.id).count end + + #解决缺陷数 def get_resolve_issue_count(user) Issue.where("assigned_to_id = ? and status_id=3",user.id).count end + + #参与匿评数 def get_anonymous_evaluation_count(user) StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count end