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 | export default { data() { return { // Stan początkowy - wybór trybu isSetupMode: true, // Ustawienia ćwiczenia settings: { mode: null, // 'learn' lub 'challenge' range: null, // 'small', 'medium', 'large' vehicle: 'train', // 'train' lub 'rocket' step: 1, // Domyślny krok direction: 'forward' // 'forward' lub 'backward' }, // Dane ćwiczenia exercise: { currentNumber: 0, targetNumber: 0, direction: 'forward', // 'forward' lub 'backward' step: 1, numbers: [], currentIndex: 0, isComplete: false }, // Odpowiedź użytkownika userAnswer: '', // Statystyki stats: { points: 0, level: 1, currentStreak: 0, mistakes: 0 }, // Feedback feedback: { message: '', type: '' // 'success', 'error', 'hint' }, // Timer dla trybu wyzwań timer: { time: 0, isRunning: false, interval: null }, setupValidation: { mode: { required: true, selected: false }, range: { required: true, selected: false }, direction: { required: true, selected: false } }, setupFeedback: { show: true, message: 'Wybierz opcje aby rozpocząć ćwiczenie! 😊', type: 'info' } } }, template: ` <div class="max-w-4xl mx-auto bg-white rounded-lg shadow-lg p-6"> <!-- Nagłówek z przyciskiem powrotu i statystykami --> <div class="flex justify-between items-center mb-6"> <button @click="isSetupMode ? $emit('back') : resetExercise()" class="text-indigo-600 hover:text-indigo-800 flex items-center" > <span class="mr-2">←</span> {{ isSetupMode ? 'Powrót' : 'Zmień ustawienia' }} </button> <div class="flex items-center space-x-4"> <div class="bg-indigo-100 px-3 py-1 rounded-full"> <span class="text-indigo-800">Punkty: {{ stats.points }}</span> </div> <div class="bg-green-100 px-3 py-1 rounded-full"> <span class="text-green-800">Seria: {{ stats.currentStreak }}</span> </div> <div v-if="settings.mode === 'challenge'" class="bg-red-100 px-3 py-1 rounded-full"> <span class="text-red-800">Czas: {{ timer.time }}s</span> </div> </div> </div> <!-- Komunikat pomocniczy --> <div v-if="setupFeedback.show" :class="['p-4 rounded-lg text-center transition-all duration-300', setupFeedback.type === 'info' ? 'bg-blue-100 text-blue-800' : setupFeedback.type === 'warning' ? 'bg-yellow-100 text-yellow-800' : setupFeedback.type === 'success' ? 'bg-green-100 text-green-800' : '']" > <p class="text-lg font-medium">{{ setupFeedback.message }}</p> </div> <!-- Ekran wyboru trybu --> <div v-if="isSetupMode" class="space-y-8"> <!-- Wybór trybu --> <div class="space-y-4"> <h3 class="text-xl font-semibold text-gray-700">Wybierz tryb:</h3> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"> <button @click="settings.mode = 'learn'" :class="[ 'p-6 rounded-lg border-2 text-center transition-all', settings.mode === 'learn' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-4xl mb-2">📚</div> <h4 class="font-semibold">Tryb nauki</h4> <p class="text-sm text-gray-600">Ucz się w swoim tempie</p> </button> <button @click="settings.mode = 'challenge'" :class="[ 'p-6 rounded-lg border-2 text-center transition-all', settings.mode === 'challenge' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-4xl mb-2">⭐</div> <h4 class="font-semibold">Tryb wyzwań</h4> <p class="text-sm text-gray-600">Sprawdź swoje umiejętności</p> </button> </div> </div> <!-- Wybór zakresu --> <div class="space-y-4"> <h3 class="text-xl font-semibold text-gray-700">Wybierz zakres:</h3> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"> <button @click="settings.range = 'small'" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.range === 'small' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-2xl mb-2">🚂</div> <h4 class="font-semibold">Mała podróż</h4> <p class="text-sm text-gray-600">Liczby 1-20</p> </button> <button @click="settings.range = 'medium'" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.range === 'medium' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-2xl mb-2">🚄</div> <h4 class="font-semibold">Średnia podróż</h4> <p class="text-sm text-gray-600">Liczby 1-50</p> </button> <button @click="settings.range = 'large'" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.range === 'large' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-2xl mb-2">🚅</div> <h4 class="font-semibold">Długa podróż</h4> <p class="text-sm text-gray-600">Liczby 1-100</p> </button> </div> </div> <!-- Wybór kroku --> <div class="space-y-4"> <h3 class="text-xl font-semibold text-gray-700">Wybierz krok:</h3> <div class="grid grid-cols-5 gap-2"> <button v-for="step in 10" :key="step" @click="settings.step = step" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.step === step ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <span class="text-xl font-bold">+{{ step }}</span> </button> </div> </div> <!-- Wybór kierunku --> <div class="space-y-4"> <h3 class="text-xl font-semibold text-gray-700">Wybierz kierunek:</h3> <div class="grid grid-cols-2 gap-4"> <button @click="settings.direction = 'forward'" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.direction === 'forward' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-2xl mb-2">➡️</div> <span class="font-semibold">W przód</span> </button> <button @click="settings.direction = 'backward'" :class="[ 'p-4 rounded-lg border-2 text-center transition-all', settings.direction === 'backward' ? 'border-indigo-500 bg-indigo-50' : 'border-gray-200 hover:border-indigo-300' ]" > <div class="text-2xl mb-2">⬅️</div> <span class="font-semibold">Wstecz</span> </button> </div> </div> <!-- Przycisk rozpoczęcia --> <div class="text-center"> <button @click="startExercise" :disabled="!canStart" :class="[ 'px-8 py-3 rounded-lg font-semibold text-white transition-all', canStart ? 'bg-indigo-600 hover:bg-indigo-700' : 'bg-gray-300 cursor-not-allowed' ]" > Rozpocznij ćwiczenie </button> </div> </div> <!-- Ekran ćwiczenia --> <div v-else-if="!exercise.isComplete" class="space-y-8"> <!-- Pojazd z liczbami --> <div class="relative h-48 bg-gray-50 rounded-lg overflow-hidden"> <!-- Tory/Trasa --> <div class="absolute bottom-0 w-full h-4 bg-gray-300"></div> <!-- Pociąg/Rakieta --> <div class="absolute bottom-4 left-1/2 transform -translate-x-1/2 flex items-center space-x-2"> <!-- Lokomotywa/Rakieta --> <div :class="[ 'w-24 h-24 flex items-center justify-center text-2xl', settings.vehicle === 'train' ? 'bg-blue-500' : 'bg-purple-500', 'rounded-lg transform transition-transform hover:scale-105' ]"> {{ settings.vehicle === 'train' ? '🚂' : '🚀' }} </div> <!-- Wagon/Segment z aktualną liczbą --> <div class="bg-white w-20 h-20 rounded-lg shadow-lg flex items-center justify-center text-3xl font-bold border-4 border-indigo-500"> {{ exercise.currentNumber }} </div> <!-- Znak zapytania dla następnej liczby --> <div class="bg-yellow-100 w-20 h-20 rounded-lg shadow-lg flex items-center justify-center text-3xl font-bold border-4 border-yellow-500"> ? </div> </div> </div> <!-- Dodajemy informację o kroku i kierunku --> <div class="text-center text-gray-600"> <span class="font-semibold"> {{ settings.direction === 'forward' ? 'Dodaj' : 'Odejmij' }} {{ settings.step }} </span> </div> <!-- Pytanie i pole odpowiedzi --> <div class="text-center space-y-4"> <h3 class="text-xl font-semibold text-gray-700"> Jaka liczba powinna być następna? </h3> <div class="flex justify-center items-center space-x-4"> <input type="number" v-model="userAnswer" @keyup.enter="checkAnswer" class="w-32 h-16 text-3xl text-center rounded-lg border-2 border-indigo-300 focus:border-indigo-500 focus:ring focus:ring-indigo-200" :disabled="exercise.isComplete" placeholder="?" autofocus > <button @click="checkAnswer" :disabled="!canProceed" class="h-16 px-8 rounded-lg bg-indigo-600 text-white font-semibold hover:bg-indigo-700 disabled:bg-gray-300 disabled:cursor-not-allowed" > Sprawdź </button> </div> <!-- Feedback --> <div v-if="feedback.message" :class="[ 'p-4 rounded-lg text-lg', feedback.type === 'success' ? 'bg-green-100 text-green-700' : feedback.type === 'error' ? 'bg-red-100 text-red-700' : 'bg-blue-100 text-blue-700' ]" > {{ feedback.message }} </div> </div> </div> <!-- Ekran podsumowania --> <div v-else class="text-center space-y-6"> <h3 class="text-2xl font-bold text-indigo-600">Ćwiczenie zakończone!</h3> <div class="space-y-2"> <p class="text-lg">Zdobyte punkty: <span class="font-bold">{{ stats.points }}</span></p> <p class="text-lg">Najdłuższa seria: <span class="font-bold">{{ stats.currentStreak }}</span></p> <p class="text-lg">Liczba błędów: <span class="font-bold">{{ stats.mistakes }}</span></p> </div> <div class="flex justify-center space-x-4"> <button @click="initializeExercise" class="px-6 py-3 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700" > Spróbuj ponownie </button> <button @click="resetExercise" class="px-6 py-3 bg-gray-600 text-white rounded-lg hover:bg-gray-700" > Zmień ustawienia </button> </div> </div> </div> `, computed: { canStart() { return this.settings.mode && this.settings.range && this.settings.direction; }, rangeLimit() { switch (this.settings.range) { case 'small': return 20; case 'medium': return 50; case 'large': return 100; default: return 20; } }, // Określa, czy użytkownik może przejść dalej canProceed() { return this.userAnswer !== '' && !this.exercise.isComplete; } }, methods: { updateSetupValidation(field, value) { this.setupValidation[field].selected = !!value; this.checkSetupCompleteness(); }, checkSetupCompleteness() { const missing = []; if (!this.settings.mode) missing.push('tryb ćwiczenia'); if (!this.settings.range) missing.push('zakres liczb'); if (!this.settings.direction) missing.push('kierunek liczenia'); if (missing.length > 0) { this.setupFeedback = { show: true, message: `Wybierz jeszcze: ${missing.join(', ')} 😊`, type: 'info' }; } else { this.setupFeedback = { show: true, message: 'Świetnie! Możesz rozpocząć ćwiczenie! 🎉', type: 'success' }; } }, startExercise() { if (!this.settings.mode || !this.settings.range || !this.settings.direction) { this.setupFeedback = { show: true, message: 'Wybierz wszystkie potrzebne opcje przed rozpoczęciem 😊', type: 'warning' }; return; } this.isSetupMode = false; this.initializeExercise(); if (this.settings.mode === 'challenge') { this.startTimer(); } }, initializeExercise() { // Generowanie sekwencji liczb const start = Math.floor(Math.random() * 5) + 1; // Losowy start od 1 do 5 this.exercise.numbers = this.generateSequence(start); this.exercise.currentIndex = 0; this.exercise.currentNumber = this.exercise.numbers[0]; this.exercise.targetNumber = this.exercise.numbers[1]; this.userAnswer = ''; this.feedback.message = ''; }, generateSequence(start) { const numbers = []; const count = this.settings.mode === 'learn' ? 5 : 10; for (let i = 0; i < count; i++) { let randomNum; if (this.settings.direction === 'forward') { // Dla liczenia w przód, maksymalna liczba to limit - krok randomNum = Math.floor(Math.random() * (this.rangeLimit - this.settings.step)) + 1; } else { // Dla liczenia wstecz, minimalna liczba to krok + 1 randomNum = Math.floor(Math.random() * (this.rangeLimit - this.settings.step)) + this.settings.step + 1; } numbers.push(randomNum); } return numbers; }, getNextNumber(currentNumber) { return this.settings.direction === 'forward' ? currentNumber + this.settings.step : currentNumber - this.settings.step; }, checkAnswer() { const answer = parseInt(this.userAnswer); const expectedAnswer = this.getNextNumber(this.exercise.currentNumber); const isCorrect = answer === expectedAnswer; if (isCorrect) { this.handleCorrectAnswer(); } else { this.handleIncorrectAnswer(expectedAnswer); } }, handleCorrectAnswer() { this.feedback = { message: 'Świetnie! To prawidłowa odpowiedź!', type: 'success' }; this.stats.currentStreak++; this.addPoints(); // Przejście do następnej liczby setTimeout(() => { this.moveToNext(); }, 1000); }, handleIncorrectAnswer(expectedAnswer) { this.stats.mistakes++; this.stats.currentStreak = 0; // Dostosowany komunikat błędu this.feedback = { message: this.settings.mode === 'learn' ? `Spróbuj jeszcze raz! Po liczbie ${this.exercise.currentNumber} ${this.settings.direction === 'forward' ? 'następna' : 'poprzednia'} to ${expectedAnswer}` : 'Nieprawidłowa odpowiedź!', type: 'error' }; }, moveToNext() { this.exercise.currentIndex++; if (this.exercise.currentIndex >= this.exercise.numbers.length - 1) { this.completeExercise(); return; } // Ustawiamy nową losową liczbę jako aktualną this.exercise.currentNumber = this.exercise.numbers[this.exercise.currentIndex]; // Nie potrzebujemy już targetNumber, bo będziemy go obliczać dynamicznie this.userAnswer = ''; this.feedback.message = ''; }, addPoints() { let points = 10; // Bonus za większy krok points += (this.settings.step - 1) * 2; // Bonus za tryb wyzwań if (this.settings.mode === 'challenge') points *= 1.5; // Bonus za streak if (this.stats.currentStreak > 2) points *= 1.2; this.stats.points += Math.round(points); }, completeExercise() { this.exercise.isComplete = true; this.timer.isRunning = false; clearInterval(this.timer.interval); // Obliczanie wyniku końcowego const accuracy = ((this.exercise.numbers.length - this.stats.mistakes) / this.exercise.numbers.length) * 100; this.feedback = { message: `Gratulacje! Ukończyłeś ćwiczenie! Zdobyte punkty: ${this.stats.points}, Dokładność: ${Math.round(accuracy)}%`, type: 'success' }; }, startTimer() { this.timer.time = this.settings.mode === 'challenge' ? 60 : 0; this.timer.isRunning = true; this.timer.interval = setInterval(() => { if (this.timer.time > 0) { this.timer.time--; } else { this.completeExercise(); } }, 1000); }, resetExercise() { this.isSetupMode = true; this.exercise.isComplete = false; this.stats.points = 0; this.stats.currentStreak = 0; this.stats.mistakes = 0; clearInterval(this.timer.interval); } }, watch: { 'settings.mode'(newValue) { this.updateSetupValidation('mode', newValue); }, 'settings.range'(newValue) { this.updateSetupValidation('range', newValue); }, 'settings.direction'(newValue) { this.updateSetupValidation('direction', newValue); } }, mounted() { this.checkSetupCompleteness(); } }; |