You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
6.4 KiB

<!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="modal fade" id="modalUpdateQuestions">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modifier une Question</h5>
</div>
<form method="POST" action="/admin/questions/update">
<div class="modal-body">
<div class="form-group">
<input type="hidden" class="form-control" id="updateId" name="id">
</div>
<div class="form-group">
<label for="name">Contenu de la question :</label>
<input type="text" class="form-control" id="updateContent" name="content">
</div>
<div class="form-group">
<label for="name">Chapitre de la question :</label>
<select class="form-control" id="updateIdChapter" name="idChapter">
{% for chapter in chapters %}
<option value="{{ chapter.id }}" {% if chapter.id == question.idchapter %}selected="selected"{% endif %}>{{ chapter.name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="name">Réponse 1 de la question :</label>
<input type="hidden" class="form-control" id="updateIdAnswer1" name="IdAnswer1">
<input type="text" class="form-control" id="updateAnswer1" name="answer1">
<input type="radio" name="correctAnswer" {% if question.idanswergood == answers[0].id %}checked="checked"{% endif %} value="0"> Correct
</div>
<div class="form-group">
<label for="name">Réponse 2 de la question :</label>
<input type="hidden" class="form-control" id="updateIdAnswer2" name="IdAnswer2">
<input type="text" class="form-control" id="updateAnswer2" name="answer2">
<input type="radio" name="correctAnswer" {% if question.idanswergood == answers[1].id %}checked="checked"{% endif %} value="1"> Correct
</div>
<div class="form-group">
<label for="name">Réponse 3 de la question :</label>
<input type="hidden" class="form-control" id="updateIdAnswer3" name="IdAnswer3">
<input type="text" class="form-control" id="updateAnswer3" name="answer3">
<input type="radio" name="correctAnswer" {% if question.idanswergood == answers[2].id %}checked="checked"{% endif %} value="2"> Correct
</div>
<div class="form-group">
<label for="name">Réponse 4 de la question :</label>
<input type="hidden" class="form-control" id="updateIdAnswer4" name="IdAnswer4">
<input type="text" class="form-control" id="updateAnswer4" name="answer4">
<input type="radio" name="correctAnswer" {% if question.idanswergood == answers[3].id %}checked="checked"{% endif %} 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>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<script>
if ({{ question.id }} != 0) {
window.onload = showModal();
function showModal() {
var modal = new bootstrap.Modal(document.getElementById('modalUpdateQuestions'));
var id = document.getElementById('updateId');
var content = document.getElementById('updateContent');
var IdAnswer1 = document.getElementById('updateIdAnswer1');
var IdAnswer2 = document.getElementById('updateIdAnswer2');
var IdAnswer3 = document.getElementById('updateIdAnswer3');
var IdAnswer4 = document.getElementById('updateIdAnswer4');
var answer1 = document.getElementById('updateAnswer1');
var answer2 = document.getElementById('updateAnswer2');
var answer3 = document.getElementById('updateAnswer3');
var answer4 = document.getElementById('updateAnswer4');
id.value = "{{ question.id }}";
content.value = "{{ question.content }}";
IdAnswer1.value = "{{ answers[0].id }}";
IdAnswer2.value = "{{ answers[1].id }}";
IdAnswer3.value = "{{ answers[2].id }}";
IdAnswer4.value = "{{ answers[3].id }}";
answer1.value = "{{ answers[0].content }}";
answer2.value = "{{ answers[1].content }}";
answer3.value = "{{ answers[2].content }}";
answer4.value = "{{ answers[3].content }}";
modal.show();
}
}
</script>
</body>
</html>