From cabac5914c29e18c2a27c3660a6cc4a8f10db200 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 10 May 2016 13:41:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=BB=9F=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 8 ++++++-- app/views/organizations/_show_teachers.html.erb | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index d2974baae..3db2345ce 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -170,11 +170,15 @@ module OrganizationsHelper end def org_teacher_resource_count user - results = Attachment.find_by_sql("SELECT count(*) FROM attachments where author_id = #{user.id};").count + results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count end def org_teacher_course_count user - results = Course.find_by_sql("select count(*) from courses where courses.tea_id = #{user.id}").count + results = Course.find_by_sql("select * from courses where courses.tea_id = #{user.id}").count end + def org_student_course_count user + course_ids = user.courses.map { |c| c.is_delete == 0 && c.id} + results = Member.find_by_sql("select id from courses where courses.tea_id = #{user.id}").count + end end diff --git a/app/views/organizations/_show_teachers.html.erb b/app/views/organizations/_show_teachers.html.erb index 9418b861f..cbaed9f74 100644 --- a/app/views/organizations/_show_teachers.html.erb +++ b/app/views/organizations/_show_teachers.html.erb @@ -23,12 +23,12 @@ <%= org_teacher.technical_title %> <% end %>
-
<%= org_teacher.courses.count %>
+
<%= org_teacher_course_count(org_teacher) %>
课程数
-
500
+
<%= org_student_course_count(org_teacher) %>500
学生数