<%
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
%>

<% @responsive_misc = @domain_root_account.feature_enabled?(:responsive_misc) %>
<li class="<%= 'unpublished' if enrollment.course.created? || enrollment.course.claimed? %> <%= enrollment.state_based_on_date %> clearfix">

  <a href="<%= course_user_path(enrollment.course_id, enrollment.user_id) %>" style="float: <%= direction('left') %>; max-width: 800px;">
    <span
      class="name"
      title="<%= enrollment.long_name(@current_user) %>"
      style="<%= @responsive_misc ? 'word-break: break-word;' : '' %>">
      <%= enrollment.long_name(@current_user) %>
      <% if enrollment.course.created? || enrollment.course.claimed? %>
        <i class="icon-unpublish" title="<%= t('course_not_published', "This course hasn't been published yet") %>"></i>
      <% end %>
    </span>

    <% unless enrollment.course.enrollment_term.default_term? %>
      <span
        class="subtitle<%= @responsive_misc ? '' : ' ellipsis' %>"
        style="<%= @responsive_misc ? 'word-break: break-word;' : '' %>">
        <%= enrollment.course.enrollment_term.name %>
      </span>
    <% end %>

    <span
      class="subtitle<%= @responsive_misc ? '' : ' ellipsis' %>"
      style="<%= @responsive_misc ? 'word-break: break-word;' : '' %>">
      <%= Enrollment.workflow_readable_type(enrollment.readable_state_based_on_date) %>,
      <%=
        case enrollment.class.to_s
        when 'TeacherEnrollment'
          t('roles_teacher', "Enrolled as a Teacher.")
        when 'StudentEnrollment'
          t('roles_student', "Enrolled as a Student.")
        when 'TaEnrollment'
          t('roles_ta', "Enrolled as a TA.")
        when 'ObserverEnrollment'
          t('roles_observer', "Enrolled as an Observer.")
        when 'DesignerEnrollment'
          t('roles_designer', "Enrolled as a Designer.")
        else
          t('roles_student', "Enrolled as a Student.")
        end
      %>

      <% if enrollment.associated_user %>
        <%= t('linked_to_user', '(Linked to %{user_name})', :user_name => enrollment.associated_user.name) %>
      <% end %>
    </span>
  </a>
  <span style="float: <%= direction('right') %>; margin-<%= direction('right') %>: 5px; margin-top: 3px;">
    <% if enrollment.can_be_deleted_by(@current_user, enrollment.course, session) %>
      <a href="#" rel="<%= api_v1_destroy_enrollment_url(enrollment.course_id, enrollment.id, {:task => "delete"}) %>" class="unenroll_link" role="button">
        <i class="icon-end standalone-icon"></i>
        <span class="screenreader-only"><%= t(:unenrollr, "Unenroll") %></span>
      </a>
    <% end %>
  </span>
  <% if enrollment.admin? && can_do(enrollment.user, @current_user, :read_reports) %>
    <div style='clear:left'>
      <%= link_to(t('links.teacher_activity', 'See Student Interactions Report'), user_course_teacher_activity_url(enrollment.user_id, enrollment.course_id)) %>
    </div>
  <% end %>
  <span class="clear"></span>
</li>
