右三模式定制

This commit is contained in:
huang 2016-05-13 13:39:44 +08:00
parent 21a56509fc
commit 3853d5b7ad
3 changed files with 40 additions and 21 deletions

View File

@ -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

View File

@ -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
# 查询用户未读过的记录
# 用户留言记录

View File

@ -1,24 +1,24 @@
<div class="sn-teacher-wrap" style="display:<%= field.hide == 0?'block':'none' %>;">
<h2 class="h2-title sn-mb5">名师风采<a href="javascript:void(0);" target="_blank" class="more">更多</a></h2>
<div class="sn-teacher-list"><a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>
<div class="sn-teacher-info"><a href="javascript:void(0);" class="sn-teacher-name sn-hidden" target=" title="张晓华" _blank">张晓华</a><span class="sn-teacher-unit sn-hidden" title="国防科学技术大学">国防科学技术大学</span> </div>
<div class="sn-teacher-social"><span>博客 8</span><span class="sn-ml20">课程 2</span><span class="sn-ml20">学生 218</span> </div>
<div class="sn-cl"></div>
</div>
<div class="sn-teacher-list"><a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>
<div class="sn-teacher-info"><a href="javascript:void(0);" class="sn-teacher-name sn-hidden" target=" title="张晓华" _blank">张晓华</a><span class="sn-teacher-unit sn-hidden" title="国防科学技术大学">国防科学技术大学</span></div><div class="sn-teacher-social"><span>博客 8</span><span class="sn-ml20">课程 2</span><span class="sn-ml20">学生 218</span> </div>
<div class="sn-cl"></div>
</div>
<div class="sn-teacher-list"><a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>
<div class="sn-teacher-info"><a href="javascript:void(0);" class="sn-teacher-name sn-hidden" target=" title="张晓华" _blank">张晓华</a><span class="sn-teacher-unit sn-hidden" title="国防科学技术大学">国防科学技术大学</span></div><div class="sn-teacher-social"><span>博客 8</span><span class="sn-ml20">课程 2</span><span class="sn-ml20">学生 218</span> </div>
<div class="sn-cl"></div>
</div>
<div class="sn-teacher-list"><a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>
<div class="sn-teacher-info"><a href="javascript:void(0);" class="sn-teacher-name sn-hidden" target=" title="张晓华" _blank">张晓华</a><span class="sn-teacher-unit sn-hidden" title="国防科学技术大学">国防科学技术大学</span></div><div class="sn-teacher-social"><span>博客 8</span><span class="sn-ml20">课程 2</span><span class="sn-ml20">学生 218</span> </div>
<div class="sn-cl"></div>
</div>
<div class="sn-teacher-list sn-border-none"><a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>
<div class="sn-teacher-info"><a href="javascript:void(0);" class="sn-teacher-name sn-hidden" target=" title="张晓华" _blank">张晓华</a><span class="sn-teacher-unit sn-hidden" title="国防科学技术大学">国防科学技术大学</span></div><div class="sn-teacher-social"><span>博客 8</span><span class="sn-ml20">课程 2</span><span class="sn-ml20">学生 218</span> </div>
<div class="sn-cl"></div>
</div>
<% excellent_teachers.each do |teacher| %>
<div class="sn-teacher-list">
<%= link_to image_tag(url_to_avatar(teacher), :width => "60", :height => "60", :class => "sn-fl", :style => "display:block;"), user_path(teacher), :alt => "用户头像", :target => '_blank' %>
<!--<a href="javascript:void(0);" target="_blank"><img src="images/avatar_default.png" width="60" height="60" style="display:block;" class="sn-fl" /></a>-->
<div class="sn-teacher-info">
<%=link_to teacher.try(:realname) ? teacher.try(:realname) :teacher.try(:login), user_path(teacher), :class => "sn-teacher-name sn-hidden", :title => '', :target => '_blank' %></a>
<span class="sn-teacher-unit sn-hidden" title="<%= teacher.my_workplace %>"><%= teacher.my_workplace %></span> </div>
<div class="sn-teacher-social">
<% unless teacher.my_blogs_count == 0 %>
<span>博客 <%= teacher.my_blogs_count %></span>
<% end %>
<% unless teacher.courses.count == 0 %>
<span class="sn-ml20">课程 <%= teacher.courses.count %></span>
<% end %>
<% unless teacher.my_students == 0 %>
<span class="sn-ml20">学生 <%= teacher.my_students %></span>
<% end %>
</div>
<div class="sn-cl"></div>
</div>
<% end %>
</div>