<% if members.any? %>
<table class="sy_new_table clear sy_new_table_width"  cellpadding="0" cellspacing="0">
  <thead>
  <tr class="clear">
    <th class="sy_th7">序号</th>
    <th class="sy_th15">姓名</th>
    <th class="sy_th15">
      <%= link_to '学号', member_score_sort_course_path(:sort_type => 'student_id', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? (@group == -1 ? -1 : @group.id) : 0), :search_name => (@search_name ? @search_name : nil)), :result => members, method: 'get', remote: true, :style => 'color:#000000;'%>
      <% if @sort_type == "student_id" && @score_sort_by == 'desc' %>
          <a href="javascript:void(0)" class="sy_sortdownbtn"></a>
      <% elsif @sort_type == "student_id" && @score_sort_by == 'asc' %>
          <a href="javascript:void(0)" class="sy_sortupbtn"></a>
      <% end %>
    </th>
    <th class="sy_th0 sy_fenban_tap">
      <%= link_to '作业得分', member_score_sort_course_path(:sort_type => 'score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? (@group == -1 ? -1 : @group.id) : 0), :search_name => (@search_name ? @search_name : nil)), :result => members, method: 'get', remote: true, :style => 'color:#000000;'%>
      <% if @sort_type == "score" && @score_sort_by == 'desc' %>
          <a href="javascript:void(0)" class="sy_sortdownbtn"></a>
      <% elsif @sort_type == "score" && @score_sort_by == 'asc' %>
          <a href="javascript:void(0)" class="sy_sortupbtn"></a>
      <% end %>
      <div class="sy_fenban_show undis" >
        <p>积分规则<br/>
          班级作业的得分总和</p>
      </div>
    </th>
    <th class="sy_th0 sy_fenban_tap">
      <%= link_to '测评得分', member_score_sort_course_path(:sort_type => 'ex_score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? (@group == -1 ? -1 : @group.id) : 0), :search_name => (@search_name ? @search_name : nil)), :result => members, method: 'get', remote: true, :style => 'color:#000000;'%>
      <% if @sort_type == "ex_score" && @score_sort_by == 'desc' %>
          <a href="javascript:void(0)" class="sy_sortdownbtn"></a>
      <% elsif @sort_type == "ex_score" && @score_sort_by == 'asc' %>
          <a href="javascript:void(0)" class="sy_sortupbtn"></a>
      <% end %>
      <div class="sy_fenban_show undis" >
        <p>积分规则<br/>
          班级测验的得分总和</p>
      </div>
    </th>
    <th class="sy_th0 sy_fenban_tap">
      <%= link_to '社区得分', member_score_sort_course_path(:sort_type => 'act_score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? (@group == -1 ? -1 : @group.id) : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true, :style => 'color:#000000;'%>
      <% if @sort_type == "act_score" && @score_sort_by == 'desc' %>
          <a href="javascript:" class= "sy_sortdownbtn"></a>
      <% elsif @sort_type == "act_score" && @score_sort_by == 'asc' %>
          <a href="javascript:" class= "sy_sortupbtn"></a>
      <% end %>
      <div class="sy_fenban_show undis" >
        <p>积分规则<br/>
          资源发布：资源数 x 5 <br>
          问答发布：发帖数 x 2 <br>
          通知发布：通知数 x 1 <br>
          问答回复：回复数 x 1 <br>
          作业留言：留言数 x 1 <br>
          通知留言：留言数 x 1 <br>
          班级留言：留言数 x 1  <br>
          总得分为以上得分之和
        </p>
      </div>
    </th>
    <th class="sy_th0 sy_fenban_tap">总得分
      <div class="sy_fenban_show undis" style="width:180px;">
        <p>积分规则<br/>
          作业得分+测评得分+社区得分</p>
      </div>
    </th>
    <th class="sy_th13">分班</th>
  </tr>
  </thead>
  <tbody>
    <% members.each_with_index do |member, i| %>
      <tr class="clear">
        <% user = member.user %>
        <% hw_score = member.score.nil? ? 0 : member.score %>
        <% ex_score = member.ex_score.nil? ? 0 : member.ex_score %>
        <% act_score = member.act_score.nil? ? 0 : member.act_score %>
        <% sum = hw_score + ex_score + act_score %>
        <td><%= (@page - 1) * @limit + i + 1 %></td>
        <td>
          <%= link_to image_tag(url_to_avatar(user), :width => "30", :height => "30", :style => "display:block;"), user_path(member.user_id), :class => 'sy_class_users_st fl mt5 mr5' ,:alt => "用户头像" %>
          <span class="fl sy_class_users_st_name" title="<%= user.show_name %>"><%= user.show_name %></span>
        </td>
        <td>
          <span class="sy_class_users_st_num" title="<%= user.user_extensions.student_id %>"><%= user.user_extensions.student_id %></span>
        </td>
        <td>
          <%= link_to format("%0.2f", hw_score), {
                :action => 'show_member_score',
                :member_id => member.id,
                :remote => true},
                :class => "" %>
        </td>
        <td><%= ex_score %></td>
        <td>
          <%= link_to act_score, {
                :action => 'show_member_act_score',
                :member_id => member.id,
                :remote => true},
                :class => '' %>
        </td>
        <td class="pr">
          <span class="sum_score_tip"><%= format("%0.2f", sum) %></span>
          <div class="sy_tips_box_inner undis" style="left: 215px; top: -60px; text-align: left;">
            <span style="top: 75px;"></span>
            <p >
                <font class="fb"><%= user.show_name %></font><br/>
                资源&nbsp;&nbsp;&nbsp;&nbsp;发布数：<%= member.resource_num.nil? ? 0 : member.resource_num %><br/>
                <font class="mr15">问答&nbsp;&nbsp;&nbsp;&nbsp;发布数：<%= member.message_num.nil? ? 0 : member.message_num %></font>回复数：<%= member.message_reply_num.nil? ? 0 : member.message_reply_num %><br/>
                <font class="mr15">通知&nbsp;&nbsp;&nbsp;&nbsp;提交数：<%= member.news_num.nil? ? 0 : member.news_num %></font>留言数：<%= member.news_reply_num.nil? ? 0 : member.news_reply_num %><br/>
                <font class="mr15">作业&nbsp;&nbsp;&nbsp;&nbsp;提交数：<%= member.homework_num.nil? ? 0 : member.homework_num %></font>留言数：<%= member.homework_journal_num.nil? ? 0 : member.homework_journal_num %><br/>
                班级&nbsp;&nbsp;&nbsp;&nbsp;留言数：<%= member.journal_num.nil? ? 0 : member.journal_num %><br />
                测验&nbsp;&nbsp;&nbsp;&nbsp;提交数：<%= member.exercise_num.nil? ? 0 : member.exercise_num %>
            </p>
          </div>
        </td>
        <td>
          <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? || User.current == user %>
              <% if @course.course_groups.empty? %>
                  <%=member.course_group_id == 0 ? "暂无" : member.course_group.name %>
              <% else %>
                  <%= form_tag({:controller => 'courses', :action => 'teacher_assign_group', :id => @course.id,:user_id => member.user_id},:remote=>'true', :method => 'post', :id=>"join_group_form_#{member.id}", :class => 'query_form') do %>
                      <div class="select-class-option">
                        <span class="hidden" style="display:inline-block; vertical-align:middle; max-width:70px;"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
                        <a href="javascript:void(0)" class="sy_icons_edit pic_edit_icon" alt="编辑" style="background-position:0 5px;"></a>
                      </div>
                      <%= select( :name,:group_id, course_group_option(@course),
                                  { :include_blank => false,:selected => member.course_group_id},
                                  {:onchange=>"join_group_function('#join_group_form_#{member.id}');", :id =>"course_group_id", :name => "course_group_id",:class=>"w100 undis class-edit sy_fenban_select", :style => "margin-left: 5px;"}) %>
                  <% end %>
              <% end %>
          <% else %>
              <%=member.course_group_id == 0 ? "暂无" : member.course_group.name %>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>
<div style="text-align:center;">
  <div class="pages" style="width:auto; display:inline-block;">
    <ul  id="homework_pository_ref_pages">
      <%= pagination_links_full @mem_pages, @members_count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%>
    </ul>
    <div class="cl"></div>
  </div>
</div>
<% else%>
  <p class="nodata">
    <%= l(:label_no_data) %>
  </p>
<% end %>

<script>
    $(document).ready(function(){
        $(".pic_edit_icon").click(function(){
            $(this).parent().hide();
            $(this).parent().next().show();
        });
        $(".class-edit").blur(function(){
            $(this).hide();
            $(this).prev().show();
            var editValue = $(this).children("option:selected").text();
            $(this).prev().children(":first").text(editValue);
        });
        function stopPropagation(e) {
            if (e.stopPropagation)
                e.stopPropagation();
            else
                e.cancelBubble = true;
        };
        $(document).bind('click',function(){
            $('.class-edit').css('display','none');
            $('.select-class-option').show();
        });
        $('.class-edit,.pic_edit_icon').bind('click',function(e){
            stopPropagation(e);
        });
    });
    function join_group_function(id){
        $(id).submit();
    }

    $(".sy_new_table tr").each(function(){
        $(this).mouseenter(function(){
            $(".sy_tips_box_inner").hide();
            $(this).children().eq(6).children().eq(1).stop();
            $(this).children().eq(6).children().eq(1).show();
        });
        $(this).mouseleave(function(){
            $(this).children().eq(6).children().eq(1).delay(500).hide(0);
        });
    });

    $(".sy_tips_box_inner").each(function(){
        $(this).mouseover(function(){
            $(this).stop();
            $(this).show();
        });
        $(this).mouseout(function(){
            $(this).delay(500).hide(0);
        });
    });
</script>

