From 3853d5b7ad8981f6ab7eabd260df9dac74943a10 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 May 2016 13:39:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=B3=E4=B8=89=E6=A8=A1=E5=BC=8F=E5=AE=9A?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/organizations_helper.rb | 5 +++ app/models/user.rb | 14 +++++++ .../_org_subfield_rightM2.html.erb | 42 +++++++++---------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 3db2345ce..6463bf854 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -181,4 +181,9 @@ module OrganizationsHelper 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 + + def excellent_teachers + User.where("excellent_teacher =?",true) + end + end diff --git a/app/models/user.rb b/app/models/user.rb index 2030adfdf..c3a4f8c25 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -308,6 +308,20 @@ class User < Principal end # ====================================================================== + def my_workplace + self.user_extensions.try(:occupation).to_s + end + + def my_blogs_count + self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count + end + + def my_students + my_students=StudentsForCourse.find_by_sql("SELECT SUM(student_count) as students_count, c.tea_id FROM courses c, (SELECT course_id , COUNT(id) AS student_count FROM students_for_courses GROUP BY course_id) AS ct + WHERE c.id= ct.course_id and c.tea_id = #{self.id} GROUP BY c.tea_id").first + results = my_students.blank? ? 0 : my_students.students_count + results + end # 查询用户未读过的记录 # 用户留言记录 diff --git a/app/views/organizations/_org_subfield_rightM2.html.erb b/app/views/organizations/_org_subfield_rightM2.html.erb index 1f954b66a..567df26d9 100644 --- a/app/views/organizations/_org_subfield_rightM2.html.erb +++ b/app/views/organizations/_org_subfield_rightM2.html.erb @@ -1,24 +1,24 @@

名师风采更多

-
-
张晓华国防科学技术大学
-
博客 8课程 2学生 218
-
-
-
-
张晓华国防科学技术大学
博客 8课程 2学生 218
-
-
-
-
张晓华国防科学技术大学
博客 8课程 2学生 218
-
-
-
-
张晓华国防科学技术大学
博客 8课程 2学生 218
-
-
-
-
张晓华国防科学技术大学
博客 8课程 2学生 218
-
-
+ <% excellent_teachers.each do |teacher| %> +
+ <%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %> + +
+ <%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "sn-teacher-name sn-hidden", :title => '', :target => '_blank' %> + <%= teacher.my_workplace %>
+
+ <% unless teacher.my_blogs_count == 0 %> + 博客 <%= teacher.my_blogs_count %> + <% end %> + <% unless teacher.courses.count == 0 %> + 课程 <%= teacher.courses.count %> + <% end %> + <% unless teacher.my_students == 0 %> + 学生 <%= teacher.my_students %> + <% end %> +
+
+
+ <% end %>
\ No newline at end of file