Zadachi Po Matematika Za 4 Klas Apr 2026
.new-task-btn:hover background: #1f5e7a; transform: scale(0.97);
.task-question padding: 1.5rem 1.5rem 1rem; font-size: 1.4rem; font-weight: 600; line-height: 1.4; color: #0f172a; min-height: 110px;
.feedback.wrong background: #ffe6e5; color: #c0392b; border-left: 5px solid #e74c3c; zadachi po matematika za 4 klas
.task-header background: #f8fafc; padding: 1rem 1.5rem; border-bottom: 2px dashed #cbd5e1; font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: #475569; display: flex; justify-content: space-between;
/* header area */ .hero background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%); padding: 2rem 2rem 1.8rem 2rem; text-align: center; color: white; // But also we want user to solve
.task-input-area input:focus border-color: #2c7da0; box-shadow: 0 0 0 3px rgba(44,125,160,0.2);
.score-box background: #f0f4fe; border-radius: 40px; padding: 0.4rem 1.2rem; font-weight: bold; font-size: 1.2rem; color: #1e3c72; box-shadow: inset 0 1px 2px #0000, 0 2px 5px rgba(0,0,0,0.02); When solved, it's marked correct and can't change
.task-input-area input flex: 2; min-width: 120px; padding: 12px 16px; font-size: 1rem; border: 2px solid #e2e8f0; border-radius: 60px; font-weight: 500; transition: 0.2s; outline: none; font-family: monospace; font-size: 1.1rem;
// 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: false , 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>
/* 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;