<!DOCTYPE html>
<html lang="fr">
    <head>
        <title>Maths 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>
        <div class="container mt-5">
            <h1>Liste des questions</h1>
            <ul class="list-group">
                {% for question in questions %}
                    <li class="list-group-item d-flex ustify-content-between align-items-center">
                        {{ question.content }}
                        <div class="btn-group" role="group">
                            <a type="button" href="/admin/questions/updatemodal/{{ question.id }}"  class="btn btn-primary">Modifier</a>
                            <a type="button" href="/admin/questions/delete/{{ question.id }}" class="btn btn-danger">Supprimer</a>
                        </div>
                    </li>
                {% endfor %}
            </ul>
        </div>
        <div class="container mt-3">
            <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalquestions">Ajouter un chapitre</button>
            <div class="btn-group" role="group">
                <a href="/admin/chapters" class="btn btn-secondary"> ← Chapitres</a>
                <a href="/" class="btn btn-secondary">Retour</a>
                <a href="/admin/administrators" class="btn btn-secondary">Administrateurs →</a> 
            </div>
        </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>
