<table class="table text-center course-table">
  <thead class="thead-light">
  <tr>
    <th class="text-left">名称</th>
    <th class="text-left">管理教师</th>
    <th>评测次数</th>
    <th>学生</th>
    <th>实训作业</th>
    <th>资源</th>
    <th>帖子</th>
    <th>其它任务</th>
    <th>状态</th>
    <th>时间</th>
  </tr>
  </thead>
  <tbody>
    <% if @courses.present? %>
      <% @courses.each do |course| %>
        <tr>
          <td class="text-left"><a href="/classrooms/<%= course.id %>/students" target="_blank" class="d-inline-block text-truncate" style="max-width: 220px"><%= course.name %></a></td>
          <% teacher_names = course.teacher_users.map(&:real_name).join('、') %>
          <td class="text-left">
            <span class="d-inline-block text-truncate" style="max-width: 150px" data-toggle="tooltip" title="<%= teacher_names %>">
              <%= teacher_names || '--' %>
            </span>
          </td>
          <td><%= course.evaluating_count.to_i %></td>
          <td><%= @student_count.fetch(course.id, 0) %></td>
          <td><%= @shixun_work_count.fetch(course.id, 0) %></td>
          <td><%= @attachment_count.fetch(course.id, 0) %></td>
          <td><%= @message_count.fetch(course.id, 0) %></td>
          <td><%= @exercise_count.fetch(course.id, 0) + @poll_count.fetch(course.id, 0) + @other_work_count.fetch(course.id, 0) %></td>
          <td class="<%= course.is_end ? 'text-secondary' : 'text-warning' %>"><%= course.is_end ? "已结束" : "正在进行" %></td>
          <td class="text-secondary"><%= @active_time[course.id]&.strftime('%Y-%m-%d %H:%M') %></td>
        </tr>
      <% end %>
    <% else %>
      <tr><td colspan="100">暂无数据</td></tr>
    <% end %>
  </tbody>
</table>

<div class="d-flex justify-content-center text-center">
  <%= render partial: 'admins/shared/paginate', locals: { objects: @courses } %>
</div>