All files / components MathModule.js

0% Statements 0/13
0% Branches 0/6
0% Functions 0/8
0% Lines 0/12

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                                                                                                                                                                                                                                                                                                                                                                     
import CountingExercise from './exercises/CountingExercise.js';
import CompareExercise from './exercises/CompareExercise.js';
import AddSubtractExercise from './exercises/AddSubtractExercise.js';
import MultiplyExercise from './exercises/MultiplyExercise.js';
import EquationsExercise from './exercises/EquationsExercise.js';
 
export default {
    name: 'MathModule',
    components: {
        CountingExercise,
        CompareExercise,
        AddSubtractExercise,
        MultiplyExercise,
        EquationsExercise
    },
    data() {
        return {
            currentExercise: null,
            sections: [
                {
                    id: 'basic',
                    title: 'Podstawowe działania',
                    icon: '🔢',
                    subsections: [
                        {
                            id: 'counting',
                            title: 'Liczenie',
                            description: 'Ćwicz liczenie w przód i w tył',
                            icon: '🚂',
                            level: 1,
                            available: true
                        },
                        {
                            id: 'compare',
                            title: 'Porównywanie liczb',
                            description: 'Porównuj liczby używając znaków <, > i =',
                            icon: '⚖️',
                            level: 1,
                            available: true
                        },
                        {
                            id: 'add-subtract',
                            title: 'Dodawanie i odejmowanie',
                            description: 'Ćwicz dodawanie i odejmowanie liczb',
                            icon: '➕',
                            level: 2,
                            available: true
                        },
                        {
                            id: 'multiply',
                            title: 'Mnożenie',
                            description: 'Ucz się tabliczki mnożenia',
                            icon: '✖️',
                            level: 3,
                            available: true
                        },
                        {
                            id: 'equations',
                            title: 'Równania',
                            description: 'Rozwiązuj proste równania',
                            icon: '🎯',
                            level: 4,
                            available: true
                        }
                    ]
                }
            ]
        }
    },
    computed: {
        currentView() {
            console.log('Current exercise:', this.currentExercise); // Debug log
            return this.currentExercise;
        }
    },
    methods: {
        startExercise(subsection) {
            this.currentExercise = subsection.id;
        },
        getIconClass(section) {
            return {
                'text-6xl mb-4': true,
                'transform transition-transform duration-200': true,
                'scale-110': this.hoveredSection === section.id
            }
        },
        getCurrentExerciseTitle() {
            if (!this.currentExercise || !this.selectedSection) return '';
 
            const currentSubsection = this.selectedSection.subsections.find(
                sub => sub.id === this.currentExercise
            );
            return currentSubsection ? currentSubsection.title : '';
        },
        goToHome() {
            this.selectedSection = null;
            this.currentExercise = null;
        },
        goToSection() {
            this.currentExercise = null;
        }
    },
    template: `
        <div class="max-w-4xl mx-auto p-4">
            <div v-if="!currentExercise" class="space-y-8">
                <h2 class="text-2xl font-bold text-gray-800">Wybierz ćwiczenie</h2>
                
                <div v-for="section in sections" :key="section.id" class="space-y-6">
                    <div class="space-y-4">
                        <h3 class="text-xl font-semibold text-gray-700 flex items-center">
                            <span class="mr-2">{{ section.icon }}</span>
                            {{ section.title }}
                        </h3>
                        
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                            <div v-for="subsection in section.subsections" 
                                 :key="subsection.id"
                                 class="bg-white p-6 rounded-lg shadow-sm border border-gray-200 hover:border-indigo-300 transition-colors"
                            >
                                <div class="flex justify-between items-start">
                                    <div class="space-y-2">
                                        <div class="flex items-center">
                                            <span class="text-2xl mr-2">{{ subsection.icon }}</span>
                                            <h4 class="text-lg font-medium text-gray-800">
                                                {{ subsection.title }}
                                            </h4>
                                        </div>
                                        <p class="text-gray-600">{{ subsection.description }}</p>
                                    </div>
                                </div>
                                
                                <div class="mt-4 flex justify-between items-center">
                                    <span class="bg-indigo-100 text-indigo-800 text-sm px-3 py-1 rounded-full">
                                        Poziom {{ subsection.level }}
                                    </span>
                                    <button 
                                        v-if="subsection.available"
                                        @click="startExercise(subsection)"
                                        class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700 transition-colors"
                                    >
                                        Rozpocznij
                                    </button>
                                    <span v-else class="text-yellow-600 text-sm font-medium">
                                        Już wkrótce!
                                    </span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
 
            <counting-exercise 
                v-else-if="currentExercise === 'counting'"
                @back="currentExercise = null"
            ></counting-exercise>
            
            <compare-exercise
                v-else-if="currentExercise === 'compare'"
                @back="currentExercise = null"
            ></compare-exercise>
            
            <add-subtract-exercise
                v-else-if="currentExercise === 'add-subtract'"
                @back="currentExercise = null"
            ></add-subtract-exercise>
            
            <multiply-exercise
                v-else-if="currentExercise === 'multiply'"
                @back="currentExercise = null"
            ></multiply-exercise>
            
            <equations-exercise
                v-else-if="currentExercise === 'equations'"
                @back="currentExercise = null"
            ></equations-exercise>
        </div>
    `
};