{% comment %}Get number of sections in course{% endcomment %}
{% assign course_count = 0 %}
{% for section in course.published_sections %}
  {% assign course_count = forloop.index %}
{% endfor %}

{% assign categories = course.course_category_names %}
<li class="uk-width-large-1-3 uk-width-medium-1-2 uk-width-small-1-1 school-website-course-tile course-card" data-categories="{{ categories }}">
  <div class="uk-panel uk-panel-box uk-panel-box-secondary course-card__body">
    {% if course.ribbon %}
      <div class="uk-panel-badge uk-badge">
        {{ course.ribbon }}
      </div>
    {% endif %}
    <div class="uk-panel-teaser">
      {% if current_person.enrolled_in_course? %}
        <a href="{{ course.cover_path }}" class="main-link">
          <img src="{{ course.list_image_url }}" class="uk-responsive-width uk-width-1-1">
        </a>
      {% else %}
        <a href="{{ course.details_path }}" class="main-link">
          <img src="{{ course.list_image_url }}" class="uk-responsive-width uk-width-1-1">
        </a>
      {% endif %}
    </div>
    <h3 class="uk-panel-title uk-margin-bottom-remove">
      {% if current_person.enrolled_in_course? %}
        <a href="{{ course.cover_path }}" data-test="course-name">{{ course.name }}</a>
      {% else %}
        <a href="{{ course.details_path }}" data-test="course-name">{{ course.name }}</a>
      {% endif %}
    </h3>
    <div class="course-card__footer c--grey">
      <div class="number-of-courses">
        <span class="number-of-courses__label"></span>
        <span class="number-of-courses__count">
          {{ course_count }}
        </span>
      </div>
      {% if current_person.enrolled_in_course? %}
        <a href="{{ course.cover_path }}" class="uk-button uk-button-primary school-website-course-tile-action uk-position-bottom-right" data-test="go-to-course-button">{{ course.go_to_label }}</a>
        <p class="progress-text">{{ course.progress_text }}</p>
      {% else %}
        <a href="{{ course.details_path }}" class="uk-button uk-button-outline school-website-course-tile-action uk-position-bottom-right">
          {% if current_school.apps.commerce.active? %}
            {{ course.formatted_price }}
          {% else %}
            {{ course.view_label }}
          {% endif %}
        </a>
      {% endif %}
    </div>
  </div>
</li>
