{% extends 'assessments/base.html' %}
{% load i18n %}

{% block head %}
	{{ block.super }}
	<script src="{{ STATIC_URL }}common/js/ajax-modal.js"></script>
{% endblock %}

{% block section_title %}
	{% trans 'Curriculum' %}
{% endblock %}

{% block section_actions %}
    {% if curriculum %}
        {% if competency_tree.can_edit or competency_tree.can_translate %}
            <a href="{{ curriculum.get_topic_create_url }}" class="btn btn-primary">
                <i class="fa fa-plus"></i> {% trans 'New topic' %}
            </a>
        {% endif %}
    {% endif %}
{% endblock %}

{% block section_content %}
    {% if curriculum %}
        {% for topic in topic_list %}
            <div class="panel panel-default">
                <div class="panel-heading clearfix">
                    <div class="pull-left">
                        <h4>
                            <a href="#{{ topic.id }}" data-toggle="collapse" class="collapsed">
                                {{ topic.name }}
                            </a>
                        </h4>
                    </div>
                    {% if competency_tree.can_edit or competency_tree.can_translate %}
                        <div class="pull-right">
                            <a href="{{ topic.get_edit_url }}" class="btn btn-primary">
                                <i class="fa fa-pencil"></i> {% trans 'Edit' %}
                            </a>
                            <a href="{{ topic.get_delete_url }}" class="btn btn-danger dialog-box">
                                <i class="fa fa-trash"></i> {% trans 'Delete' %}
                            </a>
                        </div>
                    {% endif %}
                </div>
                <div id="{{ topic.id }}" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-{{ topic.id }}" aria-expanded="false">
                    <div class="panel-body">
                        <p>{{ topic.description }}</p>
                    </div>
                    <ul class="list-group">

                        {% for lesson in topic.lessons.non_deleted.all %}
                            <li class="list-group-item">
                                <b>{{ lesson.name }}</b>
                                {% if competency_tree.can_edit or competency_tree.can_translate %}
                                    <div class="pull-right">
                                        <a href="{{ lesson.get_edit_url }}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-pencil"></i> {% trans 'Edit' %}
                                        </a>
                                        <a href="{{ lesson.get_delete_url }}" class="btn btn-danger btn-xs dialog-box">
                                            <i class="fa fa-trash"></i> {% trans 'Delete' %}
                                        </a>
                                    </div>
                                {% endif %}
                            </li>
                        {% endfor %}

                    </ul>
                    {% if competency_tree.can_edit or competency_tree.can_translate %}
                        <div class="panel-footer clearfix">
                            <div class="pull-right">
                                <a href="{{ topic.get_lesson_create_url }}" class="btn btn-primary">
                                    <i class="fa fa-plus"></i> {% trans 'New lesson' %}
                                </a>
                            </div>
                        </div>
                    {% endif %}
                </div>
            </div>
        {% endfor %}
    {% else %}
        <div class="alert alert-info">
            <p>{% trans 'No available curriculum for this business unit. Please contact your administrator.' %}</p>
        </div>
    {% endif %}
{% endblock %}
