<%
# Copyright (C) 2016 - 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/>.
%>

<%
  module_item_conditional_next ||= nil
  module_item ||= module_item_conditional_next
  item_data ||= { published_status: 'unpublished' }
  completion_criteria ||= nil
  editable ||= false
  criterion = completion_criteria && completion_criteria.find{|c| c[:id] == module_item.id}
%>

<li
  id="context_module_item_<%= module_item ? module_item.id : 'blank' %>"
  class="context_module_item context_module_item_conditional_info indent_<%= module_item.try_rescue(:indent) || '0' %>"
>
  <div class="ig-row mastery_path_row">
<%
  if item_data[:mastery_paths][:locked]
%>
    <span class="type_icon" title="<%= t('Locked Content') %>">
      <span class="ig-type-icon">
        <i class="icon-lock" aria-label="<%= t('Item type: Locked') %>"></i>
      </span>
    </span>
    <div class="ig-info">
      <div class="module-item-title">
        <span class="item_name" id="module-item-locked-<%= module_item.id %>">
          <em class="ig-title">
            <%= t('Locked until "%{item_name}" is graded', {item_name: module_item.content.title}) %>
          </em>
        </span>
      </div>
    </div>
<%
  elsif item_data[:mastery_paths][:awaiting_choice]
%>
    <span class="type_icon" title="<%= t('Content Choice') %>">
      <span class="ig-type-icon">
        <i class="icon-unlock" aria-label="<%= t('Item type: Choice') %>"></i>
      </span>
    </span>
    <div class="ig-info">
      <div class="module-item-title">
        <span class="item_name">
          <a href="<%= item_data[:choose_url] %>" title="<%= t('Choose Assignment Group') %>" class="ig-title">
            <%= t('Choose Assignment Group') %>
          </a>
        </span>
        <span class='conditional_options_count'>
          <%= t({ one: '1 Option', other: '%{count} Options' }, { count: item_data[:mastery_paths][:assignment_sets].count }) %>
        </span>
      </div>
    </div>
<%
  elsif item_data[:mastery_paths][:still_processing]
%>
    <span class="type_icon" title="<%= t('Mastery path processing') %>">
      <span class="ig-type-icon">
        <i class="icon-lock" aria-label="<%= t('Item type: Locked') %>"></i>
      </span>
    </span>
    <div class="ig-info">
      <div class="module-item-title">
        <span class="item_name" id="module-item-locked-<%= module_item.id %>">
          <em class="ig-title">
            <%= t('Locked until mastery path is processed for "%{item_name}"', {item_name: module_item.content.title}) %>
          </em>
        </span>
      </div>
    </div>
<%
  end
%>
  </div>
</li>
