{% extends "trainings/trainingactivity_base_detail.html" %}

{% load i18n template_tools %}

{% block activity_details %}
    <table class="table table-bordered">
        <tr>
            <td>
                {% if workshop.is_broadcastable %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "is_broadcastable" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "is_broadcastable" %}
                {% endif %}
            </td>
            <td>
                {% if workshop.is_steps_order_random %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "is_steps_order_random" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "is_steps_order_random" %}
                {% endif %}
            </td>
            <td>
                {% if workshop.are_questions_mandatory %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "are_questions_mandatory" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "are_questions_mandatory" %}
                {% endif %}
            </td>
        </tr>
        <tr>
            <td>
                {% if workshop.is_questions_answers_order_random %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "is_questions_answers_order_random" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "is_questions_answers_order_random" %}
                {% endif %}
            </td>
            <td>
                {% if workshop.needs_approval %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "needs_approval" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "needs_approval" %}
                {% endif %}
            </td>
            <td>
                {% if workshop.enable_score %}
                    <i class="fa fa-check"></i>
                    {% get_verbose_field_name workshop "enable_score" %}
                {% else %}
                    <i class="fa fa-remove"></i>
                    {% get_verbose_field_name workshop "enable_score" %}
                {% endif %}
            </td>
        </tr>
    </table>
{% endblock %}
{% block activity_contents %}
    <div class="clearfix">
        <h4 class="pull-left">
            {% trans 'Steps' %}
        </h4>
        {% if workshop.training.is_editable %}
            <div class="pull-right">
                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        {% trans 'New step' %} <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        {% for step_type in workshop.available_step_types %}
                            <li>
                                <a href="{{ step_type.create_url }}" class="dialog-box">
                                    <i class="fa fa-plus"></i>
                                    {% trans 'New ' %} {{ step_type.verbose_name }}
                                </a>
                            </li>
                        {% endfor %}
                    </ul>
                </div>
                {% if steps %}
                    <a href="{{ workshop.get_steps_sort_url }}" class="btn btn-primary">
                        <i class="fa fa-sort"></i>
                        {% trans 'Sort steps' %}
                    </a>
                {% endif %}
            </div>
        {% endif %}
    </div>
    <hr>
    {% for step in steps %}
        <div class="panel panel-default">
            <div class="panel-heading clearfix">
                <h4 class="pull-left">
                    <a href="#{{ step.pk }}" data-toggle="collapse" class="collapsed" id="heading-{{ step.id }}">
                        <small>{{ step.verbose_step_name }}</small>
                        {{ step.title }}
                    </a>
                </h4>
                {% if workshop.training.is_editable %}
                    <div class="pull-right">
                        <a href="{{ step.get_edit_url }}" class="btn btn-primary dialog-box">
                            <i class="fa fa-pencil icon-white"></i> {% trans 'Edit' %}
                        </a>
                        <a href="{{ step.get_delete_url }}" class="btn btn-danger dialog-box">
                            <i class="fa fa-trash icon-white"></i>
                        </a>
                    </div>
                {% endif %}
            </div>
            <div class="panel-collapse collapse" id="{{ step.id }}" role="tabpanel" aria-labelledby="heading-{{ step.id }}" aria-expanded="false">
                {% if step.step_name == 'image' %}
                    <div class="panel-body">
                        <img src="{{ step.image.url }}" alt="">
                    </div>
                {% else %}
                    <table class="table table-bordered">
                        <tr>
                            <td>
                                {% if step.is_multiple_choices %}
                                    <i class="fa fa-check"></i>
                                    {% get_verbose_field_name step "is_multiple_choices" %}
                                {% else %}
                                    <i class="fa fa-remove"></i>
                                    {% get_verbose_field_name step "is_multiple_choices" %}
                                {% endif %}
                            </td>
                            <td>
                                {% if step.is_answers_order_random %}
                                    <i class="fa fa-check"></i>
                                    {% get_verbose_field_name step "is_answers_order_random" %}
                                {% else %}
                                    <i class="fa fa-remove"></i>
                                    {% get_verbose_field_name step "is_answers_order_random" %}
                                {% endif %}
                            </td>
                        </tr>
                    </table>
                {% endif %}
                <ul class="list-group">
                    {% for answer in step.answers.non_deleted %}
                        <li class="list-group-item clearfix {% if answer.is_correct %}list-group-item-success{% endif %}">
                            <p class="pull-left">
                                {{ answer.label }}
                            </p>
                            {% if workshop.training.is_editable %}
                                <div class="pull-right">
                                    <a href="{{ answer.get_edit_url }}" class="btn btn-primary dialog-box">
                                        <i class="fa fa-pencil"></i>
                                        {% trans 'Edit' %}
                                    </a>
                                    <a href="{{ answer.get_delete_url }}" class="btn btn-danger dialog-box">
                                        <i class="fa fa-trash"></i>
                                    </a>
                                </div>
                            {% endif %}
                        </li>
                    {% endfor %}
                </ul>
                {% if step.step_name == 'question' and workshop.training.is_editable %}
                    <div class="panel-footer clearfix">
                        <div class="pull-right">
                            <a href="{{ step.get_create_answer_url }}" class="btn btn-primary dialog-box">
                                <i class="fa fa-plus"></i>
                                {% trans 'New answer' %}
                            </a>
                            <a href="{{ step.get_answers_sort_url }}" class="btn btn-primary">
                                <i class="fa fa-sort"></i>
                                {% trans 'Sort answers' %}
                            </a>
                        </div>
                    </div>
                {% endif %}
            </div>
        </div>
    {% endfor %}
{% endblock %}