{% extends 'base.html' %}
{% block content %}
<div class="card">
<h2 style="margin-top:0">Results</h2>


{% if real_answer is defined and real_answer is not none %}
<p><strong>Real answer:</strong> {{ real_answer }}</p>
{% endif %}


{% if winners and winners|length > 0 %}
<p><strong>Winner{{ 's' if winners|length > 1 else '' }}:</strong>
{% for w in winners %}
{{ w.name }} ({{ w.estimate }}){% if not loop.last %}, {% endif %}
{% endfor %}
</p>
{% else %}
<p>No winner yet. Finalize to compute winner.</p>
{% endif %}


<hr>
<h3 style="margin:0.5rem 0">All submissions</h3>


{% if submissions %}
<table>
<thead>
<tr><th>Name</th><th>Estimate</th><th>Submitted</th></tr>
</thead>
<tbody>
{% for s in submissions %}
<tr>
<td>{{ s.name }}</td>
<td>{{ s.estimate }}</td>
<td>{{ s.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No submissions yet.</p>
{% endif %}
</div>

{% endblock %}