{% extends "base.html" %}
{% load i18n %}

{% block actions %}
<a class="btn btn-danger" href="{% url 'trainings:training_contents' training_id=training.id %}">{% trans 'Back to training' %}</a>
{% endblock %}


{% block subtitle %}
  {% trans 'Training' %} <span class="text-info">{{training.name}}</span> - {% trans 'Edit evaluation' %} <span class="text-info">{{evaluation_type_properties.name}}</span>
{% endblock %}

{% block head %}
  <link rel="stylesheet" href="{{ STATIC_URL }}trainings/css/django-admin-widgets.css" type="text/css" media="screen" charset="utf-8" />

  <script type="text/javascript" src="{{ STATIC_URL }}trainings/js/ui/jquery-ui.js"></script>

  <script type="text/javascript" src="{{ STATIC_URL }}trainings/js/django-admin.multiselect.js"></script>
  <script type="text/javascript">
    $(function(){
       jQuery.each($("select[multiple]"), function () {
        // "Locations" can be any label you want
        SelectFilter.init(this.id, "Locations", 0, "/static/admin/");
       });
    });
  </script>
  <style>
    .axis_count
    {
    position: relative;
    }

    .axis_count ul
    {
    display: none;
    list-style: none;
    width: 300px;
    }


    .axis_count:hover ul
    {
    display: block;
    position: absolute;
    border: 1px solid black;
    background-color: white;
    bottom: 0px;
    }

  </style>
{% endblock %}

{% block main %}
<form action="" method="post" enctype="multipart/form-data" >{% csrf_token %}
<table class="table table-hover">
<tbody>
{% for field in formEvaluationTypeProperties %}
<tr {% if field.errors %}class="error"{% endif %}>
  <td>
  {{ field.label_tag }}
  </td>
  <td>
    <div>{{field.errors}}</div>
  {{ field }}
  </td>
</tr>
{% endfor %}
</tbody>
</table>

<h2>{% trans 'Trainees permissions' %}:</h2>

<table class="table table-hover">
<tbody>
{% for field in formTraineeGroupSet %}
<tr {% if field.errors %}class="error"{% endif %}>
  <td>
  {{ field.label_tag }}
  </td>
  <td>
    <div>{{field.errors}}</div>
  {{ field }}
  </td>
</tr>
{% endfor %}
</tbody>
</table>


<div class="well text-center">
<input class="btn btn-primary" type="submit" value="{% trans 'Save' %}" />
{% if user.is_superuser %}
<a class="btn btn-danger" href="{% url 'evaluations:type_duplicate' evaluation_type_properties_id=evaluation_type_properties.id %}">{% trans 'Copy to trainers' %}</a>
{% endif %}
</div>
</form>

<h3>{% trans 'Exercices' %}:</h3>

{% if evaluation_exercice %}
  <div class="panel panel-default">
    <table class="table">
      <tr>
        <th>
          {% trans 'Order' %}
        </th>
        <th>
          {% trans 'Title' %}
        </th>
        <th>
          {% trans 'Preview' %}
        </th>
        <th>
          {% trans 'Edit' %}
        </th>
        {% if user.is_superuser %}
          <th>
            {% trans 'Delete' %}
          </th>
        {% endif %}
      </tr>
      {% for exercice in evaluation_exercice %}
        <tr>
          <td>
            {{exercice.order}}
          </td>
          <td>
            {{exercice.label}}
          </td>
          <td>
            {% if exercice.preview %}
              <img src="{{exercice.preview.url}}" />
            {% endif %}
          </td>
          <td>
            <a class="btn btn-primary" href="{% url 'evaluations:exercise_detail' evaluation_type_properties_id=evaluation_type_properties.id evaluation_exercice_id=exercice.id %}"><i class="fa fa-pencil"></i></a>
          </td>
          {% if user.is_superuser %}
          <td>
            <a class="btn btn-danger" href="{% url 'evaluations:exercise_delete' evaluation_type_properties_id=evaluation_type_properties.id evaluation_exercice_id=exercice.id %}"><i class="fa fa-trash"></i></a>
          </td>
          {% endif %}
        </tr>
      {% endfor %}
    </table>
  </div>
{% endif %}

{% if not evaluation_type_properties.master and not training.addition_lock or user.is_superuser %}
<div class="well text-center">
  <a href="{% url 'evaluations:exercise_add' evaluation_type_properties_id=evaluation_type_properties.id %}" class="btn btn-primary" >{% trans 'Add an exercice' %}</a>
</div>
{% endif %}



{% endblock %}
