Update templates/index.html
Browse files- templates/index.html +245 -297
templates/index.html
CHANGED
@@ -1,322 +1,270 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html lang="fr">
|
3 |
<head>
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
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="
|
123 |
-
|
124 |
-
|
|
|
|
|
125 |
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
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 |
-
|
153 |
-
|
154 |
-
<
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
</div>
|
|
|
|
|
|
|
|
|
|
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
<div id="currentQuestion"></div>
|
167 |
-
</div>
|
168 |
-
</div>
|
169 |
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
|
|
|
|
185 |
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
quizContainer.classList.add('hidden');
|
190 |
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
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 |
-
|
221 |
-
if (currentQuestionIndex >= quizQuestions.length) {
|
222 |
-
showResults();
|
223 |
-
return;
|
224 |
-
}
|
225 |
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
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 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
}
|
|
|
|
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
259 |
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
292 |
}
|
|
|
|
|
293 |
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
298 |
|
299 |
-
|
300 |
-
|
301 |
-
|
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 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, '"');
|
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>
|