File size: 22,871 Bytes
e21a5a1 4acd37f feed3c1 4acd37f feed3c1 741e703 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 bbc7bc4 feed3c1 bbc7bc4 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 bbc7bc4 feed3c1 bbc7bc4 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 4acd37f f87d6d7 feed3c1 4acd37f 741e703 feed3c1 f87d6d7 feed3c1 f87d6d7 cca0295 feed3c1 de8c46c 78bf8a4 de8c46c feed3c1 bbc7bc4 de8c46c 78bf8a4 de8c46c 78bf8a4 de8c46c 4393455 de8c46c 78bf8a4 4393455 78bf8a4 4393455 78bf8a4 de8c46c 4393455 de8c46c 4393455 78bf8a4 de8c46c 4393455 de8c46c feed3c1 78bf8a4 feed3c1 de8c46c f87d6d7 de8c46c 4393455 de8c46c 4393455 de8c46c 4393455 de8c46c 4393455 de8c46c f87d6d7 feed3c1 f87d6d7 feed3c1 de8c46c feed3c1 de8c46c 4393455 78bf8a4 feed3c1 de8c46c feed3c1 78bf8a4 feed3c1 de8c46c feed3c1 de8c46c 4393455 feed3c1 4393455 78bf8a4 4393455 78bf8a4 4393455 feed3c1 78bf8a4 feed3c1 78bf8a4 feed3c1 78bf8a4 feed3c1 de8c46c feed3c1 f87d6d7 feed3c1 f87d6d7 78bf8a4 feed3c1 f87d6d7 feed3c1 f87d6d7 feed3c1 f87d6d7 78bf8a4 feed3c1 78bf8a4 feed3c1 bbc7bc4 feed3c1 f87d6d7 feed3c1 4acd37f feed3c1 4acd37f bbc7bc4 feed3c1 78bf8a4 feed3c1 f87d6d7 78bf8a4 feed3c1 f87d6d7 feed3c1 bbc7bc4 feed3c1 de8c46c feed3c1 de8c46c feed3c1 de8c46c f87d6d7 66bd406 78bf8a4 feed3c1 f87d6d7 feed3c1 de8c46c 78bf8a4 de8c46c 78bf8a4 de8c46c 78bf8a4 feed3c1 78bf8a4 de8c46c bbc7bc4 de8c46c 78bf8a4 de8c46c 78bf8a4 de8c46c 78bf8a4 de8c46c 78bf8a4 f87d6d7 feed3c1 66bd406 feed3c1 78bf8a4 feed3c1 78bf8a4 feed3c1 f87d6d7 feed3c1 f87d6d7 de8c46c feed3c1 de8c46c 78bf8a4 |
1 2 3 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 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 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StudyGen - Générateur de Flashcards & Quiz</title>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary-blue: #2563eb;
--light-blue: #3b82f6;
--extra-light-blue: #eff6ff;
--white: #ffffff;
--gray-50: #f9fafb;
--gray-100: #f3f4f6;
--gray-300: #d1d5db;
--gray-600: #4b5563;
--gray-800: #1f2937;
--success: #10b981;
--error: #ef4444;
--shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
--shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: linear-gradient(135deg, var(--extra-light-blue) 0%, var(--white) 50%, var(--gray-50) 100%);
min-height: 100vh;
padding: 0;
color: var(--gray-800);
line-height: 1.6;
}
.container {
max-width: 100%;
padding: 20px 16px;
min-height: 100vh;
}
.header {
text-align: center;
margin-bottom: 32px;
padding: 20px 0;
}
.header h1 {
font-size: 2.5rem;
font-weight: 800;
background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 8px;
}
.header p {
color: var(--gray-600);
font-size: 1.1rem;
font-weight: 500;
}
.main-card {
background: var(--white);
border-radius: 24px;
padding: 24px;
box-shadow: var(--shadow);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
margin-bottom: 20px;
transform: translateY(0);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.main-card:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
}
.form-group {
margin-bottom: 24px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: 600;
color: var(--gray-800);
font-size: 0.95rem;
}
input[type="text"] {
width: 100%;
padding: 16px 20px;
border: 2px solid var(--gray-100);
border-radius: 16px;
font-size: 1rem;
transition: all 0.3s ease;
background: var(--gray-50);
color: var(--gray-800);
outline: none;
}
input[type="text"]:focus {
border-color: var(--primary-blue);
background: var(--white);
box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
transform: translateY(-1px);
}
.type-selector {
display: flex;
gap: 12px;
margin-bottom: 24px;
}
.type-option {
flex: 1;
position: relative;
}
.type-option input[type="radio"] {
display: none;
}
.type-option label {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 16px;
border: 2px solid var(--gray-200);
border-radius: 16px;
cursor: pointer;
transition: all 0.3s ease;
background: var(--white);
text-align: center;
margin-bottom: 0;
}
.type-option label:hover {
border-color: var(--light-blue);
transform: translateY(-2px);
}
.type-option input[type="radio"]:checked + label {
border-color: var(--primary-blue);
background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
color: var(--white);
box-shadow: var(--shadow);
}
.type-option i {
font-size: 2rem;
margin-bottom: 8px;
transition: transform 0.3s ease;
}
.type-option input[type="radio"]:checked + label i {
transform: scale(1.1);
}
.type-option span {
font-weight: 600;
font-size: 0.9rem;
}
.generate-btn {
width: 100%;
background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
color: var(--white);
border: none;
padding: 18px 24px;
border-radius: 16px;
font-size: 1.1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.generate-btn:hover {
transform: translateY(-2px);
box-shadow: var(--shadow-lg);
}
.generate-btn:active {
transform: translateY(0);
}
.generate-btn:disabled {
opacity: 0.7;
cursor: not-allowed;
transform: none;
}
.generate-btn .btn-text {
transition: opacity 0.3s ease;
}
.generate-btn .spinner {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
opacity: 0;
transition: opacity 0.3s ease;
}
.generate-btn.loading .btn-text {
opacity: 0;
}
.generate-btn.loading .spinner {
opacity: 1;
}
.spinner {
width: 24px;
height: 24px;
border: 3px solid rgba(255, 255, 255, 0.3);
border-radius: 50%;
border-top-color: var(--white);
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to { transform: translate(-50%, -50%) rotate(360deg); }
}
.results-container {
margin-top: 24px;
}
/* Styles pour le retournement des flashcards */
.flashcard-container {
perspective: 1000px;
margin-bottom: 16px;
}
.flashcard {
position: relative;
min-height: 150px;
transform-style: preserve-3d;
transition: transform 0.6s;
cursor: pointer;
}
.flashcard.is-flipped {
transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 24px;
border-radius: 20px;
background: var(--white);
box-shadow: var(--shadow);
border-left: 4px solid var(--primary-blue);
}
.flashcard-back {
transform: rotateY(180deg);
border-left-color: var(--success);
}
.flashcard h3 {
color: var(--primary-blue);
margin-bottom: 12px;
font-size: 1.1rem;
font-weight: 600;
text-align: center;
}
.flashcard .answer {
color: var(--gray-600);
text-align: center;
}
.flashcard-front::after {
content: 'Cliquez pour révéler';
position: absolute;
bottom: 15px;
font-size: 0.8rem;
color: var(--gray-300);
font-style: italic;
}
.quiz-question {
background: var(--white);
border-radius: 20px;
padding: 24px;
margin-bottom: 16px;
box-shadow: var(--shadow);
border-left: 4px solid var(--primary-blue);
transition: transform 0.3s ease;
}
.quiz-question:hover {
transform: translateX(4px);
}
.quiz-question h3 {
color: var(--primary-blue);
margin-bottom: 12px;
font-size: 1.1rem;
font-weight: 600;
}
.quiz-options {
margin: 16px 0;
}
.quiz-option {
padding: 12px 16px;
margin: 8px 0;
border: 2px solid var(--gray-100);
border-radius: 12px;
cursor: pointer;
transition: all 0.3s ease;
background: var(--white);
}
/* Désactive le clic une fois la réponse donnée */
.quiz-question.answered .quiz-option {
pointer-events: none;
opacity: 0.8;
}
.quiz-option:hover {
border-color: var(--light-blue);
background: var(--extra-light-blue);
}
.quiz-option.correct {
border-color: var(--success);
background: #f0fdf4;
color: #059669;
font-weight: bold;
}
.quiz-option.incorrect {
border-color: var(--error);
background: #fef2f2;
color: #dc2626;
}
.quiz-question.answered .quiz-option.correct {
opacity: 1;
}
.quiz-explanation {
margin-top: 16px;
padding: 16px;
background: var(--extra-light-blue);
border-radius: 12px;
border-left: 4px solid var(--primary-blue);
}
.error-message {
background: #fef2f2;
color: var(--error);
padding: 16px 20px;
border-radius: 12px;
border: 1px solid #fecaca;
margin-top: 16px;
text-align: center;
font-weight: 500;
}
.success-message {
background: #f0fdf4;
color: var(--success);
padding: 16px 20px;
border-radius: 12px;
border: 1px solid #bbf7d0;
margin-top: 16px;
text-align: center;
font-weight: 500;
}
.floating-elements {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: -1;
}
.floating-circle {
position: absolute;
border-radius: 50%;
background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(59, 130, 246, 0.05));
animation: float 6s ease-in-out infinite;
}
.floating-circle:nth-child(1) {
width: 80px;
height: 80px;
top: 10%;
left: 10%;
animation-delay: 0s;
}
.floating-circle:nth-child(2) {
width: 120px;
height: 120px;
top: 60%;
right: 10%;
animation-delay: 2s;
}
.floating-circle:nth-child(3) {
width: 100px;
height: 100px;
bottom: 20%;
left: 20%;
animation-delay: 4s;
}
@keyframes float {
0%, 100% { transform: translateY(0px) rotate(0deg); }
50% { transform: translateY(-20px) rotate(180deg); }
}
/* Animations d'entrée */
.fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* Responsive optimizations */
@media (min-width: 640px) {
.container {
max-width: 640px;
margin: 0 auto;
padding: 40px 24px;
}
.type-selector {
gap: 16px;
}
.main-card {
padding: 32px;
}
}
/* Accessibilité et focus states améliorés */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body>
<!-- Éléments flottants décoratifs -->
<div class="floating-elements">
<div class="floating-circle"></div>
<div class="floating-circle"></div>
<div class="floating-circle"></div>
</div>
<div class="container">
<div class="header">
<h1><i class="fas fa-graduation-cap"></i> StudyGen</h1>
<p>Créez des flashcards et quiz personnalisés en quelques secondes</p>
</div>
<div class="main-card">
<form id="generateForm">
<div class="form-group">
<label for="topic">
<i class="fas fa-lightbulb"></i> Sujet d'étude
</label>
<input
type="text"
id="topic"
name="topic"
placeholder="Ex: Les révolutions françaises, Python, Anatomie..."
required
>
</div>
<div class="form-group">
<label>
<i class="fas fa-tools"></i> Type de contenu
</label>
<div class="type-selector">
<div class="type-option">
<input type="radio" id="flashcards" name="type" value="flashcards" checked>
<label for="flashcards">
<i class="fas fa-clone"></i>
<span>Flashcards</span>
</label>
</div>
<div class="type-option">
<input type="radio" id="quiz" name="type" value="quiz">
<label for="quiz">
<i class="fas fa-question-circle"></i>
<span>Quiz</span>
</label>
</div>
</div>
</div>
<button type="submit" class="generate-btn" id="generateBtn">
<span class="btn-text">
<i class="fas fa-magic"></i> Générer le contenu
</span>
<div class="spinner"></div>
</button>
</form>
</div>
<div id="results" class="results-container"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('generateForm');
const generateBtn = document.getElementById('generateBtn');
const resultsContainer = document.getElementById('results');
form.addEventListener('submit', async function(e) {
e.preventDefault();
const topic = document.getElementById('topic').value.trim();
const type = document.querySelector('input[name="type"]:checked').value;
if (!topic) {
showMessage('Veuillez entrer un sujet d\'étude.', 'error');
return;
}
generateBtn.classList.add('loading');
generateBtn.disabled = true;
resultsContainer.innerHTML = '';
try {
// MODIFICATION : L'appel au backend a été restauré.
// La fonction de simulation a été supprimée.
const response = await fetch('/generate', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ topic, type })
});
const data = await response.json();
if (data.success) {
displayResults(data[type], type);
showMessage(`${type === 'flashcards' ? 'Flashcards' : 'Quiz'} généré avec succès !`, 'success');
} else {
showMessage(data.error || 'Une erreur est survenue lors de la génération.', 'error');
}
} catch (error) {
console.error('Erreur:', error);
showMessage('Erreur de connexion. Veuillez réessayer.', 'error');
} finally {
generateBtn.classList.remove('loading');
generateBtn.disabled = false;
}
});
function displayResults(data, type) {
resultsContainer.innerHTML = '';
if (type === 'flashcards') {
// Logique d'affichage pour les flashcards retournables
data.forEach((item, index) => {
const flashcardContainer = document.createElement('div');
flashcardContainer.className = 'flashcard-container fade-in';
flashcardContainer.style.animationDelay = `${index * 0.1}s`;
flashcardContainer.innerHTML = `
<div class="flashcard" onclick="this.classList.toggle('is-flipped')">
<div class="flashcard-front">
<h3><i class="fas fa-question"></i> ${item.question}</h3>
</div>
<div class="flashcard-back">
<div class="answer">
<i class="fas fa-lightbulb"></i> ${item.answer}
</div>
</div>
</div>
`;
resultsContainer.appendChild(flashcardContainer);
});
} else { // Quiz
// Logique d'affichage pour le quiz interactif
data.forEach((item, index) => {
const quizEl = document.createElement('div');
quizEl.className = 'quiz-question fade-in';
quizEl.style.animationDelay = `${index * 0.1}s`;
// On stocke la bonne réponse dans un attribut data-*
quizEl.dataset.correctAnswer = item.correctAnswer;
const optionsHtml = item.options.map(option => `
<div class="quiz-option" onclick="checkAnswer(this)">
${option}
</div>
`).join('');
quizEl.innerHTML = `
<h3><i class="fas fa-question-circle"></i> ${item.question}</h3>
<div class="quiz-options">${optionsHtml}</div>
<div class="quiz-explanation" style="display: none;">
<i class="fas fa-info-circle"></i> <strong>Explication :</strong> ${item.explanation}
</div>
`;
resultsContainer.appendChild(quizEl);
});
}
}
function showMessage(message, type) {
const messageEl = document.createElement('div');
messageEl.className = `${type}-message fade-in`;
messageEl.innerHTML = `
<i class="fas ${type === 'success' ? 'fa-check-circle' : 'fa-exclamation-circle'}"></i>
${message}
`;
const oldMessages = document.querySelectorAll('.error-message, .success-message');
oldMessages.forEach(msg => msg.remove());
resultsContainer.insertBefore(messageEl, resultsContainer.firstChild);
setTimeout(() => {
messageEl.remove();
}, 5000);
}
// Nouvelle fonction pour vérifier la réponse du quiz
window.checkAnswer = function(optionEl) {
const quizQuestion = optionEl.closest('.quiz-question');
if (quizQuestion.classList.contains('answered')) return; // Empêche de répondre à nouveau
quizQuestion.classList.add('answered');
const correctAnswer = quizQuestion.dataset.correctAnswer;
const selectedAnswer = optionEl.textContent.trim();
const explanation = quizQuestion.querySelector('.quiz-explanation');
const allOptions = quizQuestion.querySelectorAll('.quiz-option');
if (selectedAnswer === correctAnswer) {
optionEl.classList.add('correct');
} else {
optionEl.classList.add('incorrect');
}
allOptions.forEach(opt => {
const optText = opt.textContent.trim();
if (optText === correctAnswer) {
opt.classList.add('correct');
opt.innerHTML = `<i class="fas fa-check"></i> ${optText}`;
} else if (opt.classList.contains('incorrect')) {
opt.innerHTML = `<i class="fas fa-times"></i> ${optText}`;
}
});
explanation.style.display = 'block';
explanation.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
};
});
</script>
</body>
</html> |