Spaces:
Running
Running
File size: 55,772 Bytes
47c51a3 | 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 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3-р ангийн математик | Интерактив дасгал</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap');
body {
font-family: 'Montserrat', sans-serif;
background-color: #f0f9ff;
}
.progress-ring__circle {
transition: stroke-dashoffset 0.35s;
transform: rotate(-90deg);
transform-origin: 50% 50%;
}
.floating {
animation: floating 3s ease-in-out infinite;
}
@keyframes floating {
0% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
100% { transform: translateY(0px); }
}
.bounce {
animation: bounce 1s infinite;
}
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
</style>
</head>
<body class="min-h-screen">
<!-- Header -->
<header class="bg-blue-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-2">
<i class="fas fa-calculator text-3xl"></i>
<h1 class="text-2xl font-bold">3-р ангийн математик</h1>
</div>
<div class="flex items-center space-x-4">
<div id="score-display" class="flex items-center bg-blue-500 px-3 py-1 rounded-full">
<i class="fas fa-star text-yellow-300 mr-1"></i>
<span id="score">0</span>
</div>
<button id="sound-btn" class="p-2 rounded-full bg-blue-500 hover:bg-blue-700 transition">
<i class="fas fa-volume-up"></i>
</button>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<!-- Welcome Section -->
<section id="welcome-section" class="text-center mb-12">
<div class="max-w-3xl mx-auto">
<div class="floating inline-block mb-6">
<img src="https://img.icons8.com/color/96/000000/math.png" alt="Math Icon" class="w-24 h-24">
</div>
<h2 class="text-3xl font-bold text-blue-800 mb-4">Математикийн дугуйланд тавтай морил!</h2>
<p class="text-lg text-gray-700 mb-6">3-р ангийн математикийн бүх сэдвээр дасгал хийж, чадвараа сайжруулна уу!</p>
<button id="start-btn" class="bg-green-500 hover:bg-green-600 text-white font-bold py-3 px-8 rounded-full text-lg shadow-lg transition transform hover:scale-105">
Эхлэх <i class="fas fa-arrow-right ml-2"></i>
</button>
</div>
</section>
<!-- Topic Selection -->
<section id="topic-section" class="hidden mb-12">
<h2 class="text-2xl font-bold text-center text-blue-800 mb-8">Сэдвээр сонгох</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Topic Cards -->
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="addition">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-blue-100 p-3 rounded-full mr-4">
<i class="fas fa-plus text-blue-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Нэмэх үйлдэл</h3>
</div>
<p class="text-gray-600">2-3 оронтой тоонуудын нэмэх үйлдэл</p>
</div>
</div>
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="subtraction">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-red-100 p-3 rounded-full mr-4">
<i class="fas fa-minus text-red-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Хасах үйлдэл</h3>
</div>
<p class="text-gray-600">2-3 оронтой тоонуудын хасах үйлдэл</p>
</div>
</div>
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="multiplication">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-yellow-100 p-3 rounded-full mr-4">
<i class="fas fa-times text-yellow-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Үржүүлэх үйлдэл</h3>
</div>
<p class="text-gray-600">1-2 оронтой тоонуудын үржүүлэх</p>
</div>
</div>
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="division">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-purple-100 p-3 rounded-full mr-4">
<i class="fas fa-divide text-purple-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Хуваах үйлдэл</h3>
</div>
<p class="text-gray-600">2 оронтой тоог 1 оронтой тоонд хуваах</p>
</div>
</div>
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="fractions">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-pink-100 p-3 rounded-full mr-4">
<i class="fas fa-superscript text-pink-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Бутархай тоо</h3>
</div>
<p class="text-gray-600">Энгийн бутархай тоонуудын үйлдэл</p>
</div>
</div>
<div class="topic-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer" data-topic="geometry">
<div class="p-6">
<div class="flex items-center mb-4">
<div class="bg-green-100 p-3 rounded-full mr-4">
<i class="fas fa-shapes text-green-600 text-xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800">Геометр</h3>
</div>
<p class="text-gray-600">Дүрсүүдийн талаарх мэдлэг</p>
</div>
</div>
</div>
</section>
<!-- Difficulty Selection -->
<section id="difficulty-section" class="hidden mb-12">
<h2 class="text-2xl font-bold text-center text-blue-800 mb-8">Хэмжээ сонгох</h2>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 max-w-4xl mx-auto">
<div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="easy">
<div class="bg-green-100 p-4 rounded-full inline-block mb-4">
<i class="fas fa-smile text-green-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Амархан</h3>
<p class="text-gray-600">Энгийн дасгалууд</p>
</div>
<div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="medium">
<div class="bg-yellow-100 p-4 rounded-full inline-block mb-4">
<i class="fas fa-meh text-yellow-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Дунд зэрэг</h3>
<p class="text-gray-600">Дунд зэргийн дасгалууд</p>
</div>
<div class="difficulty-card bg-white rounded-xl shadow-md overflow-hidden hover:shadow-xl transition cursor-pointer p-6 text-center" data-difficulty="hard">
<div class="bg-red-100 p-4 rounded-full inline-block mb-4">
<i class="fas fa-frown text-red-600 text-3xl"></i>
</div>
<h3 class="text-xl font-bold text-gray-800 mb-2">Хэцүү</h3>
<p class="text-gray-600">Хэцүү дасгалууд</p>
</div>
</div>
</section>
<!-- Quiz Section -->
<section id="quiz-section" class="hidden">
<div class="max-w-3xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Progress Bar -->
<div class="bg-gray-200 h-2">
<div id="progress-bar" class="bg-blue-600 h-2 transition-all duration-300" style="width: 0%"></div>
</div>
<div class="p-6 md:p-8">
<!-- Question Counter -->
<div class="flex justify-between items-center mb-6">
<div class="flex items-center">
<span id="question-counter" class="font-bold text-blue-600">1/10</span>
</div>
<div class="flex items-center space-x-2">
<div class="relative w-12 h-12">
<svg class="w-full h-full" viewBox="0 0 36 36">
<circle cx="18" cy="18" r="16" fill="none" class="stroke-gray-200" stroke-width="2"></circle>
<circle id="timer-circle" cx="18" cy="18" r="16" fill="none" class="stroke-blue-600 progress-ring__circle" stroke-width="2" stroke-dasharray="100" stroke-dashoffset="0"></circle>
</svg>
<span id="timer" class="absolute inset-0 flex items-center justify-center text-sm font-bold">30</span>
</div>
</div>
</div>
<!-- Question -->
<div id="question-container" class="mb-8">
<h3 id="question" class="text-xl font-bold text-gray-800 mb-4"></h3>
<!-- For normal questions -->
<div id="options-container" class="grid grid-cols-1 md:grid-cols-2 gap-3"></div>
<!-- For input questions -->
<div id="input-container" class="hidden mt-4">
<input type="number" id="answer-input" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500" placeholder="Хариултаа оруулна уу...">
<button id="submit-answer" class="mt-3 bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg transition">
Илгээх <i class="fas fa-paper-plane ml-1"></i>
</button>
</div>
</div>
<!-- Feedback -->
<div id="feedback-container" class="hidden p-4 rounded-lg mb-6">
<div class="flex items-start">
<i id="feedback-icon" class="text-2xl mt-1 mr-3"></i>
<div>
<h4 id="feedback-title" class="font-bold"></h4>
<p id="feedback-message" class="text-sm"></p>
</div>
</div>
</div>
<!-- Navigation -->
<div class="flex justify-between">
<button id="back-btn" class="bg-gray-300 hover:bg-gray-400 text-gray-800 font-bold py-2 px-4 rounded-lg transition hidden">
<i class="fas fa-arrow-left mr-2"></i> Буцах
</button>
<button id="next-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded-lg transition ml-auto">
Дараах <i class="fas fa-arrow-right ml-2"></i>
</button>
</div>
</div>
</div>
</section>
<!-- Results Section -->
<section id="results-section" class="hidden max-w-3xl mx-auto text-center">
<div class="bg-white rounded-xl shadow-lg overflow-hidden p-8">
<div class="mb-6">
<div class="relative w-32 h-32 mx-auto mb-6">
<svg class="w-full h-full" viewBox="0 0 36 36">
<circle cx="18" cy="18" r="16" fill="none" class="stroke-gray-200" stroke-width="2"></circle>
<circle id="result-circle" cx="18" cy="18" r="16" fill="none" class="stroke-green-500 progress-ring__circle" stroke-width="2" stroke-dasharray="100" stroke-dashoffset="0"></circle>
</svg>
<span id="result-percent" class="absolute inset-0 flex items-center justify-center text-2xl font-bold">0%</span>
</div>
<h2 class="text-3xl font-bold text-gray-800 mb-2" id="result-title">Сайн байна!</h2>
<p class="text-gray-600 mb-4" id="result-message">Та <span id="correct-answers">0</span> асуултанд зөв хариулсан!</p>
<div class="flex justify-center space-x-2 mb-6">
<div id="star-1" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
<div id="star-2" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
<div id="star-3" class="text-gray-300 text-2xl"><i class="fas fa-star"></i></div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-8">
<div class="bg-blue-50 p-4 rounded-lg">
<div class="text-blue-600 font-bold text-lg" id="score-earned">0</div>
<div class="text-gray-600 text-sm">Оноо</div>
</div>
<div class="bg-green-50 p-4 rounded-lg">
<div class="text-green-600 font-bold text-lg" id="time-taken">0с</div>
<div class="text-gray-600 text-sm">Хугацаа</div>
</div>
</div>
<div class="flex flex-col space-y-3">
<button id="restart-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-bold py-3 px-6 rounded-lg transition">
Дахь эхлэх <i class="fas fa-redo ml-2"></i>
</button>
<button id="new-topic-btn" class="bg-white hover:bg-gray-100 text-blue-600 font-bold py-3 px-6 border border-blue-600 rounded-lg transition">
Шинэ сэдвээр дасгал хийх <i class="fas fa-book-open ml-2"></i>
</button>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-6">
<div class="container mx-auto px-4 text-center">
<p>3-р ангийн математикийн интерактив дасгалууд</p>
<p class="text-gray-400 text-sm mt-2">© 2023 Боловсролын технологи</p>
</div>
</footer>
<!-- Confetti Effect -->
<canvas id="confetti-canvas" class="fixed top-0 left-0 w-full h-full pointer-events-none z-50 hidden"></canvas>
<script>
// App State
const state = {
currentScreen: 'welcome',
selectedTopic: null,
selectedDifficulty: null,
questions: [],
currentQuestionIndex: 0,
score: 0,
correctAnswers: 0,
timer: 30,
timerInterval: null,
startTime: null,
soundEnabled: true,
topics: {
addition: {
title: "Нэмэх үйлдэл",
icon: "fa-plus",
color: "blue",
questions: {
easy: [
{ question: "25 + 34 = ?", answer: "59", options: ["53", "59", "64", "69"] },
{ question: "47 + 18 = ?", answer: "65", options: ["55", "59", "65", "69"] },
{ question: "63 + 29 = ?", answer: "92", options: ["82", "87", "92", "97"] },
{ question: "56 + 37 = ?", answer: "93", options: ["83", "89", "93", "97"] },
{ question: "78 + 15 = ?", answer: "93", options: ["83", "88", "93", "98"] }
],
medium: [
{ question: "125 + 234 = ?", answer: "359", options: ["349", "359", "369", "379"] },
{ question: "147 + 218 = ?", answer: "365", options: ["355", "365", "375", "385"] },
{ question: "263 + 129 = ?", answer: "392", options: ["382", "387", "392", "397"] },
{ question: "356 + 237 = ?", answer: "593", options: ["583", "589", "593", "597"] },
{ question: "478 + 315 = ?", answer: "793", options: ["783", "788", "793", "798"] }
],
hard: [
{ question: "425 + 334 + 125 = ?", answer: "884", options: ["874", "879", "884", "889"] },
{ question: "547 + 218 + 135 = ?", answer: "900", options: ["890", "895", "900", "905"] },
{ question: "663 + 229 + 178 = ?", answer: "1070", options: ["1060", "1065", "1070", "1075"] },
{ question: "756 + 337 + 289 = ?", answer: "1382", options: ["1372", "1377", "1382", "1387"] },
{ question: "878 + 415 + 326 = ?", answer: "1619", options: ["1609", "1614", "1619", "1624"] }
]
}
},
subtraction: {
title: "Хасах үйлдэл",
icon: "fa-minus",
color: "red",
questions: {
easy: [
{ question: "45 - 23 = ?", answer: "22", options: ["12", "18", "22", "28"] },
{ question: "67 - 19 = ?", answer: "48", options: ["42", "48", "52", "58"] },
{ question: "83 - 27 = ?", answer: "56", options: ["46", "56", "66", "76"] },
{ question: "95 - 38 = ?", answer: "57", options: ["47", "57", "67", "77"] },
{ question: "72 - 45 = ?", answer: "27", options: ["17", "27", "37", "47"] }
],
medium: [
{ question: "145 - 23 = ?", answer: "122", options: ["112", "118", "122", "128"] },
{ question: "267 - 119 = ?", answer: "148", options: ["142", "148", "152", "158"] },
{ question: "383 - 127 = ?", answer: "256", options: ["246", "256", "266", "276"] },
{ question: "495 - 238 = ?", answer: "257", options: ["247", "257", "267", "277"] },
{ question: "572 - 345 = ?", answer: "227", options: ["217", "227", "237", "247"] }
],
hard: [
{ question: "425 - 134 - 125 = ?", answer: "166", options: ["156", "161", "166", "171"] },
{ question: "547 - 218 - 135 = ?", answer: "194", options: ["184", "189", "194", "199"] },
{ question: "763 - 229 - 178 = ?", answer: "356", options: ["346", "351", "356", "361"] },
{ question: "856 - 337 - 289 = ?", answer: "230", options: ["220", "225", "230", "235"] },
{ question: "978 - 415 - 326 = ?", answer: "237", options: ["227", "232", "237", "242"] }
]
}
},
multiplication: {
title: "Үржүүлэх үйлдэл",
icon: "fa-times",
color: "yellow",
questions: {
easy: [
{ question: "5 × 7 = ?", answer: "35", options: ["25", "30", "35", "40"] },
{ question: "8 × 6 = ?", answer: "48", options: ["38", "42", "48", "54"] },
{ question: "9 × 4 = ?", answer: "36", options: ["27", "32", "36", "40"] },
{ question: "7 × 9 = ?", answer: "63", options: ["54", "56", "63", "70"] },
{ question: "6 × 8 = ?", answer: "48", options: ["40", "42", "48", "56"] }
],
medium: [
{ question: "12 × 7 = ?", answer: "84", options: ["72", "77", "84", "91"] },
{ question: "15 × 6 = ?", answer: "90", options: ["75", "80", "90", "100"] },
{ question: "11 × 11 = ?", answer: "121", options: ["100", "110", "121", "132"] },
{ question: "13 × 8 = ?", answer: "104", options: ["91", "96", "104", "112"] },
{ question: "14 × 9 = ?", answer: "126", options: ["112", "117", "126", "133"] }
],
hard: [
{ question: "25 × 12 = ?", answer: "300", options: ["250", "275", "300", "325"] },
{ question: "34 × 15 = ?", answer: "510", options: ["450", "480", "510", "540"] },
{ question: "18 × 22 = ?", answer: "396", options: ["360", "378", "396", "414"] },
{ question: "27 × 14 = ?", answer: "378", options: ["350", "364", "378", "392"] },
{ question: "19 × 21 = ?", answer: "399", options: ["361", "380", "399", "418"] }
]
}
},
division: {
title: "Хуваах үйлдэл",
icon: "fa-divide",
color: "purple",
questions: {
easy: [
{ question: "36 ÷ 6 = ?", answer: "6", options: ["4", "5", "6", "7"] },
{ question: "42 ÷ 7 = ?", answer: "6", options: ["5", "6", "7", "8"] },
{ question: "56 ÷ 8 = ?", answer: "7", options: ["6", "7", "8", "9"] },
{ question: "72 ÷ 9 = ?", answer: "8", options: ["7", "8", "9", "10"] },
{ question: "45 ÷ 5 = ?", answer: "9", options: ["8", "9", "10", "11"] }
],
medium: [
{ question: "144 ÷ 12 = ?", answer: "12", options: ["10", "11", "12", "13"] },
{ question: "169 ÷ 13 = ?", answer: "13", options: ["11", "12", "13", "14"] },
{ question: "196 ÷ 14 = ?", answer: "14", options: ["12", "13", "14", "15"] },
{ question: "225 ÷ 15 = ?", answer: "15", options: ["13", "14", "15", "16"] },
{ question: "256 ÷ 16 = ?", answer: "16", options: ["14", "15", "16", "17"] }
],
hard: [
{ question: "576 ÷ 24 = ?", answer: "24", options: ["22", "23", "24", "25"] },
{ question: "625 ÷ 25 = ?", answer: "25", options: ["23", "24", "25", "26"] },
{ question: "676 ÷ 26 = ?", answer: "26", options: ["24", "25", "26", "27"] },
{ question: "729 ÷ 27 = ?", answer: "27", options: ["25", "26", "27", "28"] },
{ question: "784 ÷ 28 = ?", answer: "28", options: ["26", "27", "28", "29"] }
]
}
},
fractions: {
title: "Бутархай тоо",
icon: "fa-superscript",
color: "pink",
questions: {
easy: [
{ question: "1/2 + 1/4 = ?", answer: "3/4", options: ["1/4", "1/2", "3/4", "1"] },
{ question: "3/4 - 1/4 = ?", answer: "1/2", options: ["1/4", "1/2", "3/4", "1"] },
{ question: "1/3 + 1/3 = ?", answer: "2/3", options: ["1/3", "1/2", "2/3", "3/4"] },
{ question: "5/6 - 1/6 = ?", answer: "2/3", options: ["1/3", "1/2", "2/3", "3/4"] },
{ question: "1/2 × 1/2 = ?", answer: "1/4", options: ["1/8", "1/4", "1/2", "3/4"] }
],
medium: [
{ question: "2/3 + 3/4 = ?", answer: "17/12", options: ["5/7", "11/12", "17/12", "5/4"] },
{ question: "5/6 - 2/3 = ?", answer: "1/6", options: ["1/6", "1/3", "1/2", "2/3"] },
{ question: "3/4 × 2/3 = ?", answer: "1/2", options: ["1/4", "1/2", "3/4", "5/6"] },
{ question: "4/5 ÷ 2/5 = ?", answer: "2", options: ["1/2", "1", "2", "4"] },
{ question: "1/2 + 1/3 + 1/6 = ?", answer: "1", options: ["2/3", "5/6", "1", "7/6"] }
],
hard: [
{ question: "3 1/2 + 2 3/4 = ?", answer: "25/4", options: ["21/4", "23/4", "25/4", "27/4"] },
{ question: "4 2/3 - 1 5/6 = ?", answer: "17/6", options: ["13/6", "15/6", "17/6", "19/6"] },
{ question: "2 1/4 × 1 1/3 = ?", answer: "3", options: ["2", "2 1/2", "3", "3 1/2"] },
{ question: "3 3/4 ÷ 1 1/2 = ?", answer: "5/2", options: ["3/2", "2", "5/2", "3"] },
{ question: "1/2 + 2/3 - 1/4 = ?", answer: "11/12", options: ["5/12", "7/12", "11/12", "13/12"] }
]
}
},
geometry: {
title: "Геометр",
icon: "fa-shapes",
color: "green",
questions: {
easy: [
{ question: "3 талтай дүрсийг юу гэж нэрлэдэг вэ?", answer: "Гурвалжин", options: ["Дөрвөлжин", "Гурвалжин", "Тэгш өнцөгт", "Тойрог"] },
{ question: "4 тэнцүү талтай дүрсийг юу гэж нэрлэдэг вэ?", answer: "Квадрат", options: ["Тэгш өнцөгт", "Ромб", "Квадрат", "Параллелограмм"] },
{ question: "Тойргийн голч нь радиусын хэд дахин урт вэ?", answer: "2", options: ["1", "2", "3", "4"] },
{ question: "90 градусын өнцөгтэй гурвалжинг юу гэж нэрлэдэг вэ?", answer: "Тэгш өнцөгт", options: ["Хурц өнцөгт", "Тэгш өнцөгт", "Мохоо өнцөгт", "Тэгш талт"] },
{ question: "5 талтай олон өнцөгтийг юу гэж нэрлэдэг вэ?", answer: "Пентагон", options: ["Тетрагон", "Пентагон", "Гексагон", "Хептагон"] }
],
medium: [
{ question: "Куб хэдэн ирмэгтэй вэ?", answer: "12", options: ["6", "8", "12", "16"] },
{ question: "Тэгш өнцөгт призмийн эзлэхүүнийг хэрхэн олдог вэ?", answer: "Урт × Өргөн × Өндөр", options: ["Урт + Өргөн + Өндөр", "Урт × Өргөн", "Урт × Өргөн × Өндөр", "Урт × Өндөр"] },
{ question: "360 градусын өнцөгтэй дүрсийг юу гэж нэрлэдэг вэ?", answer: "Тойрог", options: ["Гурвалжин", "Дөрвөлжин", "Тэгш өнцөгт", "Тойрог"] },
{ question: "Параллелограммын эсрэг талууд ямар байдаг вэ?", answer: "Зэрэгцээ ба тэнцүү", options: ["Зөвхөн тэнцүү", "Зөвхөн зэрэгцээ", "Зэрэгцээ ба тэнцүү", "Янз бүр"] },
{ question: "Гурвалжны дотоод өнцгүүдийн нийлбэр хэд вэ?", answer: "180°", options: ["90°", "120°", "180°", "360°"] }
],
hard: [
{ question: "Ижил суурьтай, ижил өндөртэй пирамид ба призмийн эзлэхүүний харьцаа хэд вэ?", answer: "1:3", options: ["1:1", "1:2", "1:3", "2:3"] },
{ question: "Тойргийн талбайг πr² томъёогоор олдог бол тойргийн тойргийн уртыг ямар томъёогоор олдог вэ?", answer: "2πr", options: ["πr", "2πr", "πr²", "4πr"] },
{ question: "Тетраэдр хэдэн нүүртэй вэ?", answer: "4", options: ["3", "4", "5", "6"] },
{ question: "Координатын хавтгайд (3,4) ба (7,1) цэгүүдийн хоорондох зайг ол.", answer: "5", options: ["3", "4", "5", "6"] },
{ question: "Тэгш талт гурвалжны өндөр нь 6√3 бол талын урт хэд вэ?", answer: "12", options: ["6", "8", "10", "12"] }
]
}
}
}
};
// DOM Elements
const elements = {
welcomeSection: document.getElementById('welcome-section'),
topicSection: document.getElementById('topic-section'),
difficultySection: document.getElementById('difficulty-section'),
quizSection: document.getElementById('quiz-section'),
resultsSection: document.getElementById('results-section'),
startBtn: document.getElementById('start-btn'),
topicCards: document.querySelectorAll('.topic-card'),
difficultyCards: document.querySelectorAll('.difficulty-card'),
questionContainer: document.getElementById('question-container'),
question: document.getElementById('question'),
optionsContainer: document.getElementById('options-container'),
inputContainer: document.getElementById('input-container'),
answerInput: document.getElementById('answer-input'),
submitAnswer: document.getElementById('submit-answer'),
feedbackContainer: document.getElementById('feedback-container'),
feedbackIcon: document.getElementById('feedback-icon'),
feedbackTitle: document.getElementById('feedback-title'),
feedbackMessage: document.getElementById('feedback-message'),
backBtn: document.getElementById('back-btn'),
nextBtn: document.getElementById('next-btn'),
progressBar: document.getElementById('progress-bar'),
questionCounter: document.getElementById('question-counter'),
timerCircle: document.getElementById('timer-circle'),
timer: document.getElementById('timer'),
resultCircle: document.getElementById('result-circle'),
resultPercent: document.getElementById('result-percent'),
resultTitle: document.getElementById('result-title'),
resultMessage: document.getElementById('result-message'),
correctAnswers: document.getElementById('correct-answers'),
scoreEarned: document.getElementById('score-earned'),
timeTaken: document.getElementById('time-taken'),
restartBtn: document.getElementById('restart-btn'),
newTopicBtn: document.getElementById('new-topic-btn'),
scoreDisplay: document.getElementById('score'),
soundBtn: document.getElementById('sound-btn'),
confettiCanvas: document.getElementById('confetti-canvas'),
star1: document.getElementById('star-1'),
star2: document.getElementById('star-2'),
star3: document.getElementById('star-3')
};
// Event Listeners
elements.startBtn.addEventListener('click', showTopicSelection);
elements.topicCards.forEach(card => {
card.addEventListener('click', () => selectTopic(card.dataset.topic));
});
elements.difficultyCards.forEach(card => {
card.addEventListener('click', () => selectDifficulty(card.dataset.difficulty));
});
elements.backBtn.addEventListener('click', goToPreviousQuestion);
elements.nextBtn.addEventListener('click', goToNextQuestion);
elements.submitAnswer.addEventListener('click', checkInputAnswer);
elements.answerInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') checkInputAnswer();
});
elements.restartBtn.addEventListener('click', restartQuiz);
elements.newTopicBtn.addEventListener('click', startNewTopic);
elements.soundBtn.addEventListener('click', toggleSound);
// Initialize
function init() {
updateScreen('welcome');
updateScoreDisplay();
}
// Screen Management
function updateScreen(screen) {
state.currentScreen = screen;
elements.welcomeSection.classList.add('hidden');
elements.topicSection.classList.add('hidden');
elements.difficultySection.classList.add('hidden');
elements.quizSection.classList.add('hidden');
elements.resultsSection.classList.add('hidden');
if (screen === 'welcome') {
elements.welcomeSection.classList.remove('hidden');
} else if (screen === 'topic') {
elements.topicSection.classList.remove('hidden');
} else if (screen === 'difficulty') {
elements.difficultySection.classList.remove('hidden');
} else if (screen === 'quiz') {
elements.quizSection.classList.remove('hidden');
startQuiz();
} else if (screen === 'results') {
elements.resultsSection.classList.remove('hidden');
showResults();
}
}
function showTopicSelection() {
updateScreen('topic');
}
function selectTopic(topic) {
state.selectedTopic = topic;
updateScreen('difficulty');
}
function selectDifficulty(difficulty) {
state.selectedDifficulty = difficulty;
state.questions = state.topics[state.selectedTopic].questions[state.selectedDifficulty];
updateScreen('quiz');
}
// Quiz Functions
function startQuiz() {
state.currentQuestionIndex = 0;
state.correctAnswers = 0;
state.startTime = new Date();
loadQuestion();
startTimer();
}
function loadQuestion() {
const currentQuestion = state.questions[state.currentQuestionIndex];
// Update progress
const progress = ((state.currentQuestionIndex) / state.questions.length) * 100;
elements.progressBar.style.width = `${progress}%`;
elements.questionCounter.textContent = `${state.currentQuestionIndex + 1}/${state.questions.length}`;
// Show/hide navigation buttons
elements.backBtn.classList.toggle('hidden', state.currentQuestionIndex === 0);
elements.nextBtn.textContent = state.currentQuestionIndex === state.questions.length - 1 ? 'Дуусгах' : 'Дараах';
// Set question
elements.question.textContent = currentQuestion.question;
// Clear previous feedback
elements.feedbackContainer.classList.add('hidden');
// Check question type and display appropriately
if (currentQuestion.options) {
// Multiple choice question
elements.optionsContainer.classList.remove('hidden');
elements.inputContainer.classList.add('hidden');
// Clear previous options
elements.optionsContainer.innerHTML = '';
// Add new options
currentQuestion.options.forEach((option, index) => {
const optionElement = document.createElement('button');
optionElement.className = 'bg-white hover:bg-gray-100 border border-gray-300 text-gray-800 font-medium py-3 px-4 rounded-lg transition';
optionElement.textContent = option;
optionElement.dataset.answer = option;
optionElement.addEventListener('click', () => selectAnswer(option));
elements.optionsContainer.appendChild(optionElement);
});
} else {
// Input answer question
elements.optionsContainer.classList.add('hidden');
elements.inputContainer.classList.remove('hidden');
elements.answerInput.value = '';
elements.answerInput.focus();
}
}
function selectAnswer(selectedAnswer) {
const currentQuestion = state.questions[state.currentQuestionIndex];
const isCorrect = selectedAnswer === currentQuestion.answer;
// Disable all options
const optionButtons = elements.optionsContainer.querySelectorAll('button');
optionButtons.forEach(button => {
button.disabled = true;
if (button.dataset.answer === currentQuestion.answer) {
button.classList.add('bg-green-100', 'border-green-500');
} else if (button.dataset.answer === selectedAnswer && !isCorrect) {
button.classList.add('bg-red-100', 'border-red-500');
}
});
showFeedback(isCorrect, currentQuestion.answer);
}
function checkInputAnswer() {
const userAnswer = elements.answerInput.value.trim();
const currentQuestion = state.questions[state.currentQuestionIndex];
const isCorrect = userAnswer === currentQuestion.answer;
showFeedback(isCorrect, currentQuestion.answer);
}
function showFeedback(isCorrect, correctAnswer) {
if (isCorrect) {
state.correctAnswers++;
state.score += 10 * (state.timer / 5); // More points for faster answers
updateScoreDisplay();
elements.feedbackContainer.className = 'bg-green-100 border border-green-400 text-green-700 p-4 rounded-lg mb-6';
elements.feedbackIcon.className = 'fas fa-check-circle text-green-500 text-2xl mt-1 mr-3';
elements.feedbackTitle.textContent = 'Зөв байна!';
elements.feedbackMessage.textContent = 'Та маш сайн!';
playSound('correct');
} else {
elements.feedbackContainer.className = 'bg-red-100 border border-red-400 text-red-700 p-4 rounded-lg mb-6';
elements.feedbackIcon.className = 'fas fa-times-circle text-red-500 text-2xl mt-1 mr-3';
elements.feedbackTitle.textContent = 'Буруу байна!';
elements.feedbackMessage.textContent = `Зөв хариулт: ${correctAnswer}`;
playSound('wrong');
}
elements.feedbackContainer.classList.remove('hidden');
stopTimer();
}
function goToPreviousQuestion() {
if (state.currentQuestionIndex > 0) {
state.currentQuestionIndex--;
loadQuestion();
resetTimer();
}
}
function goToNextQuestion() {
if (state.currentQuestionIndex < state.questions.length - 1) {
state.currentQuestionIndex++;
loadQuestion();
resetTimer();
} else {
finishQuiz();
}
}
function finishQuiz() {
stopTimer();
updateScreen('results');
}
function showResults() {
const percentage = Math.round((state.correctAnswers / state.questions.length) * 100);
const endTime = new Date();
const timeTaken = Math.floor((endTime - state.startTime) / 1000);
// Animate result circle
const circle = elements.resultCircle;
const radius = circle.r.baseVal.value;
const circumference = 2 * Math.PI * radius;
const offset = circumference - (percentage / 100) * circumference;
circle.style.strokeDashoffset = offset;
circle.style.strokeDasharray = circumference;
// Animate percentage counter
let counter = 0;
const interval = setInterval(() => {
if (counter >= percentage) {
clearInterval(interval);
} else {
counter++;
elements.resultPercent.textContent = `${counter}%`;
}
}, 20);
// Set result text
elements.correctAnswers.textContent = state.correctAnswers;
elements.scoreEarned.textContent = Math.floor(state.score);
elements.timeTaken.textContent = `${timeTaken}с`;
// Set result title based on performance
if (percentage >= 80) {
elements.resultTitle.textContent = 'Гайхалтай!';
elements.resultTitle.className = 'text-3xl font-bold text-green-600 mb-2';
animateStars();
triggerConfetti();
playSound('success');
} else if (percentage >= 50) {
elements.resultTitle.textContent = 'Сайн байна!';
elements.resultTitle.className = 'text-3xl font-bold text-blue-600 mb-2';
animateStars(2);
playSound('applause');
} else {
elements.resultTitle.textContent = 'Дахиж оролдоно уу!';
elements.resultTitle.className = 'text-3xl font-bold text-yellow-600 mb-2';
animateStars(1);
playSound('try-again');
}
}
function animateStars(count = 3) {
elements.star1.classList.remove('text-yellow-300', 'bounce');
elements.star2.classList.remove('text-yellow-300', 'bounce');
elements.star3.classList.remove('text-yellow-300', 'bounce');
setTimeout(() => {
if (count >= 1) {
elements.star1.classList.add('text-yellow-300', 'bounce');
}
if (count >= 2) {
setTimeout(() => {
elements.star2.classList.add('text-yellow-300', 'bounce');
}, 200);
}
if (count >= 3) {
setTimeout(() => {
elements.star3.classList.add('text-yellow-300', 'bounce');
}, 400);
}
}, 100);
}
function triggerConfetti() {
elements.confettiCanvas.classList.remove('hidden');
const confettiSettings = {
target: 'confetti-canvas',
max: 150,
size: 1.5,
animate: true,
props: ['circle', 'square', 'triangle', 'line'],
colors: [[255,0,0],[0,255,0],[0,0,255],[255,255,0],[0,255,255],[255,0,255]],
clock: 25,
rotate: true,
start_from_edge: true,
respawn: true
};
const confetti = new ConfettiGenerator(confettiSettings);
confetti.render();
setTimeout(() => {
confetti.clear();
elements.confettiCanvas.classList.add('hidden');
}, 5000);
}
// Timer Functions
function startTimer() {
state.timer = 30;
updateTimerDisplay();
state.timerInterval = setInterval(() => {
state.timer--;
updateTimerDisplay();
if (state.timer <= 0) {
stopTimer();
showFeedback(false, state.questions[state.currentQuestionIndex].answer);
}
}, 1000);
}
function stopTimer() {
if (state.timerInterval) {
clearInterval(state.timerInterval);
state.timerInterval = null;
}
}
function resetTimer() {
stopTimer();
startTimer();
}
function updateTimerDisplay() {
elements.timer.textContent = state.timer;
// Update timer circle
const percentage = (state.timer / 30) * 100;
const circle = elements.timerCircle;
const radius = circle.r.baseVal.value;
const circumference = 2 * Math.PI * radius;
const offset = circumference - (percentage / 100) * circumference;
circle.style.strokeDashoffset = offset;
circle.style.strokeDasharray = circumference;
// Change color based on time left
if (state.timer <= 10) {
circle.classList.remove('stroke-blue-600');
circle.classList.add('stroke-red-600');
} else {
circle.classList.remove('stroke-red-600');
circle.classList.add('stroke-blue-600');
}
}
// Score Functions
function updateScoreDisplay() {
elements.scoreDisplay.textContent = Math.floor(state.score);
}
// Navigation Functions
function restartQuiz() {
state.score = 0;
updateScoreDisplay();
updateScreen('quiz');
}
function startNewTopic() {
updateScreen('topic');
}
// Sound Functions
function toggleSound() {
state.soundEnabled = !state.soundEnabled;
if (state.soundEnabled) {
elements.soundBtn.innerHTML = '<i class="fas fa-volume-up"></i>';
playSound('toggle');
} else {
elements.soundBtn.innerHTML = '<i class="fas fa-volume-mute"></i>';
}
}
function playSound(type) {
if (!state.soundEnabled) return;
const audio = new Audio();
audio.volume = 0.3;
switch (type) {
case 'correct':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-correct-answer-tone-2870.mp3';
break;
case 'wrong':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-wrong-answer-fail-notification-946.mp3';
break;
case 'success':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-achievement-bell-600.mp3';
break;
case 'applause':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-winning-chimes-2015.mp3';
break;
case 'try-again':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-retro-arcade-lose-2027.mp3';
break;
case 'toggle':
audio.src = 'https://assets.mixkit.co/sfx/preview/mixkit-modern-click-box-check-1120.mp3';
break;
default:
return;
}
audio.play().catch(e => console.log('Audio play failed:', e));
}
// Initialize Confetti Generator class (simplified)
class ConfettiGenerator {
constructor(settings) {
this.settings = settings;
this.canvas = document.getElementById(settings.target);
this.ctx = this.canvas.getContext('2d');
this.particles = [];
this.animationId = null;
this.canvas.width = window.innerWidth;
this.canvas.height = window.innerHeight;
}
render() {
this.createParticles();
this.animate();
}
createParticles() {
for (let i = 0; i < this.settings.max; i++) {
this.particles.push(this.createParticle());
}
}
createParticle() {
const color = this.settings.colors[Math.floor(Math.random() * this.settings.colors.length)];
return {
x: Math.random() * this.canvas.width,
y: this.settings.start_from_edge ? 0 : Math.random() * this.canvas.height,
r: Math.random() * this.settings.size + 1,
d: Math.random() * this.settings.max + 1,
color: `rgb(${color[0]}, ${color[1]}, ${color[2]})`,
shape: this.settings.props[Math.floor(Math.random() * this.settings.props.length)],
tilt: Math.floor(Math.random() * 10) - 10,
tiltAngle: Math.random() * 0.1,
tiltAngleIncrement: Math.random() * 0.07
};
}
animate() {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
for (let i = 0; i < this.particles.length; i++) {
const p = this.particles[i];
this.ctx.beginPath();
this.ctx.fillStyle = p.color;
switch (p.shape) {
case 'circle':
this.ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2, false);
break;
case 'square':
this.ctx.rect(p.x - p.r, p.y - p.r, p.r * 2, p.r * 2);
break;
case 'triangle':
this.ctx.moveTo(p.x, p.y - p.r);
this.ctx.lineTo(p.x + p.r, p.y + p.r);
this.ctx.lineTo(p.x - p.r, p.y + p.r);
break;
case 'line':
this.ctx.moveTo(p.x - p.r, p.y);
this.ctx.lineTo(p.x + p.r, p.y);
this.ctx.lineWidth = 2;
break;
}
this.ctx.fill();
// Update particle position
p.y += Math.cos(p.d) + 1 + p.r / 2;
p.x += Math.sin(0) * 2;
p.tiltAngle += p.tiltAngleIncrement;
p.tilt = Math.sin(p.tiltAngle) * 15;
// Reset particle if it's out of view
if (p.y > this.canvas.height) {
if (this.settings.respawn) {
this.particles[i] = this.createParticle();
} else {
this.particles.splice(i, 1);
i--;
}
}
}
this.animationId = requestAnimationFrame(() => this.animate());
}
clear() {
cancelAnimationFrame(this.animationId);
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.particles = [];
}
}
// Start the app
init();
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Batzuul/math-3-class" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |