{% extends 'base.html' %}
{% load i18n %}
{% load quiz_tags %}
{% block title %}
{% trans "Results of " %} {{ sitting.quiz.title }} {% trans "for " %} {{ sitting.user }}
{% endblock %}

{% block content %}
<!-- vérif si user is logged == sitting.user ou est admin -->
{% if sitting.user.username == request.user.username or request.user.is_superuser %}

<h2>{% trans "Quiz title" %}: {{ sitting.quiz.title }}</h2>
<h3>{% trans "Catégory" %}: {{ sitting.quiz.category }}</h3>
<p>{{ sitting.quiz.description }}</p>
<hr>
<p>{% trans "User" %}: {{ sitting.user }}</p>
<p>{% trans "Completed" %}: {{ sitting.end|date }}</p>
<p>{% trans "Score" %}: {{ sitting.get_percent_correct }}%</p>

<table class="table table-bordered table-striped">

  <thead>
	<tr>
	  <th>{% trans "Question" %}</th>
	  <th>{% trans "User answer" %}</th>
	  <th>Réponse</th>
	  <!--th>Réponse correcte</th-->
	  <th>Explication</th>
	</tr>
  </thead>

  <tbody>

{% for question in questions %}
	<tr>
      <td>
        {{ question.content }}
        {% if question.figure %}
        <div style="max-width: 100px;"><img src="{{ question.figure.url }}" alt="{{ question.figure }}"/></div>
        {% endif %}
      </td>
	  <td>{{ question|answer_choice_to_string:question.user_answer }}</td>
	  <td>
		{% if question.id in sitting.get_incorrect_questions %}
		  <p>{% trans "Incorrect" %}</p>
		{% else %}
		  <p>{% trans "Correct" %}</p>
		{% endif %}
	  </td>
	  	{% if question.explanation %}
	  <td>{{ question.explanation }}</td>
	  	{% endif %}
	</tr>
{% endfor %}

</tbody>

</table>
{% else %}
	<p>{% trans "You don't have access to this page" %}</p>
{% endif %}
{% endblock %}
	  <!--td>
		<form action="" method="POST">{% csrf_token %}
		  <input type=hidden name="qid" value="{{ question.id }}">
		  <button type="submit" class="btn btn-warning">{% trans "Toggle whether correct" %}</button>
		</form>
	  </td-->