{% set chapter = task %}
<li class="task-manage-item js-task-manage-item drag clearfix " id="chapter-{{ chapter.id }}">
  {% set tasks = array_index(chapter.tasks, 'mode') %}
  {% set task = tasks.lesson|default(null) %}
  <div class="item-default-header clearfix">
    <div class="item-line"></div>
    <div class="item-content text-overflow js-item-content">
      <i class="mrm es-icon
        {% if activity_metas(task.activity.mediaType) %}
          {{ activity_metas(task.activity.mediaType).icon }}
        {% endif %}">
      </i>

      {% if chapter.number == 0 %}
        <span class="label label-info mrm">{{'course.plan_task.is_optional_task'|trans}}</span>
      {% else %}
        {{'site.data.task'|trans}}<span class="number">{{ chapter.number }}</span>：
      {% endif %}

      {{ task.title|sub_text(30) }}
      {% if task.activity.mediaType is same as('live') %}
        {% set isLiveFinished = is_live_finished(task.activity.id, 'course') %}
        
        {% if not task.activity.ext.roomCreated|default(true) %}
          <span class="color-warning">{{ 'course.plan_task.edit_tips'|trans }}</span>
        {% elseif isLiveFinished %}
          <span class="color-gray">{{ 'course.plan_task.live_finish_tips'|trans }}</span>
        {% else %}
          <span class="color-success mls">
          {{ task.activity.startTime|date('Y-n-j H:i')|trans }} ~ {{ task.activity.endTime|date('H:i')|trans }}</span>
        {% endif %}
      {% else %}
        {% if task.activity.length|activity_length_format(task.activity.mediaType) %}<span class="color-gray mls">
          （{{ task.activity.length|activity_length_format(task.activity.mediaType) }}）</span>{% endif %}
      {% endif %}
      <span class="color-warning publish-status
        {% if task.status == 'published' %}
          hidden
        {% endif %}">
         {{'course.plan_task.task_unpublished'|trans}}
      </span>
    </div>
    <div class="item-actions">
      <a class="btn gray-darker" data-role='update-task' href="javascript:;"
        data-toggle="modal" data-target="#modal"
        data-url="{{ path('course_manage_task_update', {id:task.id,courseId:task.courseId, type:'lesson'}) }}">
        <i class="es-icon es-icon-edit mrs"></i>{{'course.plan_task.edit_btn'|trans}}
      </a>
      <a class="btn gray-darker" href="{{ path('course_task_show', {id:task.id,courseId:task.courseId,preview:1}) }}"
        target="_blank"><i class="es-icon es-icon-removeredeye mrs"></i>{{'course.plan_task.preview_btn'|trans}}</a>
      <span class="dropdown">
        <a class="dropdown-toggle dropdown-more btn gray-darker" id="dropdown-more" data-toggle="dropdown" href="#">
          <i class="es-icon es-icon-keyboardarrowdown mrs" aria-haspopup="true" aria-expanded="false"></i>{{ 'course.plan_task.more_btn'|trans }}
        </a>
        <ul class="dropdown-menu pull-right dropdown-menu-more" role="menu" style="margin-top:12px;min-width:144px"
          aria-labelledby="dLabel" style="display:none;">
          {% if task.type == 'video' and setting('storage.upload_mode') == 'cloud' %}
            {% set file = task.activity.ext.file|default(null) %}

            {% if  file.storage|default(null) == 'cloud' %}
              <li class="mark-manage">
            <a href="{{ path('course_task_marker_manage', {courseId:course.id, taskId:task.id}) }}" target="_blank" class="manage-lesson-marker-btn" >
            <span class="glyphicon glyphicon-list prs"></span>{{'course.plan_task.lesson-marker_btn'|trans}}
            </a>
            </li>
              <li class="divider mark-manage-divider" style="display:none;"></li>
            {% endif %}
          {% endif %}

          {% if task.status|default('create') == 'published' %}
            {% set status = 1 %}
          {% else %}
            {% set status = 0 %}
          {% endif %}
            <li>
            <a class='unpublish-item {% if status != 1 %}hidden{% endif %}' href="javascript:;" data-type="task"
              data-url="{{ path('course_manage_task_unpublish', {id:task.id,courseId:task.courseId}) }}">
              <i class="es-icon es-icon-close01 mrm"></i>{{'course.plan_task.unpublish_btn'|trans}}
            </a>
          </li>
            <li>
              <a class='publish-item {% if status == 1 %}hidden{% endif %}' href="javascript:;" data-type="task"
                data-url="{{ path('course_manage_task_publish', {id:task.id,courseId:task.courseId}) }}">
                <i class="es-icon es-icon--check-circle mrm"></i>{{'course.plan_task.publish_btn'|trans}}
              </a>
            </li>
            {{ slot('task.menu.extension', {'task': task}) }}
            <li>
            <a class='delete-item {% if status == 1 %}hidden{% endif %}' href="javascript:;" data-type="task"
              data-url="{{ path('course_manage_task_delete', {taskId:task.id,courseId:task.courseId}) }}">
              <i class="es-icon es-icon-delete mrm"></i>{{'course.plan_task.delete_btn'|trans}}
            </a>
          </li>
        </ul>
      </span>
    </div>
  </div>
  <div class="settings-list js-settings-list clearfix">
    <div class="settings-item {% if tasks.preparation|default(null) %} active {% endif %}">
      <a href="javascript:;" data-toggle="modal" data-target="#modal"
        data-backdrop="static" data-keyboard="false"
        data-help="popover" data-placement="top" data-html="true" data-trigger="hover"
        {% if not tasks.preparation|default(null) %}
          data-content="{{'course.plan_task.preparation_tips'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)})}}"
          data-url="{{ path('course_manage_task_create', {courseId:course.id, type: 'preparation', categoryId: chapter.id}) }}">
        {% else %}
          data-content="<i class='mr10 es-icon
            {% if activity_metas(tasks.preparation.type) %}
              {{ activity_metas(tasks.preparation.type).icon }}
            {% endif %}'></i>{{tasks.preparation.title|trans}}"
          data-url= "{{ path('course_manage_task_update', {id:tasks.preparation.id,courseId:tasks.preparation.courseId, type:'preparation', categoryId: chapter.id}) }}">
        {% endif %}
        <i class="mrm es-icon es-icon-yulan "
          {% if tasks.preparation.id|default(null) %}
            data-role="task"
          {% endif %}>
        </i>
        {{'course.plan_task.preparation'|trans}}
      </a>
      <i class="es-icon es-icon-angledoubleright after"></i>
    </div>
    <div class="settings-item js-settings-item active">
      <a href="javascript:;" data-role='update-task'
        data-url="{{ path('course_manage_task_update', {id:task.id,courseId:task.courseId, type:'lesson'}) }}"
        data-toggle="modal" data-target="#modal"
        data-help="popover" data-placement="top" data-html="true" data-trigger="hover"
        data-content="<i class='mr10 es-icon
          {% if activity_metas(task.activity.mediaType) %}
            {{ activity_metas(task.activity.mediaType).icon }}
          {% endif %} '></i>{{task.title|trans}}">
        <i class="es-icon es-icon-book mrm" data-role="task"></i>
        {{'course.plan_task.task'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)})}}
      </a>
      <i class="es-icon es-icon-angledoubleright after"></i>
    </div>
    <div class="settings-item {% if tasks.exercise|default(null) %} active {% endif %}">
      <a href="javascript:;" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false"
        data-help="popover" data-placement="top" data-html="true" data-trigger="hover"
        {% if not tasks.exercise|default(null) %}
          data-content="{{'course.plan_task.practice_tips'|trans}}"
          data-url="{{ path('course_manage_task_create', {courseId:course.id, type: 'exercise', categoryId: chapter.id}) }}">
        {% else %}
          data-content="<i class='mr10 es-icon
            {% if activity_metas(tasks.exercise.type) %}
              {{ activity_metas(tasks.exercise.type).icon }}
            {% endif %}
          '></i>{{tasks.exercise.title|trans}}"
          data-url="{{ path('course_manage_task_update', {id:tasks.exercise.id,courseId:tasks.exercise.courseId, type:'exercise', categoryId: chapter.id}) }}">
        {% endif %}
        <i class="es-icon es-icon-mylibrarybooks mrm" {% if tasks.exercise.id|default(null) %}data-role="task"{% endif %}></i>
        {{'course.plan_task.practice'|trans}}
      </a>
      <i class="es-icon es-icon-angledoubleright after"></i>
    </div>
    <div class="settings-item {% if tasks.homework|default(null) %} active {% endif %}">
      <a href="javascript:;" data-toggle="modal" data-target="#modal"
        data-backdrop="static" data-keyboard="false"
        data-help="popover" data-placement="top" data-html="true" data-trigger="hover"
        {% if not tasks.homework|default(null) %}
          data-content="{{'course.plan_task.homework_tips'|trans}}"
          data-url="{{ path('course_manage_task_create', {courseId:course.id, type: 'homework', categoryId: chapter.id}) }}">
        {% else %}
          data-content="<i class='mr10 es-icon
            {% if activity_metas(tasks.homework.type) %}
              {{ activity_metas(tasks.homework.type).icon }}
            {% endif %}
          '></i>{{tasks.homework.title|trans}}"
          data-url="{{ path('course_manage_task_update', {id:tasks.homework.id,courseId:tasks.homework.courseId, type:'homework', categoryId: chapter.id}) }}">
        {% endif %}
       <i class="es-icon es-icon-writefill mrm" {% if tasks.homework.id|default(null) %}data-role="task"{% endif %}></i>
        {{'course.plan_task.homework'|trans}}
      </a>
      <i class="es-icon es-icon-angledoubleright after"></i>
    </div>
    <div class="settings-item {% if tasks.extraClass|default(null) %} active {% endif %}">
      <a href="javascript:;" data-toggle="modal" data-target="#modal"
        data-backdrop="static" data-keyboard="false"
        data-help="popover" data-placement="top" data-html="true" data-trigger="hover"
        {% if not  tasks.extraClass|default(null) %}
          data-content="{{'course.plan_task.extra_class_tips'|trans}}"
          data-url="{{ path('course_manage_task_create', {courseId:course.id, type: 'extraClass', categoryId: chapter.id}) }}">
        {% else %}
          data-content="<i class='mr10 es-icon
          {% if activity_metas(tasks.extraClass.type) %}
            {{ activity_metas(tasks.extraClass.type).icon }}
          {% endif %}
          '></i>{{tasks.extraClass.title|trans}}"
          data-url="{{ path('course_manage_task_update', {id:tasks.extraClass.id,courseId:tasks.extraClass.courseId, type:'extraClass', categoryId: chapter.id}) }}">
        {% endif %}
        <i class="es-icon es-icon-sun mrm" {% if tasks.extraClass.id|default(null) %}data-role="task"{% endif %}></i>
        {{'course.plan_task.extra_class'|trans}}
      </a>
    </div>
  </div>
</li>
