{% import 'macro.html.twig' as web_macro %}

<div class="es-section" id="open-course-comment">
  <div class="gray-darker pbl">{{'my.teaching.open_course.comment.title'|trans}}(<span class="thread-post-num">{{ course.postNum }}</span>)</div>
  {% if app.user %}
    <form class="es-commet" id="thread-post-form" method="POST" action="{{ path('open_course_post',{id:course.id}) }}" onsubmit="return false">
      <textarea class="form-control form-control-o" rows="6" placeholder="{{'my.teaching.open_course.comment.content.placeholder'|trans}}" {% if not app.user %}disabled{% endif %} name="content" data-display="{{'my.teaching.open_course.comment.content.placeholder'|trans}}"></textarea>
      <div class="form-group clearfix">
        <button type="submit" class="btn btn-primary pull-right {% if not app.user or app.request.get('as')|default('') == 'preview' %}disabled{% endif %}" data-loading-text="{{'form.btn.save.submiting'|trans}}">{{'form.btn.comment'|trans}}</button>
      </div>
      <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
    </form>
  {% else %}
    <div class="empty">
      {% set loginUrl = path('login',{goto:goto}) %}
      {% set registerUrl = path('register',{goto:goto}) %}
      {{ 'my.teaching.open_course.comment.un_login.tips'|trans({'%loginUrl%':loginUrl, '%registerUrl%':registerUrl})|raw }}
    </div>
  {% endif %}

  <ul class="comment-list thread-pripost-list">
    {% for post in posts %}
      {% set author = users[post.userId] %}
      {% set postReplyUrl = path('open_course_post_reply', {id:course.id, postId:post.id, targetType:'openCourse'}) %}
      {% set goto = goto|default(path('homepage')) %}
      {% include 'thread/part/post-item.html.twig' %}
    {% else %}
      <li class="empty">{{'my.teaching.open_course.comment.empty'|trans}}</li>
    {% endfor %}
  </ul>

  <nav class="text-center">
    {{ web_macro.paginator(paginator) }}
  </nav>
</div>
