Docfile commited on
Commit
5331cbc
·
verified ·
1 Parent(s): 4f72684

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +245 -297
templates/index.html CHANGED
@@ -1,322 +1,270 @@
1
  <!DOCTYPE html>
2
  <html lang="fr">
3
  <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Flashcards et Quiz</title>
7
- <script src="https://cdn.tailwindcss.com"></script>
8
- <style>
9
- body {
10
- background: linear-gradient(135deg, #1e3a8a, #6b7280);
11
- min-height: 100vh;
12
- }
13
- .container {
14
- background: rgba(255, 255, 255, 0.95);
15
- border-radius: 15px;
16
- box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
17
- padding: 2rem;
18
- }
19
- .progress-bar {
20
- height: 10px;
21
- background: #e5e7eb;
22
- border-radius: 5px;
23
- overflow: hidden;
24
- }
25
- .progress-fill {
26
- height: 100%;
27
- background: linear-gradient(to right, #10b981, #3b82f6);
28
- transition: width 0.5s ease-in-out;
29
- }
30
- .question-card {
31
- transform: scale(0.9);
32
- opacity: 0;
33
- animation: slideIn 0.5s forwards;
34
- }
35
- @keyframes slideIn {
36
- to { transform: scale(1); opacity: 1; }
37
- }
38
- .correct-answer {
39
- animation: correctFlash 0.8s;
40
- }
41
- .wrong-answer {
42
- animation: wrongShake 0.5s;
43
- }
44
- @keyframes correctFlash {
45
- 0% { background-color: #10b981; transform: scale(1); }
46
- 50% { transform: scale(1.05); }
47
- 100% { background-color: #d1fae5; transform: scale(1); }
48
- }
49
- @keyframes wrongShake {
50
- 0%, 100% { transform: translateX(0); }
51
- 25% { transform: translateX(-10px); }
52
- 75% { transform: translateX(10px); }
53
- }
54
- .explanation-container {
55
- display: none;
56
- margin-top: 1rem;
57
- padding: 1rem;
58
- background: #f8fafc;
59
- border-left: 4px solid #ef4444;
60
- border-radius: 5px;
61
- animation: slideFromRight 0.5s ease-in-out;
62
- }
63
- @keyframes slideFromRight {
64
- from { transform: translateX(100%); opacity: 0; }
65
- to { transform: translateX(0); opacity: 1; }
66
- }
67
- .character {
68
- width: 100px;
69
- height: 100px;
70
- background: url('chemin/vers/professeur.png') center/contain no-repeat;
71
- margin-right: 1rem;
72
- }
73
- .popup {
74
- position: fixed;
75
- top: 50%;
76
- left: 50%;
77
- transform: translate(-50%, -50%) scale(0);
78
- background: linear-gradient(135deg, #ffd700, #ff6347);
79
- padding: 2rem;
80
- border-radius: 15px;
81
- box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
82
- z-index: 1000;
83
- animation: popupIn 0.5s forwards;
84
- border: 4px solid #ffd700;
85
- color: #fff;
86
- }
87
- @keyframes popupIn {
88
- to { transform: translate(-50%, -50%) scale(1); }
89
- }
90
- .overlay {
91
- position: fixed;
92
- top: 0;
93
- left: 0;
94
- width: 100%;
95
- height: 100%;
96
- background: rgba(0, 0, 0, 0.7);
97
- z-index: 999;
98
- }
99
- .popup h2 {
100
- font-size: 2.5rem;
101
- font-weight: bold;
102
- text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
103
- }
104
- .popup p {
105
- font-size: 1.2rem;
106
- margin-top: 1rem;
107
- }
108
- .popup button {
109
- background: #ff4500;
110
- border: none;
111
- padding: 0.75rem 1.5rem;
112
- font-size: 1.1rem;
113
- font-weight: bold;
114
- border-radius: 10px;
115
- transition: transform 0.2s;
116
- }
117
- .popup button:hover {
118
- transform: scale(1.05);
119
- }
120
- </style>
121
  </head>
122
- <body class="font-sans">
123
- <div class="container mx-auto mt-8 px-4">
124
- <h1 class="text-4xl font-bold text-center text-gray-800 mb-6">Révisons un peu</h1>
 
 
125
 
126
- <!-- Section de configuration -->
127
- <div class="max-w-2xl mx-auto mb-8">
128
- <div class="bg-white rounded-lg shadow-md p-6">
129
- <div class="mb-4">
130
- <label for="topic" class="block text-sm font-medium text-gray-700 mb-1">Sujet</label>
131
- <input type="text" class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm p-2" id="topic" placeholder="Balance ton sujet...">
132
- </div>
133
- <div class="mb-4">
134
- <label class="block text-sm font-medium text-gray-700 mb-2">Type</label>
135
- <div class="flex items-center space-x-4">
136
- <div class="flex items-center">
137
- <input id="typeFlashcards" name="contentType" type="radio" value="flashcards" checked class="h-4 w-4 text-indigo-600">
138
- <label for="typeFlashcards" class="ml-2 block text-sm text-gray-900">Flashcards</label>
139
- </div>
140
- <div class="flex items-center">
141
- <input id="typeQuiz" name="contentType" type="radio" value="quiz" class="h-4 w-4 text-indigo-600">
142
- <label for="typeQuiz" class="ml-2 block text-sm text-gray-900">Quiz</label>
143
- </div>
144
- </div>
145
- </div>
146
- <button id="generateBtn" class="w-full py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700">
147
- GO !
148
- </button>
149
- </div>
150
  </div>
151
-
152
- <!-- Indicateur de chargement -->
153
- <div id="loading" class="hidden text-center my-10">
154
- <svg class="animate-spin h-8 w-8 text-indigo-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
155
- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
156
- <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
157
- </svg>
158
- <p class="mt-2 text-gray-600">Ça charge, attends deux secs...</p>
 
 
 
 
 
 
159
  </div>
 
 
 
 
 
160
 
161
- <!-- Conteneur Quiz -->
162
- <div id="quizContainer" class="mt-6 max-w-3xl mx-auto hidden">
163
- <div class="progress-bar mb-6">
164
- <div class="progress-fill" id="progressFill"></div>
165
- </div>
166
- <div id="currentQuestion"></div>
167
- </div>
168
- </div>
169
 
170
- <script>
171
- const generateBtn = document.getElementById('generateBtn');
172
- const loadingIndicator = document.getElementById('loading');
173
- const quizContainer = document.getElementById('quizContainer');
174
- const topicInput = document.getElementById('topic');
175
- let quizQuestions = [];
176
- let currentQuestionIndex = 0;
177
- let score = 0;
178
 
179
- generateBtn.addEventListener('click', function() {
180
- const topic = topicInput.value.trim();
181
- if (!topic) {
182
- alert('Rentre un sujet, bordel !');
183
- return;
184
- }
 
 
185
 
186
- const contentType = document.querySelector('input[name="contentType"]:checked').value;
187
- loadingIndicator.classList.remove('hidden');
188
- quizContainer.innerHTML = '';
189
- quizContainer.classList.add('hidden');
190
 
191
- fetch('/generate', {
192
- method: 'POST',
193
- headers: { 'Content-Type': 'application/json' },
194
- body: JSON.stringify({ topic, type: contentType }),
195
- })
196
- .then(response => {
197
- if (!response.ok) throw new Error(`HTTP ${response.status}`);
198
- return response.json();
199
- })
200
- .then(data => {
201
- loadingIndicator.classList.add('hidden');
202
- if (data.error) {
203
- alert('Erreur: ' + data.error);
204
- return;
205
- }
206
- if (contentType === 'quiz' && data.quiz) {
207
- quizQuestions = data.quiz;
208
- currentQuestionIndex = 0;
209
- score = 0;
210
- quizContainer.classList.remove('hidden');
211
- displayCurrentQuestion();
212
- }
213
- })
214
- .catch(error => {
215
- loadingIndicator.classList.add('hidden');
216
- alert('Ça a merdé: ' + error.message);
217
- });
218
- });
219
 
220
- function displayCurrentQuestion() {
221
- if (currentQuestionIndex >= quizQuestions.length) {
222
- showResults();
223
- return;
224
- }
225
 
226
- const question = quizQuestions[currentQuestionIndex];
227
- const progress = (currentQuestionIndex / 10) * 100;
228
- quizContainer.innerHTML = `
229
- <div class="progress-bar mb-6">
230
- <div class="progress-fill" id="progressFill" style="width: ${progress}%"></div>
231
- </div>
232
- <div class="question-card bg-white rounded-lg shadow-lg p-6">
233
- <h5 class="font-semibold text-xl mb-4 text-gray-800">${currentQuestionIndex + 1}. ${question.question}</h5>
234
- <div class="options mt-3"></div>
235
- <div class="explanation-container" id="explanation-${currentQuestionIndex}"></div>
236
- </div>
237
- `;
238
 
239
- const optionsContainer = quizContainer.querySelector('.options');
240
- question.options.forEach((option, oIndex) => {
241
- const optionElement = document.createElement('div');
242
- optionElement.className = 'option block p-3 my-2 border border-gray-200 rounded-md cursor-pointer hover:bg-gray-100 text-gray-800';
243
- optionElement.textContent = option;
244
- optionElement.onclick = () => selectOption(option, question.correctAnswer, oIndex);
245
- optionsContainer.appendChild(optionElement);
246
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }
 
 
248
 
249
- function selectOption(selectedOption, correctAnswer, optionIndex) {
250
- const options = quizContainer.querySelectorAll('.option');
251
- options.forEach(option => {
252
- option.onclick = null;
253
- option.classList.remove('cursor-pointer', 'hover:bg-gray-100');
254
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
 
256
- const selectedElement = options[optionIndex];
257
- const question = quizQuestions[currentQuestionIndex];
258
- const explanationContainer = document.getElementById(`explanation-${currentQuestionIndex}`);
 
259
 
260
- if (selectedOption === correctAnswer) {
261
- selectedElement.classList.add('correct-answer', 'text-white', 'border-green-500');
262
- score++;
263
- setTimeout(() => {
264
- currentQuestionIndex++;
265
- displayCurrentQuestion();
266
- }, 1000);
267
- } else {
268
- selectedElement.classList.add('wrong-answer', 'text-white', 'border-red-500');
269
- options.forEach(opt => {
270
- if (opt.textContent === correctAnswer) {
271
- opt.classList.add('correct-answer', 'text-white', 'border-green-500');
272
- }
273
- });
274
- explanationContainer.innerHTML = `
275
- <div class="flex items-center">
276
- <div class="character"></div>
277
- <div>
278
- <h3 class="text-lg font-semibold mb-2">Explication</h3>
279
- <p class="text-sm text-gray-700">${question.explanation}</p>
280
- </div>
281
- </div>
282
- `;
283
- explanationContainer.style.display = 'block';
284
- document.body.addEventListener('click', proceedToNextQuestion);
285
- }
286
- }
 
 
 
 
 
 
 
287
 
288
- function proceedToNextQuestion() {
289
- document.body.removeEventListener('click', proceedToNextQuestion);
290
- currentQuestionIndex++;
291
- displayCurrentQuestion();
 
292
  }
 
 
293
 
294
- function showResults() {
295
- const overlay = document.createElement('div');
296
- overlay.className = 'overlay';
297
- document.body.appendChild(overlay);
 
298
 
299
- const popup = document.createElement('div');
300
- popup.className = 'popup';
301
- const percentage = (score / 10) * 100;
302
- let suggestion = '';
303
- if (percentage < 50) {
304
- suggestion = 'Allez du nerf, c’est pas bon.';
305
- } else if (percentage < 80) {
306
- suggestion = 'Pas mal, mais t’as encore du taf pour tout déchirer.';
307
- } else {
308
- suggestion = 'WOW ! Tu gères grave, tu veux essayer un autre sujet ?';
309
- }
310
 
311
- popup.innerHTML = `
312
- <h2>Résultats</h2>
313
- <p>Score: ${score}/10 (${percentage}%)</p>
314
- <p class="mt-2">Détails: ${score} bonnes réponses, ${10 - score} ratées.</p>
315
- <p class="mt-4 font-semibold">${suggestion}</p>
316
- <button onclick="location.reload()">Rejouer</button>
317
- `;
318
- document.body.appendChild(popup);
319
- }
320
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  </body>
322
- </html>
 
1
  <!DOCTYPE html>
2
  <html lang="fr">
3
  <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Générateur de Flashcards & Quiz</title>
7
+ <!-- Inclusion de Tailwind CSS -->
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <!-- Inclusion de Google Fonts -->
10
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet" />
11
+ <style>
12
+ body {
13
+ font-family: 'Roboto', sans-serif;
14
+ }
15
+ /* Animation de survol pour les cartes et options */
16
+ .hover-transform {
17
+ transition: transform 0.3s ease, box-shadow 0.3s ease;
18
+ }
19
+ .hover-transform:hover {
20
+ transform: translateY(-4px);
21
+ box-shadow: 0 8px 16px rgba(0,0,0,0.1);
22
+ }
23
+ /* Animation de chargement personnalisée */
24
+ .spinner {
25
+ border: 4px solid rgba(0, 0, 0, 0.1);
26
+ width: 3rem;
27
+ height: 3rem;
28
+ border-radius: 50%;
29
+ border-left-color: #4f46e5;
30
+ animation: spin 1s linear infinite;
31
+ }
32
+ @keyframes spin {
33
+ to { transform: rotate(360deg); }
34
+ }
35
+ </style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  </head>
37
+ <body class="bg-gray-50">
38
+ <!-- En-tête -->
39
+ <header class="bg-gradient-to-r from-indigo-600 to-blue-500 py-6 shadow-lg">
40
+ <h1 class="text-center text-white text-4xl font-bold">Générateur de Flashcards & Quiz</h1>
41
+ </header>
42
 
43
+ <main class="container mx-auto px-4 py-8">
44
+ <!-- Section de configuration -->
45
+ <section class="max-w-2xl mx-auto mb-10">
46
+ <div class="bg-white rounded-xl shadow-lg p-8">
47
+ <div class="mb-6">
48
+ <label for="topic" class="block text-gray-700 text-lg font-medium mb-2">Sujet</label>
49
+ <input type="text" id="topic" placeholder="Entrez un sujet..."
50
+ class="w-full border border-gray-300 rounded-md p-3 focus:outline-none focus:ring-2 focus:ring-indigo-500" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  </div>
52
+ <div class="mb-6">
53
+ <span class="block text-gray-700 text-lg font-medium mb-2">Type de contenu</span>
54
+ <div class="flex space-x-6">
55
+ <label class="flex items-center space-x-2">
56
+ <input type="radio" name="contentType" value="flashcards" checked
57
+ class="form-radio h-5 w-5 text-indigo-600" />
58
+ <span class="text-gray-800">Flashcards</span>
59
+ </label>
60
+ <label class="flex items-center space-x-2">
61
+ <input type="radio" name="contentType" value="quiz"
62
+ class="form-radio h-5 w-5 text-indigo-600" />
63
+ <span class="text-gray-800">Quiz</span>
64
+ </label>
65
+ </div>
66
  </div>
67
+ <button id="generateBtn" class="w-full bg-indigo-600 text-white font-semibold py-3 rounded-md shadow hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 transition">
68
+ Générer
69
+ </button>
70
+ </div>
71
+ </section>
72
 
73
+ <!-- Indicateur de chargement -->
74
+ <section id="loading" class="hidden flex flex-col items-center justify-center my-10">
75
+ <div class="spinner mb-4"></div>
76
+ <p class="text-gray-600 text-lg">Génération en cours... Patientez quelques instants.</p>
77
+ </section>
 
 
 
78
 
79
+ <!-- Flashcards -->
80
+ <section id="flashcardsContainer" class="mt-8 hidden">
81
+ <div class="mb-6 text-center">
82
+ <h2 class="text-3xl font-semibold text-gray-800">Flashcards générées</h2>
83
+ <p class="text-gray-500">Cliquez sur une carte pour révéler la réponse</p>
84
+ </div>
85
+ <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6"></div>
86
+ </section>
87
 
88
+ <!-- Quiz -->
89
+ <section id="quizContainer" class="mt-8 max-w-3xl mx-auto hidden">
90
+ <div class="mb-6 text-center">
91
+ <h2 class="text-3xl font-semibold text-gray-800">Quiz généré</h2>
92
+ <p class="text-gray-500">Sélectionnez une réponse pour chaque question</p>
93
+ </div>
94
+ </section>
95
+ </main>
96
 
97
+ <footer class="bg-gray-100 py-4">
98
+ <p class="text-center text-gray-500 text-sm">© 2025 Générateur de Flashcards & Quiz. Tous droits réservés.</p>
99
+ </footer>
 
100
 
101
+ <script>
102
+ const generateBtn = document.getElementById('generateBtn');
103
+ const loadingIndicator = document.getElementById('loading');
104
+ const flashcardsContainer = document.getElementById('flashcardsContainer');
105
+ const quizContainer = document.getElementById('quizContainer');
106
+ const topicInput = document.getElementById('topic');
107
+
108
+ generateBtn.addEventListener('click', () => {
109
+ const topic = topicInput.value.trim();
110
+ if (!topic) {
111
+ alert('Veuillez entrer un sujet.');
112
+ return;
113
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
+ const contentType = document.querySelector('input[name="contentType"]:checked').value;
 
 
 
 
116
 
117
+ // Afficher le chargement et réinitialiser les sections
118
+ loadingIndicator.classList.remove('hidden');
119
+ flashcardsContainer.querySelector('.grid') && (flashcardsContainer.querySelector('.grid').innerHTML = '');
120
+ quizContainer.innerHTML = '';
121
+ flashcardsContainer.classList.add('hidden');
122
+ quizContainer.classList.add('hidden');
 
 
 
 
 
 
123
 
124
+ // Simulation d'appel API (remplacez par votre fetch)
125
+ setTimeout(() => {
126
+ loadingIndicator.classList.add('hidden');
127
+ // Exemple de données fictives pour le quiz
128
+ if (contentType === 'quiz') {
129
+ const data = {
130
+ quiz: [
131
+ {
132
+ question: "When did World War II begin?",
133
+ options: ["September 1, 1938", "September 2, 1945", "September 1, 1939", "December 7, 1941"],
134
+ correctAnswer: "September 1, 1939",
135
+ explanation: "World War II began on September 1, 1939, with the German invasion of Poland."
136
+ },
137
+ {
138
+ question: "Which event led the United States to enter World War II?",
139
+ options: ["The invasion of Poland", "The fall of France", "The attack on Pearl Harbor", "The Battle of Britain"],
140
+ correctAnswer: "The attack on Pearl Harbor",
141
+ explanation: "The Japanese attack on Pearl Harbor on December 7, 1941, prompted the United States to declare war."
142
+ }
143
+ ]
144
+ };
145
+ quizContainer.classList.remove('hidden');
146
+ displayQuiz(data.quiz);
147
+ } else {
148
+ // Exemple fictif pour les flashcards
149
+ const data = {
150
+ flashcards: [
151
+ { question: "Capital of France?", answer: "Paris" },
152
+ { question: "Capital of Spain?", answer: "Madrid" },
153
+ { question: "Capital of Italy?", answer: "Rome" }
154
+ ]
155
+ };
156
+ flashcardsContainer.classList.remove('hidden');
157
+ displayFlashcards(data.flashcards);
158
  }
159
+ }, 1500);
160
+ });
161
 
162
+ function displayFlashcards(flashcards) {
163
+ const gridContainer = flashcardsContainer.querySelector('.grid') || document.createElement('div');
164
+ if (!gridContainer.classList.contains('grid')) {
165
+ gridContainer.className = 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6';
166
+ flashcardsContainer.appendChild(gridContainer);
167
+ }
168
+ gridContainer.innerHTML = '';
169
+ flashcards.forEach((card, index) => {
170
+ const cardElement = document.createElement('div');
171
+ cardElement.className = 'bg-white rounded-xl shadow-lg p-6 cursor-pointer hover-transform';
172
+ cardElement.setAttribute('onclick', `toggleAnswer(${index})`);
173
+ cardElement.innerHTML = `
174
+ <h3 class="text-xl font-semibold text-gray-800 mb-4">${card.question}</h3>
175
+ <div id="answer-${index}" class="hidden text-gray-700 border-t border-gray-200 pt-4">
176
+ <span class="font-bold">Réponse:</span> ${card.answer}
177
+ </div>
178
+ `;
179
+ gridContainer.appendChild(cardElement);
180
+ });
181
+ }
182
 
183
+ function toggleAnswer(index) {
184
+ const answerElement = document.getElementById(`answer-${index}`);
185
+ answerElement.classList.toggle('hidden');
186
+ }
187
 
188
+ function displayQuiz(quizQuestions) {
189
+ quizQuestions.forEach((question, qIndex) => {
190
+ const questionCard = document.createElement('div');
191
+ questionCard.className = 'bg-white rounded-xl shadow-lg p-6 mb-6';
192
+ let optionsHtml = '';
193
+ // Sécuriser la réponse correcte
194
+ const safeCorrectAnswer = question.correctAnswer.replace(/"/g, '&quot;');
195
+ question.options.forEach((option, oIndex) => {
196
+ optionsHtml += `
197
+ <div class="option block p-3 my-2 border border-gray-200 rounded-md cursor-pointer hover-transform hover:bg-gray-50 text-gray-800"
198
+ id="q${qIndex}-o${oIndex}"
199
+ data-correct="${safeCorrectAnswer}"
200
+ onclick="selectOption(this, ${qIndex}, ${oIndex})">
201
+ ${option}
202
+ </div>
203
+ `;
204
+ });
205
+ questionCard.innerHTML = `
206
+ <h4 class="text-lg font-semibold text-gray-800 mb-4">${qIndex + 1}. ${question.question}</h4>
207
+ <div class="options">
208
+ ${optionsHtml}
209
+ </div>
210
+ <div id="explanation-${qIndex}" class="hidden mt-4 p-4 rounded-md bg-blue-50 border border-blue-200 text-blue-700 text-sm">
211
+ <strong>Explication:</strong> ${question.explanation}
212
+ </div>
213
+ `;
214
+ quizContainer.appendChild(questionCard);
215
+ });
216
+ }
217
+
218
+ function selectOption(element, questionIndex, optionIndex) {
219
+ const correctAnswer = element.dataset.correct;
220
+ const questionOptions = quizContainer.querySelectorAll(`#q${questionIndex}-o0`)[0].parentElement.querySelectorAll('.option');
221
+ const explanationElement = document.getElementById(`explanation-${questionIndex}`);
222
 
223
+ // Vérifier si une option a déjà été sélectionnée pour éviter le re-clic
224
+ let alreadyAnswered = false;
225
+ questionOptions.forEach(opt => {
226
+ if (opt.classList.contains('bg-green-100') || opt.classList.contains('bg-red-100')) {
227
+ alreadyAnswered = true;
228
  }
229
+ });
230
+ if (alreadyAnswered) return;
231
 
232
+ // Réinitialiser les styles pour toutes les options
233
+ questionOptions.forEach(option => {
234
+ option.classList.remove('bg-indigo-100', 'border-indigo-300', 'bg-green-100', 'border-green-300', 'text-green-800', 'bg-red-100', 'border-red-300', 'text-red-800');
235
+ option.classList.add('hover:bg-gray-50');
236
+ });
237
 
238
+ // Appliquer le style à l'option sélectionnée
239
+ element.classList.add('bg-indigo-100', 'border-indigo-300');
240
+ element.classList.remove('hover:bg-gray-50');
 
 
 
 
 
 
 
 
241
 
242
+ const selectedText = element.textContent.trim();
243
+ if (selectedText === correctAnswer) {
244
+ element.classList.remove('bg-indigo-100', 'border-indigo-300');
245
+ element.classList.add('bg-green-100', 'border-green-300', 'text-green-800');
246
+ } else {
247
+ element.classList.remove('bg-indigo-100', 'border-indigo-300');
248
+ element.classList.add('bg-red-100', 'border-red-300', 'text-red-800');
249
+ // Mettre en évidence la bonne réponse
250
+ questionOptions.forEach(option => {
251
+ if (option.textContent.trim() === correctAnswer) {
252
+ option.classList.add('bg-green-100', 'border-green-300', 'text-green-800');
253
+ option.classList.remove('hover:bg-gray-50');
254
+ }
255
+ });
256
+ }
257
+
258
+ // Désactiver les clics sur toutes les options de cette question
259
+ questionOptions.forEach(option => {
260
+ option.onclick = null;
261
+ option.classList.remove('cursor-pointer');
262
+ option.style.cursor = 'default';
263
+ });
264
+
265
+ // Afficher l'explication
266
+ explanationElement.classList.remove('hidden');
267
+ }
268
+ </script>
269
  </body>
270
+ </html>