{% extends "base.html" %}
{% block title %}Результаты{% endblock %}
{% block description %}Сетевой тренажер для обучения компьютерным сетям{% endblock %}

{% block content %}
    <section class="container" style="margin-top: 48px; padding-top: 48px">
        <div class="row align-items-baseline">
            <div class="col-auto">
                <h1 class="mb-0" id="test_name"></h1>
            </div>
            <div class="col-auto text-center">
                <h3 class="mb-0" style="font-weight: normal" id="section_name"></h3>
            </div>
        </div>
        <div>
            <div id="answersCount">Правильных ответов: {{ data['correct_answers'] }} из {{ data['answer_count'] }}</div>
            <div id="timeCount">Тест пройден за: {{ data['time_spent'] }}</div>
            <button class="btn btn-primary" name="backToTests" style="margin-top: 12px">Назад к тестам</button>
        </div>
    </section>

    <script>
        document.getElementById("test_name").innerHTML = sessionStorage.getItem('test_name');
        document.getElementById("section_name").innerHTML = sessionStorage.getItem('section_name');

        document.querySelector('button[name="backToTests"]').addEventListener('click', backToTests);

        console.log({{ data | tojson | safe }});

        function backToTests() {
            sessionStorage.clear();
            window.location.href = '/quiz/test/all';
        }

    </script>
{% endblock %}