{% extends "base.html" %}

{% load i18n %}

{% block actions %}
    <a class="btn btn-default" href="{{ evaluation.get_absolute_url }}">{% trans 'Back to the evaluation' %}</a>
{% endblock %}

{% block main %}
	<form action="{% if exercise.pk %}{{ evaluation.get_exercise_edit_url }}{% else %}{{ evaluation.get_exercise_create_url }}{% endif %}" method="POST" enctype="multipart/form-data">{% csrf_token %}
		<div class="panel panel-default">
			<table class="table table-bordered">
				{% include 'extras/form.html' %}
			</table>
			<div class="panel-footer clearfix">
				<input type="submit" value="{% trans 'Submit' %}" class="btn btn-primary pull-right">
			</div>
		</div>
	</form>
	{% if exercise.pk %}
		<div class="panel panel-default">
			<div class="panel-heading">
				<h4>{% trans 'Criteria' %}</h4>
			</div>
			<ul class="list-group">
				{% for criterion in criteria %}
					<li class="list-group-item clearfix">
						{{ criterion.get_criterion_type_display }}: {{ criterion.description }}
						<div class="pull-right">
							<a href="{{ criterion.get_edit_url }}" class="btn btn-sm btn-primary">
								<i class="fa fa-pencil icon-white"></i> {% trans 'Edit' %}
							</a>
							<a href="{{ criterion.get_delete_url }}" class="btn btn-sm btn-danger">
								<i class="fa fa-trash icon-white"></i> {% trans 'Delete' %}
							</a>
						</div>
					</li>
				{% endfor %}
			</ul>
			<div class="panel-footer clearfix">
				<div class="pull-right">
					<a href="{{ exercise.get_criterion_create_url }}" class="btn btn-primary">
						{% trans 'Add a new criterion' %}
					</a>
					<a href="{{ exercise.get_criteria_sort_url }}" class="btn btn-default">
						<i class="fa fa-sort"></i> {% trans 'Sort criteria' %}
					</a>
				</div>
			</div>
		</div>
	{% endif %}
{% endblock %}
