{% 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 create-lesson" id="lesson-create-btn" data-title="添加" data-name="课时" 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' %}
				<button class="btn btn-info btn-sm create-lesson" id="lesson-create-btn" data-title="添加" data-name="试卷" 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-info dropdown-toggle" data-toggle="dropdown">
			    <i class="glyphicon glyphicon-plus"></i> 章节 <span class="caret"></span>
			  </button>
			  <ul class="dropdown-menu" role="menu">
			    <li>
			      <a href="#" class="create-chapter" id="chapter-create-btn" data-title="添加" data-name="章" data-url="{{ path('course_manage_chapter_create', {id:course.id}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 章</a>
			    </li>
			    <li>
			      <a href="#" class="create-chapter" id="chapter-create-btn" data-title="添加" data-name="小节" data-url="{{ path('course_manage_chapter_create', {id:course.id, type:'unit'}) }}"><i class="glyphicon glyphicon-plus"></i> 添加 小节</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-parentid="{{course.parentId}}" data-structurechanged="{{course.structureChanged}}" 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 %}
