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
学生数