{% set type = type|default('discussion') %}

<ul class="media-list">
  {% for thread in threads %}
    {% if thread.title == '' %}
      {% if thread.questionType == 'video' %}
        {% set questionType = 'course.thread.question_type.video'|trans %}
      {% elseif thread.questionType == 'image' %}
        {% set questionType = 'course.thread.question_type.image'|trans %}
      {% elseif thread.questionType == 'audio' %}
        {% set questionType = 'course.thread.question_type.audio'|trans %}
      {% elseif thread.questionType == 'content' %}
        {% set questionType = 'course.thread.question_type.content'|trans %}
      {% endif %}
    {% endif %}
    {% if courses %}
      {% set course = courses[thread.courseId]|default(null) %}
      <li class="media">
        <div class="media-body">
          {% if thread.postNum > 0 %}
            <span class="badge pull-right" style="margin-top:15px;">{{ thread.postNum }}</span>
          {% endif %}
          <div class="mbm">
            {% if thread.type == 'question' %}
              <span class="label label-info" title="{{ 'my.learning.thread.question_tips'|trans }}">{{ 'my.learning.thread.question'|trans }}</span>
            {% endif %}

            <a href="{{ path('course_thread_show', {courseId:thread.courseId, threadId:thread.id}) }}" target="_blank"><strong>{{ thread.title|default('course.thread.question.title'|trans({'%questionType%':questionType|default('course.thread.question_type.content'|trans)})) }}</strong></a>

            {% if thread.taskId %}
              <span class="label" title="{{'my.learning.thread.task_id'|trans({'%taskId%': thread.taskId})}}">L{{ thread.taskId }}</span>
            {% endif %}

            {% if thread.isElite %}
              <span class="label label-warning" title="{{ 'my.learning.thread.essence_tips'|trans }}">{{ 'my.learning.thread.essence'|trans }}</span>
            {% endif %}

          </div>
          <div class="color-gray text-normal">
            {% if course %}
              <span>
                {{'my.learning.thread.target_course_from'|trans}}
                {% if course.title %}
                  <a href="{{ path('course_show', {id:course.id}) }}" class="link-primary" target="_blank">{{ course.title }}</a>
                  -
                {% endif %}
                <a href="{{ path('course_set_show',{id: courseSets[course.courseSetId].id}) }}" class="link-primary" target="_blank">
                  {{ courseSets[course.courseSetId].title }}
                </a>
              </span>
            {% else %}
              <span>{{ 'my.learning.thread.target_course_deleted'|trans }}</span>
            {% endif %}
            <span class="bullet">•</span>
            {% if thread.postNum > 0 %}
              {% set poster = users[thread.latestPostUserId] %}
              <span>{{ 'my.learning.thread.last_post'|trans }} {{ web_macro.user_link(poster, 'link-primary') }}</span>
              ,
              <span>{{ thread.latestPostTime|smart_time }}</span>
              <span class="bullet">•</span>
            {% endif %}
            <span>{{ thread.hitNum }}{{ 'my.learning.thread.browse'|trans }}</span>
          </div>
        </div>
      </li>
    {% else %}
      {% if type == 'question' %}
        <li class="empty">{{ 'my.learning.thread.question_empty'|trans }}</li>
      {% else %}
        <li class="empty">{{ 'my.learning.thread.empty'|trans }}</li>
      {% endif %}

    {% endif %}

  {% endfor %}

</ul>

{{ web_macro.paginator(paginator) }}