<% org_students.each do |org_student| %>
    <% school = School.where("id =?", org_student.school_id).first %>
    <div class="teacher-list-row">
      <div>
        <div class="teacher-avatar">
          <%= link_to image_tag(url_to_avatar(org_student), :width => "90", :height => "90"), user_url_in_org(org_student), :alt => "用户头像" %>
        </div>
        <div class="fl">
          <div class="ml25 mb20"><span class="teacher-name"><%=link_to org_student.try(:realname).nil? ? org_student.try(:login) : org_student.try(:realname), user_url_in_org(org_student) %></span>
            <% unless school.nil? %>
                <span class="f12 fontGrey2 mr15"><%= school.name %></span>
            <% end %>
          </div>
          <div class="teacher-social-block">
            <div class="block-num"><%= org_student.courses.count %></div>
            <div class="block-title">课程数</div>
          </div>
          <div class="block-slice"></div>
          <div class="teacher-social-block">
            <div class="block-num"><%= org_teacher_resource_count(org_student) %></div>
            <div class="block-title">资源数</div>
          </div>
        </div>
        <% if User.current.admin? %>
            <a href="javascript:void(0);" class="fr teacher-select" onclick="hide($(this),'<%= org_student.id %>');" id="hide_<%= org_student.id %>"><%= org_student.excellent_student ==0 ? "设为学霸" : "取消设置" %></a>
        <% end %>
      </div>
      <div class="cl"></div>
    </div>
<% end %>

<script>
    function hide(content, id){
        if (content.text() == '设为学霸')
            $.ajax({
                url: "/organizations/set_excellent_student?user=" + id ,
                type: "post"
            });
        else
            $.ajax({
                url: "/organizations/reset_excellent_student?user=" + id ,
                type: "post"
            });
    }
</script>