{# -*- engine:django -*- #}

{% extends "core/base.html" %}

{% load i18n %}

{% block browser_title %}{% blocktrans %}Evaluations{% endblocktrans %}{% endblock %}
{% block page_title %}{% blocktrans %}Evaluations{% endblocktrans %}{% endblock %}

{% block content %}
  <figure class="alert primary">
    <i class="material-icons left">info</i>
    {% blocktrans %}
      In the following list, you can see all evaluations you can participate or have already participated in the past.
      If you want to participate in an evaluation, please register yourself using the "Register" button.
    {% endblocktrans %}
  </figure>
  <table class="highlight">
    <tr>
      <th>{% trans "Status" %}</th>
      <th>{% trans "Name" %}</th>
      <th>{% trans "Registration period" %}</th>
      <th>{% trans "Evaluation period" %}</th>
      <th>{% trans "Registered" %}</th>
      <th></th>
    </tr>
    {% for phase in object_list %}
      <tr>
        <td>
          {% include "evalu/phase/status.html" with phase=phase %}
        </td>
        <td>
          {{ phase.name }}
        </td>
        <td>
          {{ phase.registration_date_start }}–{{ phase.registration_date_end }}
        </td>
        <td>
          {{ phase.evaluation_date_start }}–{{ phase.evaluation_date_end }}
        </td>
        <td>
          {% if phase.registrations.all %}
            <i class="material-icons left green-text">check_circle</i>
            <a class="btn-flat waves-effect waves-green"
               href="{% url "evaluation_registration" phase.registrations.all.0.pk %}">{% trans "Show" %}</a>
          {% else %}
            <i class="material-icons left red-text">cancel</i>
          {% endif %}
        </td>
        <td>
          {% with status=phase.status %}
            {% if status == "registration" %}
              {% if not phase.registrations.all %}
                <a class="btn waves-effect waves-light" href="{% url "register_for_evaluation" phase.pk %}">
                  <i class="material-icons left">edit</i>
                  {% trans "Register" %}
                </a>
              {% endif %}
            {% elif status == "evaluation" and phase.registrations.all %}
              <a class="btn waves-effect waves-light" href="{% url "manage_evaluation_process" phase.registrations.all.0.pk %}">
                <i class="material-icons left">play_arrow</i>
                {% trans "Start Evaluations" %}
              </a>
              {% elif status == "results" and phase.registrations.all %}
              <a class="btn waves-effect waves-light" href="{% url "evaluation_results" phase.registrations.all.0.pk %}">
                <i class="material-icons left">insights</i>
                {% trans "View results" %}
              </a>
            {% endif %}
          {% endwith %}
        </td>
      </tr>
    {% endfor %}
  </table>
{% endblock %}
