All files / components/exercises GeometryExercise.js

0% Statements 0/184
0% Branches 0/55
0% Functions 0/29
0% Lines 0/183

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
export default {
    name: 'GeometryExercise',
    emits: ['back', 'points-updated'],
    data() {
        return {
            isSetupMode: true,
            settings: {
                mode: null,      // 'learn' lub 'practice' 
                figure: null,    // 'all', 'triangle', 'square', 'rectangle'
                figureDescriptions: {
                    all: 'Wszystkie figury',
                    triangle: 'Tylko trójkąty',
                    square: 'Tylko kwadraty',
                    rectangle: 'Tylko prostokąty'
                }
            },
            exercise: {
                currentFigure: null,
                figureParams: {},
                correctAnswer: null,
                currentIndex: 0,
                totalQuestions: 10,
                isComplete: false
            },
            userAnswer: '',
            stats: {
                points: 0,
                correctAnswers: 0,
                mistakes: 0,
                currentStreak: 0,
                level: 1,
                maxLevel: 3
            },
            feedback: {
                message: '',
                type: ''
            },
            timer: {
                time: 0,
                isRunning: false,
                interval: null
            },
            hints: {
                show: false,
                triangle: 'Obwód trójkąta to suma długości wszystkich boków: a + b + c',
                square: 'Obwód kwadratu to 4 × długość boku (a)',
                rectangle: 'Obwód prostokąta to 2 × (długość + szerokość) = 2 × (a + b)'
            },
            showSummary: false,
            setupValidation: {
                mode: { required: true, selected: false },
                figure: { required: true, selected: false }
            },
            setupFeedback: {
                show: true,
                message: 'Wybierz opcje aby rozpocząć ćwiczenie! 😊',
                type: 'info'
            },
            animations: {
                correct: false,
                wrong: false
            },
            showSolution: false
        };
    },
    methods: {
        updateSetupValidation(field, value) {
            this.settings[field] = value;
            this.setupValidation[field].selected = !!value;
            this.checkSetupCompleteness();
        },
 
        checkSetupCompleteness() {
            let isComplete = true;
            let missingFields = [];
 
            Object.keys(this.setupValidation).forEach(field => {
                if (this.setupValidation[field].required && !this.setupValidation[field].selected) {
                    isComplete = false;
                    missingFields.push(field);
                }
            });
 
            if (isComplete) {
                this.setupFeedback.message = 'Wszystko gotowe! Możesz rozpocząć ćwiczenie.';
                this.setupFeedback.type = 'success';
            } else {
                const missingFieldsText = missingFields.map(f => f === 'mode' ? 'tryb' : 'figurę').join(' i ');
                this.setupFeedback.message = `Wybierz ${missingFieldsText} aby kontynuować.`;
                this.setupFeedback.type = 'warning';
            }
 
            return isComplete;
        },
 
        startExercise() {
            if (!this.checkSetupCompleteness()) {
                return;
            }
 
            this.isSetupMode = false;
            this.exercise.currentIndex = 0;
            this.exercise.isComplete = false;
            this.stats.points = 0;
            this.stats.correctAnswers = 0;
            this.stats.mistakes = 0;
            this.stats.currentStreak = 0;
            this.showSummary = false;
 
            this.generateQuestion();
            this.startTimer();
        },
 
        generateQuestion() {
            this.userAnswer = '';
            this.feedback.message = '';
            this.feedback.type = '';
            this.hints.show = false;
            this.animations.correct = false;
            this.animations.wrong = false;
            this.showSolution = false;
 
            // Wybierz figurę
            if (this.settings.figure === 'all') {
                const figures = ['triangle', 'square', 'rectangle'];
                this.exercise.currentFigure = figures[Math.floor(Math.random() * figures.length)];
            } else {
                this.exercise.currentFigure = this.settings.figure;
            }
 
            // Generuj parametry figury
            switch (this.exercise.currentFigure) {
                case 'triangle':
                    this.exercise.figureParams = this.generateTriangleParams();
                    this.exercise.correctAnswer = this.exercise.figureParams.a + this.exercise.figureParams.b + this.exercise.figureParams.c;
                    break;
                case 'square':
                    this.exercise.figureParams = this.generateSquareParams();
                    this.exercise.correctAnswer = 4 * this.exercise.figureParams.a;
                    break;
                case 'rectangle':
                    this.exercise.figureParams = this.generateRectangleParams();
                    this.exercise.correctAnswer = 2 * (this.exercise.figureParams.a + this.exercise.figureParams.b);
                    break;
            }
 
            this.exercise.currentIndex++;
        },
 
        generateTriangleParams() {
            let a, b, c;
 
            if (this.stats.level === 1) {
                // Proste wartości na poziomie 1
                a = Math.floor(Math.random() * 5) + 1;
                b = Math.floor(Math.random() * 5) + 1;
                c = Math.floor(Math.random() * 5) + 1;
            } else if (this.stats.level === 2) {
                // Średni poziom trudności
                a = Math.floor(Math.random() * 8) + 3;
                b = Math.floor(Math.random() * 8) + 3;
                c = Math.floor(Math.random() * 8) + 3;
            } else {
                // Trudny poziom
                a = Math.floor(Math.random() * 12) + 5;
                b = Math.floor(Math.random() * 12) + 5;
                c = Math.floor(Math.random() * 12) + 5;
            }
 
            // Upewniamy się, że boki spełniają nierówność trójkąta
            while (a + b <= c || a + c <= b || b + c <= a) {
                if (this.stats.level === 1) {
                    a = Math.floor(Math.random() * 5) + 1;
                    b = Math.floor(Math.random() * 5) + 1;
                    c = Math.floor(Math.random() * 5) + 1;
                } else if (this.stats.level === 2) {
                    a = Math.floor(Math.random() * 8) + 3;
                    b = Math.floor(Math.random() * 8) + 3;
                    c = Math.floor(Math.random() * 8) + 3;
                } else {
                    a = Math.floor(Math.random() * 12) + 5;
                    b = Math.floor(Math.random() * 12) + 5;
                    c = Math.floor(Math.random() * 12) + 5;
                }
            }
 
            return { a, b, c };
        },
 
        generateSquareParams() {
            let a;
 
            if (this.stats.level === 1) {
                a = Math.floor(Math.random() * 5) + 1;
            } else if (this.stats.level === 2) {
                a = Math.floor(Math.random() * 8) + 3;
            } else {
                a = Math.floor(Math.random() * 12) + 5;
            }
 
            return { a };
        },
 
        generateRectangleParams() {
            let a, b;
 
            if (this.stats.level === 1) {
                a = Math.floor(Math.random() * 5) + 1;
                b = Math.floor(Math.random() * 5) + 1;
            } else if (this.stats.level === 2) {
                a = Math.floor(Math.random() * 8) + 3;
                b = Math.floor(Math.random() * 8) + 3;
            } else {
                a = Math.floor(Math.random() * 12) + 5;
                b = Math.floor(Math.random() * 12) + 5;
            }
 
            // Upewniamy się, że a i b są różne (prostokąt, nie kwadrat)
            while (a === b) {
                if (this.stats.level === 1) {
                    b = Math.floor(Math.random() * 5) + 1;
                } else if (this.stats.level === 2) {
                    b = Math.floor(Math.random() * 8) + 3;
                } else {
                    b = Math.floor(Math.random() * 12) + 5;
                }
            }
 
            return { a, b };
        },
 
        checkAnswer() {
            const userAnswerNum = parseFloat(this.userAnswer);
 
            if (isNaN(userAnswerNum)) {
                this.feedback.message = 'Wprowadź poprawną liczbę';
                this.feedback.type = 'warning';
                return;
            }
 
            if (userAnswerNum === this.exercise.correctAnswer) {
                this.handleCorrectAnswer();
            } else {
                this.handleIncorrectAnswer();
            }
        },
 
        handleCorrectAnswer() {
            this.stats.correctAnswers++;
            this.stats.currentStreak++;
 
            this.feedback.message = 'Poprawna odpowiedź! 👍';
            this.feedback.type = 'success';
            this.animations.correct = true;
 
            // Przyznaj punkty
            let points = 10;
 
            // Bonus za szybkość
            if (this.timer.time < 15) {
                points += 5;
                this.feedback.message += ' +5 za szybkość!';
            }
 
            // Zwiększ poziom trudności co 5 poprawnych odpowiedzi
            if (this.stats.correctAnswers % 5 === 0 && this.stats.level < this.stats.maxLevel) {
                this.stats.level++;
                this.feedback.message += ` Awansowałeś na poziom ${this.stats.level}!`;
            }
 
            this.stats.points += points;
            this.$emit('points-updated', points);
 
            // Przejdź do następnego pytania lub zakończ ćwiczenie
            setTimeout(() => {
                if (this.exercise.currentIndex < this.exercise.totalQuestions) {
                    this.generateQuestion();
                } else {
                    this.completeExercise();
                }
            }, 1500);
        },
 
        handleIncorrectAnswer() {
            this.stats.mistakes++;
            this.stats.currentStreak = 0;
 
            this.feedback.message = `Niestety, poprawna odpowiedź to ${this.exercise.correctAnswer} cm.`;
            this.feedback.type = 'error';
            this.animations.wrong = true;
 
            // Pokaż wskazówkę przy błędnej odpowiedzi
            this.hints.show = true;
        },
 
        startTimer() {
            this.timer.time = 0;
            this.timer.isRunning = true;
 
            this.timer.interval = setInterval(() => {
                this.timer.time++;
            }, 1000);
        },
 
        stopTimer() {
            clearInterval(this.timer.interval);
            this.timer.isRunning = false;
        },
 
        completeExercise() {
            this.exercise.isComplete = true;
            this.showSummary = true;
            this.stopTimer();
        },
 
        restartExercise() {
            this.startExercise();
        },
 
        goBack() {
            this.stopTimer();
            this.$emit('back');
        },
 
        showHint() {
            this.hints.show = true;
        },
 
        showFullSolution() {
            this.showSolution = true;
            this.hints.show = true;
        },
 
        calculateTrianglePoints() {
            const { a, b, c } = this.exercise.figureParams;
 
            // Sprawdzamy czy da się zbudować trójkąt z tych boków
            if (a + b <= c || a + c <= b || b + c <= a) {
                console.error("Nie można stworzyć trójkąta z tych boków!");
                return "100,50 50,150 150,150"; // domyślny trójkąt
            }
 
            // Skalowanie, aby trójkąt zmieścił się w obszarze SVG
            const maxDimension = Math.max(a, b, c);
            const scale = 120 / maxDimension;
 
            // Centrujemy bazę trójkąta (bok a) na dole
            const baseWidth = a * scale;
            const baseLeftX = (200 - baseWidth) / 2;
            const baseY = 150;
 
            // Obliczamy położenie trzeciego wierzchołka (góra trójkąta)
            // Używamy wzoru Herona do obliczenia wysokości
            const s = (a + b + c) / 2; // półobwód
            const area = Math.sqrt(s * (s - a) * (s - b) * (s - c)); // pole trójkąta
            const height = 2 * area / a; // wysokość opuszczona na bok a
 
            // Obliczamy położenie na osi X wierzchołka góry trójkąta
            // Używamy twierdzenia Pitagorasa
            const p = (a * a + b * b - c * c) / (2 * a); // odległość od lewego końca podstawy
 
            // Wierzchołki trójkąta
            const Ax = baseLeftX; // lewy dolny róg
            const Ay = baseY;
 
            const Bx = baseLeftX + baseWidth; // prawy dolny róg
            const By = baseY;
 
            const Cx = baseLeftX + p * scale; // górny wierzchołek
            const Cy = baseY - height * scale;
 
            return `${Ax},${Ay} ${Bx},${By} ${Cx},${Cy}`;
        },
 
        calculateTriangleMidpoints() {
            // Obliczamy punkty środkowe boków na podstawie wierzchołków
            const points = this.calculateTrianglePoints().split(' ').map(point => {
                const [x, y] = point.split(',');
                return { x: parseFloat(x), y: parseFloat(y) };
            });
 
            return [
                { // Środek dolnego boku (a)
                    x: (points[0].x + points[1].x) / 2,
                    y: (points[0].y + points[1].y) / 2,
                    side: 'a'
                },
                { // Środek lewego boku (b)
                    x: (points[0].x + points[2].x) / 2,
                    y: (points[0].y + points[2].y) / 2,
                    side: 'b'
                },
                { // Środek prawego boku (c)
                    x: (points[1].x + points[2].x) / 2,
                    y: (points[1].y + points[2].y) / 2,
                    side: 'c'
                }
            ];
        },
 
        calculateTriangleLabels() {
            const midpoints = this.calculateTriangleMidpoints();
            const { a, b, c } = this.exercise.figureParams;
 
            // Dodajemy etykiety z lekkim przesunięciem dla czytelności
            return [
                {
                    x: midpoints[0].x,
                    y: midpoints[0].y + 15, // Etykieta dla boku a (dolny)
                    text: `${a} cm`
                },
                {
                    x: midpoints[1].x - 15,
                    y: midpoints[1].y, // Etykieta dla boku b (lewy)
                    text: `${b} cm`
                },
                {
                    x: midpoints[2].x + 15,
                    y: midpoints[2].y, // Etykieta dla boku c (prawy)
                    text: `${c} cm`
                }
            ];
        },
 
        calculateSquareParams() {
            const { a } = this.exercise.figureParams;
 
            // Skalowanie, aby kwadrat mieścił się w obszarze SVG
            const scale = 140 / a;
            const size = a * scale;
 
            // Centrujemy kwadrat
            const x = (200 - size) / 2;
            const y = (200 - size) / 2;
 
            return {
                x: x,
                y: y,
                size: size
            };
        },
 
        calculateRectangleParams() {
            const { a, b } = this.exercise.figureParams;
 
            // Skalowanie, aby prostokąt mieścił się w obszarze SVG
            const scale = 140 / Math.max(a, b);
            const width = a * scale;
            const height = b * scale;
 
            // Centrujemy prostokąt
            const x = (200 - width) / 2;
            const y = (200 - height) / 2;
 
            return {
                x: x,
                y: y,
                width: width,
                height: height
            };
        }
    },
    mounted() {
        // Inicjalizacja komponentu
    },
    template: `
        <div class="max-w-4xl mx-auto p-4">
            <!-- Ekran konfiguracji -->
            <div v-if="isSetupMode" class="bg-white p-6 rounded-lg shadow-lg">
                <h2 class="text-2xl font-bold mb-6 text-center text-blue-600">Obliczanie obwodów figur geometrycznych</h2>
                
                <div class="space-y-6">
                    <!-- Wybór trybu -->
                    <div>
                        <h3 class="text-lg font-semibold mb-3 text-gray-700">Wybierz tryb:</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-3">
                            <button 
                                @click="updateSetupValidation('mode', 'learn')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.mode === 'learn' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">📚</span>
                                    <div>
                                        <h4 class="font-medium">Nauka</h4>
                                        <p class="text-sm text-gray-600">Poznaj wzory na obliczanie obwodów figur</p>
                                    </div>
                                </div>
                            </button>
                            
                            <button 
                                @click="updateSetupValidation('mode', 'practice')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.mode === 'practice' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">🏆</span>
                                    <div>
                                        <h4 class="font-medium">Ćwiczenia</h4>
                                        <p class="text-sm text-gray-600">Rozwiązuj zadania i zdobywaj punkty</p>
                                    </div>
                                </div>
                            </button>
                        </div>
                    </div>
                    
                    <!-- Wybór figury -->
                    <div>
                        <h3 class="text-lg font-semibold mb-3 text-gray-700">Wybierz figury:</h3>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-3">
                            <button 
                                @click="updateSetupValidation('figure', 'all')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.figure === 'all' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">🔄</span>
                                    <div>
                                        <h4 class="font-medium">Wszystkie figury</h4>
                                        <p class="text-sm text-gray-600">Trójkąty, kwadraty i prostokąty</p>
                                    </div>
                                </div>
                            </button>
                            
                            <button 
                                @click="updateSetupValidation('figure', 'triangle')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.figure === 'triangle' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">📐</span>
                                    <div>
                                        <h4 class="font-medium">Trójkąty</h4>
                                        <p class="text-sm text-gray-600">Tylko zadania z trójkątami</p>
                                    </div>
                                </div>
                            </button>
                            
                            <button 
                                @click="updateSetupValidation('figure', 'square')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.figure === 'square' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">⬛</span>
                                    <div>
                                        <h4 class="font-medium">Kwadraty</h4>
                                        <p class="text-sm text-gray-600">Tylko zadania z kwadratami</p>
                                    </div>
                                </div>
                            </button>
                            
                            <button 
                                @click="updateSetupValidation('figure', 'rectangle')" 
                                class="p-4 border rounded-lg text-left" 
                                :class="[settings.figure === 'rectangle' ? 'border-blue-500 bg-blue-50' : 'border-gray-300']"
                            >
                                <div class="flex items-center">
                                    <span class="text-2xl mr-3">🔳</span>
                                    <div>
                                        <h4 class="font-medium">Prostokąty</h4>
                                        <p class="text-sm text-gray-600">Tylko zadania z prostokątami</p>
                                    </div>
                                </div>
                            </button>
                        </div>
                    </div>
                    
                    <!-- Przyciski akcji -->
                    <div class="mt-8 space-y-4">
                        <div v-if="setupFeedback.show" 
                             class="p-3 rounded-md text-center"
                             :class="{
                                'bg-yellow-50 text-yellow-700': setupFeedback.type === 'warning',
                                'bg-green-50 text-green-700': setupFeedback.type === 'success',
                                'bg-blue-50 text-blue-700': setupFeedback.type === 'info'
                             }">
                            {{ setupFeedback.message }}
                        </div>
                        
                        <div class="flex justify-between">
                            <button 
                                @click="goBack" 
                                class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700"
                            >
                                Wróć
                            </button>
                            
                            <button 
                                @click="startExercise" 
                                class="px-6 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white font-medium"
                                :disabled="!checkSetupCompleteness()"
                                :class="{'opacity-50 cursor-not-allowed': !checkSetupCompleteness()}"
                            >
                                Rozpocznij
                            </button>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- Ekran ćwiczeń -->
            <div v-else-if="!showSummary" class="bg-white p-6 rounded-lg shadow-lg">
                <div class="flex justify-between items-center mb-6">
                    <div class="flex space-x-4">
                        <div class="text-sm text-gray-600">Poziom: {{ stats.level }}/{{ stats.maxLevel }}</div>
                        <div class="text-sm text-gray-600">Punkty: {{ stats.points }}</div>
                        <div class="text-sm text-gray-600">Pytanie: {{ exercise.currentIndex }}/{{ exercise.totalQuestions }}</div>
                    </div>
                </div>
                
                <div class="mb-6 p-4 bg-blue-50 rounded-lg">
                    <h3 class="text-lg font-semibold mb-3 text-gray-800">
                        <template v-if="exercise.currentFigure === 'triangle'">
                            Oblicz obwód trójkąta według wzoru: <span class="text-blue-700">Ob = a + b + c</span>
                        </template>
                        <template v-if="exercise.currentFigure === 'square'">
                            Oblicz obwód kwadratu według wzoru: <span class="text-blue-700">Ob = 4 × a</span>
                        </template>
                        <template v-if="exercise.currentFigure === 'rectangle'">
                            Oblicz obwód prostokąta według wzoru: <span class="text-blue-700">Ob = 2 × (a + b)</span>
                        </template>
                    </h3>
                    
                    <!-- Wizualizacja figury -->
                    <div class="flex justify-center my-6">
                        <!-- Trójkąt -->
                        <svg v-if="exercise.currentFigure === 'triangle'" class="w-64 h-64" viewBox="0 0 200 200">
                            <polygon :points="calculateTrianglePoints()" fill="none" stroke="#3B82F6" stroke-width="2" />
                            <text v-for="(label, index) in calculateTriangleLabels()" :key="'label-'+index" 
                                :x="label.x" :y="label.y" text-anchor="middle" class="font-medium">
                                {{ label.text }}
                            </text>
                        </svg>
                        
                        <!-- Kwadrat -->
                        <svg v-if="exercise.currentFigure === 'square'" class="w-64 h-64" viewBox="0 0 200 200">
                            <rect 
                                :x="calculateSquareParams().x" 
                                :y="calculateSquareParams().y" 
                                :width="calculateSquareParams().size" 
                                :height="calculateSquareParams().size" 
                                fill="none" 
                                stroke="#3B82F6" 
                                stroke-width="2" 
                            />
                            <text 
                                :x="calculateSquareParams().x + calculateSquareParams().size/2" 
                                :y="calculateSquareParams().y - 10" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                            <text 
                                :x="calculateSquareParams().x + calculateSquareParams().size/2" 
                                :y="calculateSquareParams().y + calculateSquareParams().size + 20" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                            <text 
                                :x="calculateSquareParams().x - 10" 
                                :y="calculateSquareParams().y + calculateSquareParams().size/2" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                            <text 
                                :x="calculateSquareParams().x + calculateSquareParams().size + 10" 
                                :y="calculateSquareParams().y + calculateSquareParams().size/2" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                        </svg>
                        
                        <!-- Prostokąt -->
                        <svg v-if="exercise.currentFigure === 'rectangle'" class="w-64 h-64" viewBox="0 0 200 200">
                            <rect 
                                :x="calculateRectangleParams().x" 
                                :y="calculateRectangleParams().y" 
                                :width="calculateRectangleParams().width" 
                                :height="calculateRectangleParams().height" 
                                fill="none" 
                                stroke="#3B82F6" 
                                stroke-width="2" 
                            />
                            <text 
                                :x="calculateRectangleParams().x + calculateRectangleParams().width/2" 
                                :y="calculateRectangleParams().y - 10" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                            <text 
                                :x="calculateRectangleParams().x + calculateRectangleParams().width/2" 
                                :y="calculateRectangleParams().y + calculateRectangleParams().height + 20" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.a }} cm
                            </text>
                            <text 
                                :x="calculateRectangleParams().x - 10" 
                                :y="calculateRectangleParams().y + calculateRectangleParams().height/2" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.b }} cm
                            </text>
                            <text 
                                :x="calculateRectangleParams().x + calculateRectangleParams().width + 10" 
                                :y="calculateRectangleParams().y + calculateRectangleParams().height/2" 
                                text-anchor="middle" 
                                class="font-medium"
                            >
                                {{ exercise.figureParams.b }} cm
                            </text>
                        </svg>
                    </div>
                    
                    <!-- Wzór z konkretnymi wartościami -->
                    <div v-if="settings.mode === 'learn' || hints.show || feedback.type === 'error'" class="text-center my-4 p-3 bg-white rounded-lg shadow-sm">
                        <p class="font-medium text-gray-700">Podstaw wartości do wzoru:</p>
                        <p class="text-xl font-bold text-blue-600 mt-2">
                            <template v-if="exercise.currentFigure === 'triangle'">
                                Ob = {{ exercise.figureParams.a }} + {{ exercise.figureParams.b }} + {{ exercise.figureParams.c }}
                            </template>
                            <template v-if="exercise.currentFigure === 'square'">
                                Ob = 4 × {{ exercise.figureParams.a }}
                            </template>
                            <template v-if="exercise.currentFigure === 'rectangle'">
                                Ob = 2 × ({{ exercise.figureParams.a }} + {{ exercise.figureParams.b }})
                            </template>
                        </p>
                        
                        <!-- Krok po kroku obliczenia dla trybu nauki -->
                        <div v-if="settings.mode === 'learn' && (feedback.type === 'success' || feedback.type === 'error')" class="mt-4 pt-4 border-t border-gray-200">
                            <p class="font-medium text-gray-700 mb-2">Obliczenie krok po kroku:</p>
                            
                            <div v-if="exercise.currentFigure === 'triangle'" class="flex flex-col items-center space-y-1">
                                <p class="text-gray-600">Ob = {{ exercise.figureParams.a }} + {{ exercise.figureParams.b }} + {{ exercise.figureParams.c }}</p>
                                <span class="text-gray-400">↓</span>
                                <p class="text-green-600 font-bold">Ob = {{ exercise.correctAnswer }} cm</p>
                            </div>
                            
                            <div v-if="exercise.currentFigure === 'square'" class="flex flex-col items-center space-y-1">
                                <p class="text-gray-600">Ob = 4 × {{ exercise.figureParams.a }}</p>
                                <span class="text-gray-400">↓</span>
                                <p class="text-green-600 font-bold">Ob = {{ exercise.correctAnswer }} cm</p>
                            </div>
                            
                            <div v-if="exercise.currentFigure === 'rectangle'" class="flex flex-col items-center space-y-1">
                                <p class="text-gray-600">Ob = 2 × ({{ exercise.figureParams.a }} + {{ exercise.figureParams.b }})</p>
                                <span class="text-gray-400">↓</span>
                                <p class="text-gray-600">Ob = 2 × {{ exercise.figureParams.a + exercise.figureParams.b }}</p>
                                <span class="text-gray-400">↓</span>
                                <p class="text-green-600 font-bold">Ob = {{ exercise.correctAnswer }} cm</p>
                            </div>
                        </div>
                    </div>
                    
                    <!-- Pole do wprowadzenia odpowiedzi -->
                    <div class="max-w-md mx-auto">
                        <label class="block text-sm font-medium text-gray-700 mb-1">Obwód figury wynosi:</label>
                        <div class="flex items-center">
                            <input 
                                type="number" 
                                v-model="userAnswer" 
                                class="block w-full border border-gray-300 rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
                                placeholder="Wpisz obwód..." 
                                @keyup.enter="checkAnswer"
                            />
                            <span class="ml-2 text-gray-700">cm</span>
                        </div>
                        
                        <div class="flex justify-between mt-4">
                            <div class="flex space-x-2">
                                <button 
                                    @click="showHint" 
                                    class="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded-md text-gray-700 text-sm"
                                >
                                    Pokaż wskazówkę
                                </button>
                                
                                <button 
                                    v-if="settings.mode === 'learn'"
                                    @click="showFullSolution" 
                                    class="px-4 py-2 bg-indigo-100 hover:bg-indigo-200 rounded-md text-indigo-700 text-sm"
                                >
                                    Pokaż rozwiązanie
                                </button>
                            </div>
                            
                            <button 
                                @click="checkAnswer" 
                                class="px-6 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white font-medium"
                            >
                                Sprawdź
                            </button>
                        </div>
                    </div>
                    
                    <!-- Rozwiązanie (widoczne tylko w trybie nauki po kliknięciu "Pokaż rozwiązanie") -->
                    <div v-if="settings.mode === 'learn' && showSolution" class="mt-4 p-4 bg-indigo-50 rounded-md">
                        <p class="font-medium text-indigo-800 mb-2">Rozwiązanie:</p>
                        
                        <div v-if="exercise.currentFigure === 'triangle'" class="space-y-2">
                            <p>Aby obliczyć obwód trójkąta, należy dodać długości wszystkich boków:</p>
                            <p class="font-medium">Ob = a + b + c</p>
                            <p>Podstawiając dane:</p>
                            <p>Ob = {{ exercise.figureParams.a }} + {{ exercise.figureParams.b }} + {{ exercise.figureParams.c }} = {{ exercise.correctAnswer }} cm</p>
                        </div>
                        
                        <div v-if="exercise.currentFigure === 'square'" class="space-y-2">
                            <p>Aby obliczyć obwód kwadratu, należy pomnożyć długość boku przez 4:</p>
                            <p class="font-medium">Ob = 4 × a</p>
                            <p>Podstawiając dane:</p>
                            <p>Ob = 4 × {{ exercise.figureParams.a }} = {{ exercise.correctAnswer }} cm</p>
                        </div>
                        
                        <div v-if="exercise.currentFigure === 'rectangle'" class="space-y-2">
                            <p>Aby obliczyć obwód prostokąta, można użyć wzoru 2 × (a + b):</p>
                            <p class="font-medium">Ob = 2 × (a + b)</p>
                            <p>Podstawiając dane:</p>
                            <p>Ob = 2 × ({{ exercise.figureParams.a }} + {{ exercise.figureParams.b }}) = 2 × {{ exercise.figureParams.a + exercise.figureParams.b }} = {{ exercise.correctAnswer }} cm</p>
                        </div>
                        
                        <p class="mt-4 text-sm text-indigo-600">Teraz możesz wpisać odpowiedź i kliknąć "Sprawdź", lub przejść do następnego zadania.</p>
                    </div>
                    
                    <!-- Wskazówka -->
                    <div v-if="hints.show" class="mt-4 p-3 bg-yellow-50 rounded-md text-sm text-gray-700">
                        <p class="font-medium">Podpowiedź:</p>
                        <p v-if="exercise.currentFigure === 'triangle'">{{ hints.triangle }}</p>
                        <p v-if="exercise.currentFigure === 'square'">{{ hints.square }}</p>
                        <p v-if="exercise.currentFigure === 'rectangle'">{{ hints.rectangle }}</p>
                    </div>
                    
                    <!-- Komunikat zwrotny -->
                    <div v-if="feedback.message" class="mt-4 p-3 rounded-md" :class="{
                        'bg-green-50 text-green-700': feedback.type === 'success',
                        'bg-red-50 text-red-700': feedback.type === 'error',
                        'bg-yellow-50 text-yellow-700': feedback.type === 'warning'
                    }">
                        {{ feedback.message }}
                    </div>
                    
                    <!-- Animacje -->
                    <div v-if="animations.correct" class="fixed inset-0 flex items-center justify-center pointer-events-none">
                        <div class="text-6xl animate-bounce">🎉</div>
                    </div>
                    <div v-if="animations.wrong" class="fixed inset-0 flex items-center justify-center pointer-events-none">
                        <div class="text-6xl animate-pulse">❌</div>
                    </div>
                </div>
            </div>
            
            <!-- Ekran podsumowania -->
            <div v-else class="bg-white p-6 rounded-lg shadow-lg">
                <h2 class="text-2xl font-bold mb-6 text-center text-blue-600">Ćwiczenie zakończone!</h2>
                
                <div class="bg-blue-50 p-4 rounded-lg mb-6">
                    <div class="grid grid-cols-2 gap-4 mb-4">
                        <div class="bg-white p-3 rounded-md shadow-sm">
                            <p class="text-gray-500 text-sm">Poprawne odpowiedzi</p>
                            <p class="text-2xl font-bold">{{ stats.correctAnswers }}/{{ exercise.totalQuestions }}</p>
                        </div>
                        
                        <div class="bg-white p-3 rounded-md shadow-sm">
                            <p class="text-gray-500 text-sm">Zdobyte punkty</p>
                            <p class="text-2xl font-bold">{{ stats.points }}</p>
                        </div>
                        
                        <div class="bg-white p-3 rounded-md shadow-sm">
                            <p class="text-gray-500 text-sm">Osiągnięty poziom</p>
                            <p class="text-2xl font-bold">{{ stats.level }}/{{ stats.maxLevel }}</p>
                        </div>
                        
                        <div class="bg-white p-3 rounded-md shadow-sm">
                            <p class="text-gray-500 text-sm">Czas</p>
                            <p class="text-2xl font-bold">{{ Math.floor(timer.time / 60) }}:{{ (timer.time % 60).toString().padStart(2, '0') }}</p>
                        </div>
                    </div>
                    
                    <div class="mb-6 p-4 bg-white rounded-md text-center">
                        <p class="font-medium mb-2">Wynik:</p>
                        <p v-if="stats.correctAnswers >= exercise.totalQuestions * 0.8" class="text-green-600 font-bold text-lg">
                            Świetnie! Doskonale rozumiesz obliczanie obwodów figur! 🌟
                        </p>
                        <p v-else-if="stats.correctAnswers >= exercise.totalQuestions * 0.6" class="text-blue-600 font-bold text-lg">
                            Dobrze! Rozumiesz podstawy, ale przyda się jeszcze trochę praktyki. 👍
                        </p>
                        <p v-else class="text-yellow-600 font-bold text-lg">
                            Warto jeszcze poćwiczyć obliczanie obwodów figur. 💪
                        </p>
                    </div>
                </div>
                
                <div class="flex justify-between">
                    <button 
                        @click="goBack" 
                        class="px-4 py-2 bg-gray-200 hover:bg-gray-300 rounded-md text-gray-700"
                    >
                        Wróć do menu
                    </button>
                    
                    <button 
                        @click="restartExercise" 
                        class="px-6 py-2 bg-blue-600 hover:bg-blue-700 rounded-md text-white font-medium"
                    >
                        Spróbuj ponownie
                    </button>
                </div>
            </div>
        </div>
    `
};