Zadachi Po Matematika Za 4 Klas -
.task-input-area input:focus border-color: #2c7da0; box-shadow: 0 0 0 3px rgba(44,125,160,0.2);
.new-task-btn:hover background: #1f5e7a; transform: scale(0.97);
/* main content grid */ .tasks-grid display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.8rem; padding: 2rem;
.congrats text-align: center; background: #e6f7e6; margin: 0 2rem 2rem 2rem; padding: 0.8rem; border-radius: 50px; font-weight: bold; color: #2b6e2f; </style> </head> <body> <div class="math-lab"> <div class="hero"> <h1> 📐 Задачи по математика <span>4. клас</span> </h1> <p>✏️ Умножение, деление, дроби, логика и мерни единици</p> </div> <div class="stats-bar"> <div class="score-box"> 🏆 Решени задачи: <span id="scoreValue">0</span> / <span id="totalTasksCount">0</span> </div> <div style="display: flex; gap: 12px;"> <button class="new-task-btn" id="refreshAllBtn">🔄 Нови задачи</button> <button class="new-task-btn reset-btn" id="resetProgressBtn">♻️ Нулирай резултата</button> </div> </div> zadachi po matematika za 4 klas
button background: none; border: none; font-family: inherit;
.hero h1 span background: #ffd966; color: #1e3c72; font-size: 1.8rem; border-radius: 60px; padding: 0 20px; display: inline-block;
<div id="tasksContainer" class="tasks-grid"> <!-- dynamic tasks will be injected here --> </div> <div id="congratsMessage" style="display: none;" class="congrats">🎉 Браво! Реши всички задачи! 🎉</div> </div> // But also we want user to solve
body background: linear-gradient(145deg, #f5f7fc 0%, #eef2f8 100%); font-family: 'Segoe UI', 'Roboto', 'Poppins', system-ui, -apple-system, 'Nunito', sans-serif; padding: 1.5rem; min-height: 100vh; display: flex; justify-content: center; align-items: center;
/* main card container */ .math-lab max-width: 1300px; width: 100%; background: rgba(255,255,255,0.75); backdrop-filter: blur(2px); border-radius: 3rem; box-shadow: 0 25px 45px -12px rgba(0,0,0,0.25), 0 8px 18px rgba(0,0,0,0.05); overflow: hidden; transition: all 0.2s ease;
// Number of active tasks displayed at once (we want 4 tasks per page for clarity, but can show all? we choose 6 for rich experience) // Better: display 6 tasks at random from bank (or all if less than 6). But to keep fresh, we randomize each "new tasks" click. // But also we want user to solve all visible tasks, then show congrats when all visible solved. // Implementation: We'll store currentTasks array (each task object with additional fields: solved flag, userAnswer, feedback, id) // Each task card is independent. User can check answers. When solved, it's marked correct and can't change? Actually we allow re-check? // We'll design: once correct -> input disabled and check button disabled or shows ✓. But also reset progress will reset solved flags. // New tasks button will generate fresh set of tasks (random selection from bank, maybe 6 tasks). Reset progress clears solved flags without changing tasks. let currentTasks = []; // active tasks objects extended with id, taskData, solved, userAnswer, feedbackClass, feedbackMsg let globalScore = 0; // number of solved tasks in currentTasks let taskCounter = 0; // simple unique id // DOM elements const tasksContainer = document.getElementById('tasksContainer'); const scoreSpan = document.getElementById('scoreValue'); const totalTasksSpan = document.getElementById('totalTasksCount'); const refreshBtn = document.getElementById('refreshAllBtn'); const resetProgressBtn = document.getElementById('resetProgressBtn'); const congratsDiv = document.getElementById('congratsMessage'); // Helper: check if two answers match (numeric or time string) function isAnswerMatch(userAnswerRaw, correctAnswerRaw, isTimeTask = false) // trim and normalize let userStr = String(userAnswerRaw).trim().toLowerCase(); // For time based tasks like "16:40" also accept "16:40" or "4:40pm"? but we keep simple. if (isTimeTask) // remove spaces and accept both "16:40" and "16,40"? allow "16:40" let normalizedUser = userStr.replace(/[^0-9:]/g, ''); let normalizedCorrect = String(correctAnswerRaw).trim().toLowerCase().replace(/[^0-9:]/g, ''); return normalizedUser === normalizedCorrect; // numeric or decimal let userNum = parseFloat(userStr.replace(',', '.')); // support comma as decimal separator if (isNaN(userNum)) return false; let correctNum = parseFloat(correctAnswerRaw); if (isNaN(correctNum)) return false; // allow tiny floating tolerance for decimals like 4.5 return Math.abs(userNum - correctNum) < 0.0001; // update score UI and check congrats function updateGlobalStats() const solvedCount = currentTasks.filter(t => t.solved).length; globalScore = solvedCount; scoreSpan.innerText = globalScore; totalTasksSpan.innerText = currentTasks.length; if (currentTasks.length > 0 && globalScore === currentTasks.length) congratsDiv.style.display = 'block'; else congratsDiv.style.display = 'none'; // re-render all tasks from currentTasks array (fully rebuild cards) function renderTasks() if (!tasksContainer) return; tasksContainer.innerHTML = ''; if (currentTasks.length === 0) tasksContainer.innerHTML = '<div style="grid-column:1/-1; text-align:center; padding:2rem;">🎯 Натисни "Нови задачи" за да започнеш 🎯</div>'; updateGlobalStats(); return; currentTasks.forEach((task, idx) => const card = document.createElement('div'); card.className = 'task-card'; const taskData = task.taskData; const isSolved = task.solved; // Header const headerDiv = document.createElement('div'); headerDiv.className = 'task-header'; headerDiv.innerHTML = `<span>📌 Задача $idx+1</span><span class="task-category">$</span>`; // Question const questionDiv = document.createElement('div'); questionDiv.className = 'task-question'; questionDiv.innerText = taskData.text; // Input area const inputArea = document.createElement('div'); inputArea.className = 'task-input-area'; const inputEl = document.createElement('input'); inputEl.type = 'text'; inputEl.placeholder = 'Вашият отговор...'; inputEl.disabled = isSolved; if (!isSolved && task.userAnswer !== undefined && task.userAnswer !== null) inputEl.value = task.userAnswer; else if (isSolved && task.userAnswer) inputEl.value = task.userAnswer; else inputEl.value = ''; const checkBtn = document.createElement('button'); checkBtn.className = 'check-btn'; checkBtn.innerText = isSolved ? '✓ Решена' : '🔍 Провери'; checkBtn.disabled = isSolved; if (!isSolved) checkBtn.style.opacity = '1'; checkBtn.style.cursor = 'pointer'; else checkBtn.style.opacity = '0.7'; checkBtn.style.cursor = 'default'; inputArea.appendChild(inputEl); inputArea.appendChild(checkBtn); // Feedback const feedbackDiv = document.createElement('div'); feedbackDiv.className = `feedback $ ''`; feedbackDiv.innerText = task.feedbackMsg ); updateGlobalStats(); // generate random subset from tasks bank (size between 4 and 8, we choose 6 tasks) function getRandomTasks(count = 6) if (TASKS_BANK.length === 0) return []; const shuffled = [...TASKS_BANK]; for (let i = shuffled.length - 1; i > 0; i--) const j = Math.floor(Math.random() * (i + 1)); [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]]; let selected = shuffled.slice(0, count); // ensure variety: if less than count due to bank, duplicate? but bank has 16 items, fine. if (selected.length < count && TASKS_BANK.length >= count) selected = shuffled.slice(0, count); return selected; // create new tasks set (full reset of solved status, fresh questions) function generateNewTasks() const freshTaskBank = getRandomTasks(6); // 6 задачи на екрана за добро разнообразие const newTasksArray = freshTaskBank.map((taskData, index) => return id: taskCounter++, taskData: , solved: false, userAnswer: '', feedbackMsg: '⏳ Въведи отговор и натисни "Провери"', feedbackClass: '' ; ); currentTasks = newTasksArray; renderTasks(); // reset only solved flags but keep same tasks function resetProgress() if (currentTasks.length === 0) // if no tasks, maybe generate default ones generateNewTasks(); return; currentTasks = currentTasks.map(task => ( ...task, solved: false, userAnswer: '', feedbackMsg: '⏳ Въведи отговор и натисни "Провери"', feedbackClass: '' )); renderTasks(); // Event handlers refreshBtn.addEventListener('click', () => generateNewTasks(); ); resetProgressBtn.addEventListener('click', () => if (currentTasks.length === 0) generateNewTasks(); else resetProgress(); ); // initial load: generate default 6 interesting tasks function init() generateNewTasks(); init(); </script> </body> </html> if (selected.length <
.feedback margin: 0.5rem 1.5rem 1.5rem; padding: 0.6rem 1rem; border-radius: 50px; font-size: 0.9rem; font-weight: 500; background: #f1f5f9; color: #334155; transition: all 0.2s;
.score-box span font-size: 1.6rem; font-weight: 800; margin-right: 5px; color: #2b6e9e;