<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>Math'Educ</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
        </script>
        <link rel="stylesheet" href="../css/global.css">
    </head>

    <body id="bodyStyle">
        <div>
            <a href="/" role="button" class="btn btn-secondary position-absolute top-0 mt-2 end-0 me-2">
                Retour
            </a>
        </div>
        <div class="container mt-5 text-light fs-4">
            <h1>Liste des questions</h1>
            <p class="text-center bg-danger"> {{ error }} </p>
            <ul class="list-group">
                {% for question in questions %}
                    <li class="list-group-item d-flex justify-content-between align-items-center border-dark text-light bg-secondary">
                        {{ question.content }}
                        <div class="btn-group" role="group">
                            <a type="button" href="/admin/questions/updatemodal/{{ question.id }}"  class="btn btn-primary fs-5">Modifier</a>
                            <a type="button" href="/admin/questions/delete/{{ question.id }}" class="btn btn-danger fs-5">Supprimer</a>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="container mt-3 d-flex justify-content-between">
            <a type="button" href="/admin/chapters" class="btn btn-secondary fs-5"> ← Chapitres</a>
            <button type="button" class="btn btn-primary fs-5" data-bs-toggle="modal" data-bs-target="#modalquestions">Ajouter une question</button>
            <a type="button" href="/admin/administrators" class="btn btn-secondary fs-5">Administrateurs →</a>
        </div>

        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>

        <div class="modal fade" id="modalquestions">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title" id="exampleModalLabel">Ajouter une question</h5>
                    </div>
                    <form method="POST" action="/admin/questions/add">
                        <div class="modal-body">
                            <div class="form-group">
                                <label for="name">Contenu de la question :</label>
                                <input type="text" class="form-control" id="content" name="content">
                            </div>
                            <div class="form-group">
                                <label for="name">Chapitre de la question :</label>
                                <select class="form-control" id="idChapter" name="idChapter">
                                    {% for chapter in chapters %}
                                    <option value="{{chapter.id}}" >{{chapter.name}}</option>
                                    {% endfor %}
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="name">Réponse 1 de la question :</label>
                                <input type="text" class="form-control" id="answer1" name="answer1">
                                <input type="radio" name="correctAnswer" checked="checked" value="0"> Correct
                            </div>
                            <div class="form-group">
                                <label for="name">Réponse 2 de la question :</label>
                                <input type="text" class="form-control" id="answer2" name="answer2">
                                <input type="radio" name="correctAnswer" value="1"> Correct
                            </div>
                            <div class="form-group">
                                <label for="name">Réponse 3 de la question :</label>
                                <input type="text" class="form-control" id="answer3" name="answer3">
                                <input type="radio" name="correctAnswer" value="2"> Correct
                            </div>
                            <div class="form-group">
                                <label for="name">Réponse 4 de la question :</label>
                                <input type="text" class="form-control" id="answer4" name="answer4">
                                <input type="radio" name="correctAnswer" value="3"> Correct
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
                            <button type="submit" class="btn btn-primary">Enregistrer</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </body>
</html>
