<!-- 加入分班 -->
<div style="margin-left: 15px">
  <% if User.current.logged? && User.current.member_of_course?(@course) && @group  %>
      <%= join_in_course_group(@course.course_groups,@group, User.current) unless @canShowCode %>
      <span style="font-size: 12px; float: left; margin-right: 5px">
      <%= l(:label_current_group)%>:&nbsp;
        <%= @group.name %>
    </span>
  <% end %>
</div>
<div class="cl"></div>

<% if members.any? %>
    <% if @result_count %>
        <p style="font-size: 18px;">
          <%= l(:label_search_member_count) %>
          <%= @result_count %>
          <%= l(:label_member_people) %>
        </p>
        <div class="cl"></div>
    <% end %>

    <div class="st_box">
      <ul class="st_box_top">
        <li  class="ml50" style="padding-right: 5px;"><span class="fontGrey6 fb">姓名</span></li>
        <li  class="ml10" style="padding-right: 15px;"><span class="fontGrey6 fb">学号</span></li>
        <li style="padding-right: 55px; margin-left: 160px;"><span class="fontGrey6 fb">分班</span></li>
        <li class="st_list_score ml10">
          <%= link_to '作业积分', member_score_sort_course_path(:sort_type => 'score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true, :class => 'ml25'%>
          <% if @sort_type == "score" && @score_sort_by == 'desc' %>
              <a id="pic" href="javascript:" class= "st_down"></a>
          <% elsif @sort_type == "score" && @score_sort_by == 'asc' %>
              <a id="pic" href="javascript:" class= "st_up"></a>
          <% end %>
        </li>
        <li class="st_list_score">
          <%= link_to '活跃度', member_score_sort_course_path(:sort_type => 'act_score', :sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true, :class => 'ml35'%>
          <% if @sort_type == "act_score" && @score_sort_by == 'desc' %>
              <a id="pic" href="javascript:" class= "st_down"></a>
          <% elsif @sort_type == "act_score" && @score_sort_by == 'asc' %>
              <a id="pic" href="javascript:" class= "st_up"></a>
          <% end %>
        </li>
        <li class="ml20"><span class="fontGrey6 fb">加入时间</span></li>
      </ul>
      <div class="cl"></div><!--st_box_top end-->

      <% members.each do |member| %>
          <div class="st_boxlist">
            <a href="javascript:" class="st_img">
              <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32))  %>
            </a>
            <ul>
              <li>
                <%= link_to("#{l(:label_bidding_user_studentname)}：<span >#{member.user.show_name}</span>".html_safe,user_path(member.user)) %>
              </li>
              <br/>
              <% unless member.user.user_extensions.student_id == ''%>
                  <li><%= link_to("#{l(:label_bidding_user_studentcode)}：<span >#{member.user.user_extensions.student_id}</span>".html_safe,user_path(member.user)) %></li>
              <% end%>
            </ul>
            <% if User.current.allowed_to?(:as_teacher, @course) || User.current.admin? %>
                <% if @course.course_groups.nil? || @group %>
                    <div class="select-class-option fl" style="margin-left: 5px;">
                      <span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
                    </div>
                <% 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 fl" style="margin-left: 5px;"><span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
                          <a style="display: inline-block;" href="javascript:void(0)" class="pic_edit2 ml5"></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=>"w125 undis class-edit fl", :style => "margin-left: 5px;"}) %>
                    <% end %>
                <% end %>
            <% else %>
                <div class="select-class-option fl" style="margin-left: 5px;">
                  <span style="width: 100px; text-align: center; float: left;" class="hidden"><%=member.course_group_id == 0 ? "暂无" : member.course_group.name %></span>
                </div>
            <% end %>
            <%= link_to format("%0.2f",member.score.nil? ? 0 : member.score.to_s), {
                    :action => 'show_member_score',
                    :member_id => member.id,
                    :remote => true},
                        :class => 'st_list_score c_red' %>
            <%= link_to member.act_score.nil? ? 0 : member.act_score.to_s, {
                    :action => 'show_member_act_score',
                    :member_id => member.id,
                    :remote => true},
                        :class => 'st_list_score c_red' %>
            <span class="fr mr15 c_grey"><%= format_date(member.created_on)%></span>
            <%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
          </div>
          <div class="cl"></div>
      <% end; reset_cycle %>
    </div>

    <!--<ul class="wlist">
      <% #= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
    </ul>-->
<% else%>
    <p class="nodata">
      <%= l(:label_no_data) %>
    </p>
<% end%>

<script>
    $(document).ready(function(){
        /*$(".select-class-option").mouseover(function(){
         $(this).children(".pic_edit2").css("display","inline-block");
         });
         $(".select-class-option").mouseout(function(){
         $(this).children(".pic_edit2").css("display","none");
         });*/
        $(".pic_edit2").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_edit2').bind('click',function(e){
            stopPropagation(e);
        });
    });
    function join_group_function(id){
        $(id).submit();
    }
</script>

