{% extends 'TopxiaWebBundle:CourseManage:layout.html.twig' %}

{% block title %}课时管理 - {{ parent() }}{% endblock %}

{% set side_nav = 'lesson' %}
{% set script_controller = 'course-manage/lesson' %}

{% block main %}

<div class="panel panel-default panel-col lesson-manage-panel">
	<div class="panel-heading">
		<div class="pull-right">

			<button class="btn btn-info btn-sm" id="lesson-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{% if course.type == 'normal' %}{{ path('course_manage_lesson_create', {id:course.id}) }}{% else %}{{ path('live_course_manage_lesson_create', {id:course.id}) }}{% endif %}"><i class="glyphicon glyphicon-plus"></i> {% if course.type == 'normal' %}课时{% else %}直播课时{% endif %}</button>

			{% if course.type == 'normal' or course.type == 'live' %}
				<button class="btn btn-info btn-sm" id="lesson-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_lesson_create_testpaper', {id:course.id}) }}"><i class="glyphicon glyphicon-plus"></i> 试卷</button>
			{% endif %}

			<div class="btn-group">
			  <button type="button" class="btn btn-sm btn-success dropdown-toggle" data-toggle="dropdown">
			    <i class="glyphicon glyphicon-plus"></i> {% if setting('default.chapter_name') %}{{setting('default.chapter_name')|default('章')}}{% else %}章{% endif %}/{% if setting('default.part_name') %}{{setting('default.part_name')|default('节')}}{% else %}节{% endif %} <span class="caret"></span>
			  </button>
			  <ul class="dropdown-menu" role="menu">
			    <li>
			      <a href="#" id="chapter-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_chapter_create', {id:course.id}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 {% if setting('default.chapter_name') %}{{setting('default.chapter_name')|default('章')}}{% else %}章{% endif %}</a>
			    </li>
			    <li>
			      <a href="#" id="chapter-create-btn" data-toggle="modal" data-target="#modal" data-backdrop="static" data-keyboard="false" data-url="{{ path('course_manage_chapter_create', {id:course.id, type:'unit'}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 {% if setting('default.part_name') %}{{setting('default.part_name')|default('节')}}{% else %}节{% endif %}</a>
			    </li>
			  </ul>
			</div>
		</div>

		课时管理
	</div>

	{% if items is empty %}

	 <div class="empty">暂无课时内容！</div>

	 {% endif %}

	<div class="panel-body">
		<ul class="lesson-list sortable-list" id="course-item-list" data-sort-url="{{ path('course_manage_lesson_sort', {id:course.id}) }}">

			{% for id, item in items %}
			  {% if 'chapter' in id %}
			    {% include 'TopxiaWebBundle:CourseChapterManage:list-item.html.twig' with {chapter: item} %}
			  {% elseif 'lesson' in id %}
			    {% include 'TopxiaWebBundle:CourseLessonManage:list-item.html.twig' with {lesson: item, file: files[item.mediaId]|default(null)} %}
			  {% endif %}
			{% endfor %}
			
		</ul>
	</div>
</div>

{% endblock %}
