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 | export default { name: 'EquationsExercise', emits: ['back'], data() { return { isSetupMode: true, settings: { mode: null, // 'learn' lub 'challenge' type: null, // 'addition', 'subtraction', 'mixed' range: null // 'small' (do 20), 'medium' (do 50), 'large' (do 100) }, unknownSymbol: '🎯', // Tarcza jako symbol niewiadomej exercise: { equation: { leftSide: '', // np. "□ + 5" rightSide: '', // np. "12" missingNumber: null, operation: '', secondNumber: '', missingPosition: null }, currentIndex: 0, totalQuestions: 10, isComplete: false }, userAnswer: '', stats: { points: 0, correctAnswers: 0, mistakes: 0, currentStreak: 0, additionCorrect: 0, // Nowe statystyki dla dodawania subtractionCorrect: 0, // Nowe statystyki dla odejmowania lastOperation: null // Śledzenie ostatniej operacji }, feedback: { message: '', type: '' }, hints: { isVisible: false, visualElements: [], currentStep: 0, maxSteps: 3 } } }, methods: { generateEquation() { const maxNumber = this.settings.range === 'small' ? 20 : this.settings.range === 'medium' ? 50 : 100; let operations = []; if (this.settings.type === 'mixed') { // Zapewniamy równomierny rozkład operacji if (this.stats.lastOperation === '+') { operations = ['-']; // Wymuszamy odejmowanie po dodawaniu } else if (this.stats.lastOperation === '-') { operations = ['+']; // Wymuszamy dodawanie po odejmowaniu } else { operations = ['+', '-']; // Losowy wybór dla pierwszego równania } } else { operations = [this.settings.type === 'addition' ? '+' : '-']; } const operation = operations[Math.floor(Math.random() * operations.length)]; this.stats.lastOperation = operation; let num1, num2, result; if (operation === '+') { result = Math.floor(Math.random() * (maxNumber - 5)) + 5; num2 = Math.floor(Math.random() * (result - 1)) + 1; num1 = result - num2; } else { num1 = Math.floor(Math.random() * (maxNumber - 5)) + 5; num2 = Math.floor(Math.random() * (num1 - 1)) + 1; result = num1 - num2; } const missingPosition = Math.floor(Math.random() * 2); this.exercise.equation = { leftSide: missingPosition === 0 ? this.unknownSymbol : num1.toString(), operation: operation, secondNumber: missingPosition === 1 ? this.unknownSymbol : num2.toString(), rightSide: result.toString(), missingNumber: missingPosition === 0 ? num1 : num2, missingPosition: missingPosition }; }, checkAnswer() { if (!this.userAnswer) return; const isCorrect = parseInt(this.userAnswer) === this.exercise.equation.missingNumber; if (isCorrect) { this.handleCorrectAnswer(); } else { this.handleIncorrectAnswer(); } }, handleCorrectAnswer() { this.stats.correctAnswers++; this.stats.currentStreak++; // Aktualizacja statystyk dla konkretnego typu działania if (this.exercise.equation.operation === '+') { this.stats.additionCorrect++; } else { this.stats.subtractionCorrect++; } this.addPoints(); this.feedback = { message: 'Świetnie! Trafiłeś w dziesiątkę! 🎯✨', type: 'success' }; setTimeout(() => { this.moveToNext(); }, 1000); }, handleIncorrectAnswer() { this.stats.mistakes++; this.stats.currentStreak = 0; let hintMessage = ''; if (this.settings.mode === 'learn') { const operation = this.exercise.equation.operation; const rightSide = this.exercise.equation.rightSide; if (this.exercise.equation.missingPosition === 0) { hintMessage = `Jaka liczba ${operation} ${this.exercise.equation.secondNumber} daje ${rightSide}?`; } else { hintMessage = `${this.exercise.equation.leftSide} ${operation} jaka liczba daje ${rightSide}?`; } } this.feedback = { message: this.settings.mode === 'learn' ? `Spróbuj jeszcze raz! Trafisz w tarczę 🎯, gdy ${hintMessage.toLowerCase()}` : 'Nieprawidłowa odpowiedź! Spróbuj jeszcze raz!', type: 'error' }; }, moveToNext() { this.exercise.currentIndex++; if (this.exercise.currentIndex >= this.exercise.totalQuestions) { this.completeExercise(); return; } this.generateEquation(); this.userAnswer = ''; this.feedback.message = ''; this.hints.isVisible = false; this.hints.currentStep = 0; this.hints.visualElements = []; }, startExercise() { if (!this.settings.mode || !this.settings.type || !this.settings.range) { return; } this.isSetupMode = false; this.exercise.currentIndex = 0; this.exercise.isComplete = false; this.hints.isVisible = false; this.hints.currentStep = 0; this.hints.visualElements = []; this.generateEquation(); }, addPoints() { let points = 10; if (this.settings.mode === 'challenge') points *= 1.5; if (this.stats.currentStreak > 2) points *= 1.2; if (this.settings.range === 'medium') points *= 1.2; if (this.settings.range === 'large') points *= 1.5; this.stats.points += Math.round(points); }, completeExercise() { this.exercise.isComplete = true; const accuracy = ((this.exercise.totalQuestions - this.stats.mistakes) / this.exercise.totalQuestions) * 100; let summaryMessage = `Gratulacje! Ukończyłeś ćwiczenie!\n`; if (this.settings.type === 'mixed') { summaryMessage += `\nDodawanie: ${this.stats.additionCorrect} poprawnych\n`; summaryMessage += `Odejmowanie: ${this.stats.subtractionCorrect} poprawnych\n`; } summaryMessage += `\nZdobyte punkty: ${this.stats.points}\n`; summaryMessage += `Dokładność: ${Math.round(accuracy)}%`; this.feedback = { message: summaryMessage, type: 'success' }; }, showHint() { if (!this.settings.mode === 'learn') return; this.hints.isVisible = true; this.generateHintSteps(); }, generateHintSteps() { const operation = this.exercise.equation.operation; const rightSide = parseInt(this.exercise.equation.rightSide); const leftNum = parseInt(this.exercise.equation.leftSide); const secondNum = parseInt(this.exercise.equation.secondNumber); // Resetujemy kroki podpowiedzi this.hints.currentStep = 0; this.hints.visualElements = []; // Przygotowanie podpowiedzi w zależności od pozycji niewiadomej switch (this.exercise.equation.missingPosition) { case 0: // Pierwsza liczba jest niewiadomą if (operation === '+') { this.hints.visualElements = [ { type: 'explanation', description: `Aby znaleźć nieznaną liczbę, możemy odjąć ${secondNum} od ${rightSide}:` }, { type: 'operation', description: `${rightSide} - ${secondNum} = 🎯` }, { type: 'explanation', description: `Sprawdzenie: 🎯 + ${secondNum} = ${rightSide}` } ]; } else { this.hints.visualElements = [ { type: 'explanation', description: `Aby znaleźć nieznaną liczbę, możemy dodać ${secondNum} do ${rightSide}:` }, { type: 'operation', description: `${rightSide} + ${secondNum} = 🎯` }, { type: 'explanation', description: `Sprawdzenie: 🎯 - ${secondNum} = ${rightSide}` } ]; } break; case 1: // Druga liczba jest niewiadomą if (operation === '+') { this.hints.visualElements = [ { type: 'explanation', description: `Aby znaleźć nieznaną liczbę, możemy odjąć ${leftNum} od ${rightSide}:` }, { type: 'operation', description: `${rightSide} - ${leftNum} = 🎯` }, { type: 'explanation', description: `Sprawdzenie: ${leftNum} + 🎯 = ${rightSide}` } ]; } else { this.hints.visualElements = [ { type: 'explanation', description: `Aby znaleźć nieznaną liczbę, odejmujemy ${rightSide} od ${leftNum}:` }, { type: 'operation', description: `${leftNum} - ${rightSide} = 🎯` }, { type: 'explanation', description: `Sprawdzenie: ${leftNum} - 🎯 = ${rightSide}` } ]; } break; } }, nextHintStep() { if (this.hints.currentStep < this.hints.maxSteps - 1) { this.hints.currentStep++; } }, previousHintStep() { if (this.hints.currentStep > 0) { this.hints.currentStep--; } } }, template: ` <div class="max-w-4xl mx-auto p-4"> <!-- Tryb konfiguracji --> <div v-if="isSetupMode" class="space-y-8"> <div class="flex items-center mb-4"> <button @click="$emit('back')" class="text-indigo-600 hover:text-indigo-800">← Powrót</button> </div> <!-- Wybór trybu --> <div> <h3 class="text-lg font-medium mb-4">Wybierz tryb:</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div @click="settings.mode = 'learn'" :class="['p-6 rounded-lg cursor-pointer border-2 text-center', settings.mode === 'learn' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-3xl mb-2">📚</div> <h4 class="font-medium">Tryb nauki</h4> <p class="text-sm text-gray-600">Ucz się w swoim tempie</p> </div> <div @click="settings.mode = 'challenge'" :class="['p-6 rounded-lg cursor-pointer border-2 text-center', settings.mode === 'challenge' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-3xl mb-2">⭐</div> <h4 class="font-medium">Tryb wyzwań</h4> <p class="text-sm text-gray-600">Sprawdź swoje umiejętności</p> </div> </div> </div> <!-- Wybór typu równań --> <div> <h3 class="text-lg font-medium mb-4">Wybierz rodzaj działań:</h3> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> <div @click="settings.type = 'addition'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.type === 'addition' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">➕</div> <h4 class="font-medium">Dodawanie</h4> <p class="text-sm text-gray-600">np. □ + 5 = 12</p> </div> <div @click="settings.type = 'subtraction'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.type === 'subtraction' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">➖</div> <h4 class="font-medium">Odejmowanie</h4> <p class="text-sm text-gray-600">np. 15 - □ = 8</p> </div> <div @click="settings.type = 'mixed'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.type === 'mixed' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">🔄</div> <h4 class="font-medium">Mieszane</h4> <p class="text-sm text-gray-600">Dodawanie i odejmowanie</p> </div> </div> </div> <!-- Wybór zakresu --> <div> <h3 class="text-lg font-medium mb-4">Wybierz zakres liczb:</h3> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> <div @click="settings.range = 'small'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.range === 'small' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">🚂</div> <h4 class="font-medium">Mała podróż</h4> <p class="text-sm text-gray-600">Liczby do 20</p> </div> <div @click="settings.range = 'medium'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.range === 'medium' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">🚗</div> <h4 class="font-medium">Średnia podróż</h4> <p class="text-sm text-gray-600">Liczby do 50</p> </div> <div @click="settings.range = 'large'" :class="['p-4 rounded-lg cursor-pointer border-2 text-center', settings.range === 'large' ? 'border-indigo-600 bg-indigo-50' : 'border-gray-200']" > <div class="text-2xl mb-2">✈️</div> <h4 class="font-medium">Długa podróż</h4> <p class="text-sm text-gray-600">Liczby do 100</p> </div> </div> </div> <button @click="startExercise" :disabled="!settings.mode || !settings.type || !settings.range" :class="['w-full py-3 rounded-lg transition-colors', (!settings.mode || !settings.type || !settings.range) ? 'bg-gray-300 cursor-not-allowed' : 'bg-indigo-600 text-white hover:bg-indigo-700']" > Rozpocznij ćwiczenie </button> </div> <!-- Tryb ćwiczenia --> <div v-else class="space-y-6"> <div class="flex justify-between items-center"> <button @click="isSetupMode = true" class="text-indigo-600 hover:text-indigo-800">← Wróć do ustawień</button> <div class="space-x-4"> <span class="bg-blue-100 text-blue-800 px-3 py-1 rounded-full">Punkty: {{ stats.points }}</span> <span class="bg-green-100 text-green-800 px-3 py-1 rounded-full">Seria: {{ stats.currentStreak }}</span> </div> </div> <!-- Instrukcja przed rozpoczęciem --> <div class="text-center mb-6"> <div class="text-lg text-gray-600 mb-2"> Znajdź liczbę ukrytą pod tarczą 🎯 </div> <div class="text-sm text-gray-500"> Trafisz w cel, gdy odkryjesz brakującą liczbę! </div> </div> <!-- Równanie --> <div class="text-center"> <div class="text-4xl font-bold mb-8"> {{ exercise.equation.leftSide }} {{ exercise.equation.operation }} {{ exercise.equation.secondNumber }} = {{ exercise.equation.rightSide }} </div> <div class="mt-4"> <input v-model="userAnswer" type="number" :placeholder="'Wpisz liczbę ukrytą pod ' + unknownSymbol" class="text-center text-2xl w-64 p-2 border-2 rounded-lg" @keyup.enter="checkAnswer" :disabled="exercise.isComplete" > </div> </div> <!-- Feedback --> <div v-if="feedback.message" :class="['mt-4 p-4 rounded-lg text-center', feedback.type === 'success' ? 'bg-green-100 text-green-800' : 'bg-red-100 text-red-800']"> {{ feedback.message }} </div> <div class="text-center" v-if="exercise.isComplete"> <h3 class="text-xl font-bold mb-4">Ćwiczenie zakończone!</h3> <p>Poprawne odpowiedzi: {{ stats.correctAnswers }} / {{ exercise.totalQuestions }}</p> <button @click="isSetupMode = true" class="mt-4 bg-indigo-600 text-white px-6 py-2 rounded-lg hover:bg-indigo-700 transition-colors" > Spróbuj ponownie </button> </div> <!-- Przycisk podpowiedzi --> <div v-if="!isSetupMode && settings.mode === 'learn'" class="mt-4"> <button @click="showHint" class="bg-yellow-500 text-white px-4 py-2 rounded-lg hover:bg-yellow-600 transition-colors" > 💡 Pokaż podpowiedź </button> <!-- Sekcja podpowiedzi --> <div v-if="hints.isVisible" class="mt-4 p-6 bg-yellow-50 rounded-lg"> <div class="flex justify-between items-center mb-4"> <button @click="previousHintStep" :disabled="hints.currentStep === 0" class="text-yellow-600 disabled:text-gray-400" > ← Poprzedni krok </button> <span class="text-yellow-800"> Krok {{ hints.currentStep + 1 }} z {{ hints.maxSteps }} </span> <button @click="nextHintStep" :disabled="hints.currentStep === hints.maxSteps - 1" class="text-yellow-600 disabled:text-gray-400" > Następny krok → </button> </div> <div v-if="hints.visualElements[hints.currentStep]" class="text-center p-4 bg-yellow-100 rounded-lg"> {{ hints.visualElements[hints.currentStep].description }} </div> </div> </div> </div> </div> ` }; |