Redesign admin dashboard with sidebar layout, planner overhaul, and readability fixes
Build and Push Docker Image / build-and-push (push) Successful in 41s

- Replace horizontal top-nav with a dark sidebar (grouped: People / Academics / Tools)
- Add Dashboard landing page with kid stat cards, today's schedule, and recent scores
- Add /api/admin/schedule and /api/admin/recent-scores endpoints for dashboard data
- Add Lock button and mobile sidebar toggle in top bar
- Redesign planner toolbar: two-section layout (nav left, actions right)
- Elevate auto-schedule out of hidden accordion into always-visible inline bar
- Richer planner task cards: course color stripe, course name label, completion counter per day
- Dashed "+ Add task" empty state instead of plain dash
- Fix nav-pill CSS conflict: student tabs (light bg) now use dark text; admin sidebar keeps white text
- Add seed.js demo data script for two students (Emma and Liam)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nmemmertandClaude Sonnet 4.6 committed 2026-10-19 13:31:12 -04:00
1 parent ab32ba8634
commit 7775c4fc3a
5 files changed
+1421 -124

No files matched your search

+96 -33
View File
@@ -21,25 +21,80 @@
</section>
<div id="console" hidden>
<header class="admin-header">
<a href="index.html" class="admin-logo" id="admin-school-name">🎓 Homeschool</a>
<aside class="admin-sidebar">
<a href="index.html" class="admin-logo">
<span class="admin-logo-icon">🏫</span>
<span id="admin-school-name">Homeschool</span>
</a>
<nav class="admin-nav">
<button class="nav-pill active" data-panel="kids">🧒 Kids</button>
<button class="nav-pill" data-panel="courses">📚 Courses</button>
<button class="nav-pill" data-panel="planner">🗓️ Planner</button>
<button class="nav-pill" data-panel="grading">✅ Grading</button>
<button class="nav-pill" data-panel="messages">💬 Messages</button>
<button class="nav-pill" data-panel="gradebook">📊 Gradebook</button>
<button class="nav-pill" data-panel="spelling">✏️ Spelling</button>
<button class="nav-pill" data-panel="decks">🗂️ Flashcards</button>
<button class="nav-pill" data-panel="settings">⚙️ Settings</button>
<button class="nav-pill active" data-panel="dashboard">
<span class="nav-icon">⊞</span><span class="nav-label">Dashboard</span>
</button>
<div class="nav-section-label">People</div>
<button class="nav-pill" data-panel="kids">
<span class="nav-icon">🧒</span><span class="nav-label">Kids</span>
</button>
<button class="nav-pill" data-panel="messages">
<span class="nav-icon">💬</span><span class="nav-label">Messages</span>
</button>
<div class="nav-section-label">Academics</div>
<button class="nav-pill" data-panel="courses">
<span class="nav-icon">📚</span><span class="nav-label">Courses</span>
</button>
<button class="nav-pill" data-panel="planner">
<span class="nav-icon">🗓️</span><span class="nav-label">Planner</span>
</button>
<button class="nav-pill" data-panel="grading">
<span class="nav-icon">✅</span><span class="nav-label">Grading</span>
</button>
<button class="nav-pill" data-panel="gradebook">
<span class="nav-icon">📊</span><span class="nav-label">Gradebook</span>
</button>
<div class="nav-section-label">Tools</div>
<button class="nav-pill" data-panel="spelling">
<span class="nav-icon">✏️</span><span class="nav-label">Spelling</span>
</button>
<button class="nav-pill" data-panel="decks">
<span class="nav-icon">🗂️</span><span class="nav-label">Flashcards</span>
</button>
</nav>
<div class="admin-sidebar-footer">
<button class="nav-pill" data-panel="settings">
<span class="nav-icon">⚙️</span><span class="nav-label">Settings</span>
</button>
</div>
</aside>
<div class="admin-body">
<header class="admin-topbar">
<button class="sidebar-toggle" id="sidebar-toggle" aria-label="Toggle menu">☰</button>
<h1 class="admin-page-title" id="admin-page-title">Dashboard</h1>
<div class="admin-topbar-right">
<a href="index.html" class="topbar-btn">← Student view</a>
<button class="topbar-btn topbar-lock" id="btn-lock">🔒 Lock</button>
</div>
</header>
<main class="admin-main">
<!-- Dashboard -->
<section id="panel-dashboard" class="panel">
<div id="dashboard-greeting" class="dash-greeting"></div>
<div id="dashboard-kid-cards" class="dash-kid-grid"></div>
<div class="dash-bottom-row">
<div class="dash-col">
<h3 class="dash-col-title">Today's Schedule</h3>
<div id="dashboard-schedule" class="dash-schedule-list"></div>
</div>
<div class="dash-col">
<h3 class="dash-col-title">Recent Scores</h3>
<div id="dashboard-scores" class="dash-score-list"></div>
</div>
</div>
</section>
<!-- Kids -->
<section id="panel-kids" class="panel">
<section id="panel-kids" class="panel" hidden>
<h1>Kids</h1>
<div class="panel-cols">
<div class="panel-col">
@@ -331,30 +386,37 @@
<!-- Planner -->
<section id="panel-planner" class="panel">
<h1>Planner</h1>
<div class="inline-form">
<label>Kid <select id="planner-student"></select></label>
<button id="planner-view-week" class="secondary active-view">Week</button>
<button id="planner-view-month" class="secondary">Month</button>
<button id="planner-prev" class="secondary">← Prev</button>
<div class="planner-toolbar">
<div class="planner-toolbar-left">
<div class="planner-view-toggle">
<button id="planner-view-week" class="view-toggle-btn active">Week</button>
<button id="planner-view-month" class="view-toggle-btn">Month</button>
</div>
<div class="planner-nav-group">
<button id="planner-prev" class="planner-nav-btn">‹</button>
<span id="planner-week-label" class="week-label"></span>
<button id="planner-next" class="secondary">Next →</button>
<button id="planner-today" class="secondary">Today</button>
<button id="planner-copy" class="secondary">Copy last week</button>
<button id="planner-print">🖨 Print</button>
<button id="planner-next" class="planner-nav-btn">›</button>
</div>
<button id="planner-today" class="secondary small">Today</button>
</div>
<div class="planner-toolbar-right">
<select id="planner-student" class="planner-kid-select"></select>
<button id="planner-copy" class="secondary small" title="Copy last week's tasks to this week">📋 Copy week</button>
<button id="planner-print" class="secondary small">🖨 Print</button>
<button id="planner-add-btn">+ Add task</button>
</div>
<details id="auto-schedule-details" class="admin-card" style="margin-bottom:1rem">
<summary style="cursor:pointer;font-weight:600">⚡ Auto-schedule a course</summary>
<div class="inline-form" style="margin-top:.75rem">
<label>Course <select id="auto-course"></select></label>
<label>Start date <input type="date" id="auto-start-date"></label>
<label>Items/day <input type="number" id="auto-items-per-day" value="1" min="1" max="10" style="width:5rem"></label>
<button id="auto-schedule-btn">Schedule</button>
</div>
<p id="auto-schedule-msg" class="hint" style="margin-top:.5rem"></p>
</details>
<div class="planner-auto-bar">
<span class="planner-auto-label">⚡ Auto-schedule</span>
<select id="auto-course"></select>
from <input type="date" id="auto-start-date" style="width:8rem">
<input type="number" id="auto-items-per-day" value="1" min="1" max="10" style="width:3.5rem" title="Items per day">
<span style="color:var(--muted);font-size:.8rem">items/day</span>
<button id="auto-schedule-btn" class="secondary small">Schedule</button>
<span id="auto-schedule-msg" class="hint"></span>
</div>
<div id="planner-grid" class="planner-grid"></div>
</section>
@@ -683,7 +745,8 @@
</section>
</main>
</div>
</div><!-- /.admin-body -->
</div><!-- /#console -->
<!-- Floating assign popup -->
<div id="assign-popup" hidden>
+155 -23
View File
@@ -82,22 +82,25 @@ async function unlock() {
await loadAppSettings();
$('#pin-gate').hidden = true;
$('#console').hidden = false;
showPanel('kids');
showPanel('dashboard');
if ('Notification' in window && Notification.permission === 'default') Notification.requestPermission();
loadGradingBadge();
loadMessagesBadge();
startAdminMsgPoll();
loadDashboard();
}
async function loadGradingBadge() {
try {
const { count } = await api('/api/grading-queue/count');
const pill = document.querySelector('.nav-pill[data-panel="grading"]');
if (!pill) return;
const lbl = pill.querySelector('.nav-label');
if (count > 0) {
pill.textContent = `✅ Grading (${count})`;
if (lbl) lbl.textContent = `Grading (${count})`;
pill.classList.add('grading-pending');
} else {
pill.textContent = '✅ Grading';
if (lbl) lbl.textContent = 'Grading';
pill.classList.remove('grading-pending');
}
} catch {}
@@ -114,11 +117,20 @@ document.querySelectorAll('[data-nav]').forEach((btn) =>
btn.addEventListener('click', () => showPanel(btn.dataset.nav))
);
const PANEL_TITLES = {
dashboard: 'Dashboard', kids: 'Kids', courses: 'Courses', planner: 'Planner',
grading: 'Grading', messages: 'Messages', gradebook: 'Gradebook',
spelling: 'Spelling', decks: 'Flashcards', settings: 'Settings',
'course-detail': 'Course Detail', 'item-editor': 'Item Editor',
};
function showPanel(name) {
document.querySelectorAll('.panel').forEach((p) => (p.hidden = p.id !== `panel-${name}`));
document.querySelectorAll('.admin-nav .nav-pill').forEach((p) => p.classList.toggle('active', p.dataset.panel === name));
const titleEl = document.getElementById('admin-page-title');
if (titleEl) titleEl.textContent = PANEL_TITLES[name] || name;
const loaders = {
kids: loadKids, courses: loadCourses, planner: loadPlannerPanel,
dashboard: loadDashboard, kids: loadKids, courses: loadCourses, planner: loadPlannerPanel,
grading: loadGrading, messages: loadMessages, gradebook: loadGradebookPanel, spelling: loadSpelling, decks: loadDecks,
settings: loadSettings,
};
@@ -126,6 +138,99 @@ function showPanel(name) {
if (name === 'course-detail') openCourseDetail(currentCourseId);
}
// sidebar toggle + lock button
document.getElementById('sidebar-toggle')?.addEventListener('click', () => {
document.querySelector('.admin-sidebar')?.classList.toggle('open');
});
document.getElementById('btn-lock')?.addEventListener('click', () => {
sessionStorage.removeItem('admin_pin');
location.reload();
});
// ============================================================
// Dashboard
// ============================================================
async function loadDashboard() {
const greetEl = document.getElementById('dashboard-greeting');
const kidGrid = document.getElementById('dashboard-kid-cards');
const schedEl = document.getElementById('dashboard-schedule');
const scoresEl = document.getElementById('dashboard-scores');
if (!greetEl) return;
const hr = new Date().getHours();
const greet = hr < 12 ? 'Good morning' : hr < 17 ? 'Good afternoon' : 'Good evening';
const dateStr = new Date().toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric' });
greetEl.innerHTML = `<h1>${greet}! 👋</h1><p>${dateStr}</p>`;
try {
const [students, scheduleData, recentScores] = await Promise.all([
api('/api/students'),
api(`/api/admin/schedule?date=${new Date().toISOString().slice(0,10)}`).catch(() => ({ rows: [] })),
api('/api/admin/recent-scores').catch(() => ({ scores: [] })),
]);
const THEME_HEX = { blue:'#4f86f7', green:'#2e9e5b', purple:'#7c5cbf', orange:'#e8802a', pink:'#d45d8a', red:'#e84040', teal:'#20a8a0', yellow:'#c8960c', indigo:'#5b6abf' };
const rows = scheduleData.rows || scheduleData || [];
kidGrid.innerHTML = '';
for (const s of students) {
const kidRows = rows.filter(r => r.student_id === s.id);
const total = kidRows.length;
const done = kidRows.filter(r => r.done).length;
const pct = total ? Math.round(done / total * 100) : 0;
const accent = THEME_HEX[s.theme?.replace('theme-','')] || '#4f7ef8';
kidGrid.innerHTML += `
<div class="dash-kid-card" style="--kid-accent:${accent}">
<div class="dash-kid-top">
<span class="dash-kid-avatar">${s.emoji || '🧒'}</span>
<div>
<div class="dash-kid-name">${s.name}</div>
<div class="dash-kid-streak">🔥 ${s.streak_count || 0}-day streak</div>
</div>
</div>
<div class="dash-kid-stats">
<div class="dash-stat-box">
<div class="dash-stat-num">${done}</div>
<div class="dash-stat-lbl">Done today</div>
</div>
<div class="dash-stat-box">
<div class="dash-stat-num">${total}</div>
<div class="dash-stat-lbl">Scheduled</div>
</div>
</div>
<div class="dash-progress-bar">
<div class="dash-progress-fill" style="width:${pct}%"></div>
</div>
</div>`;
}
schedEl.innerHTML = rows.length ? rows.slice(0, 12).map(r => {
const kidName = students.find(s => s.id === r.student_id)?.name || '';
return `<div class="dash-schedule-item${r.done ? ' done' : ''}">
<span class="sch-dot"></span>
<span>${r.title}</span>
<span class="dash-schedule-who">${kidName}</span>
</div>`;
}).join('') : '<p style="color:var(--muted);font-size:.82rem">No schedule for today.</p>';
const scores = recentScores.scores || recentScores || [];
scoresEl.innerHTML = scores.length ? scores.slice(0, 8).map(sc => {
const pct = sc.total > 0 ? Math.round(sc.score / sc.total * 100) : null;
const cls = pct === null ? '' : pct >= 80 ? '' : pct >= 60 ? ' mid' : ' low';
const kidName = students.find(s => s.id === sc.student_id)?.name || '';
return `<div class="dash-score-item">
<span>${sc.title}</span>
<span class="dash-score-who" style="font-size:.7rem;color:var(--muted);margin-left:.25rem">${kidName}</span>
<span class="dash-score-pct${cls}">${pct !== null ? pct+'%' : sc.score+' pts'}</span>
</div>`;
}).join('') : '<p style="color:var(--muted);font-size:.82rem">No scores yet.</p>';
} catch (e) {
kidGrid.innerHTML = '<p style="color:var(--muted)">Could not load dashboard data.</p>';
}
}
// ============================================================
// Kids
// ============================================================
@@ -1310,8 +1415,8 @@ $('#planner-student').addEventListener('change', () => {
});
$('#planner-view-week').addEventListener('click', () => {
plannerMode = 'week';
$('#planner-view-week').classList.add('active-view');
$('#planner-view-month').classList.remove('active-view');
$('#planner-view-week').classList.add('active');
$('#planner-view-month').classList.remove('active');
$('#planner-copy').hidden = false;
renderPlanner();
});
@@ -1321,8 +1426,8 @@ $('#planner-view-month').addEventListener('click', () => {
const ref = new Date(plannerWeekStart + 'T00:00:00');
plannerMonthRef = `${ref.getFullYear()}-${String(ref.getMonth() + 1).padStart(2, '0')}-01`;
plannerWeekStart = firstWeekStartOfMonth(plannerMonthRef);
$('#planner-view-month').classList.add('active-view');
$('#planner-view-week').classList.remove('active-view');
$('#planner-view-month').classList.add('active');
$('#planner-view-week').classList.remove('active');
$('#planner-copy').hidden = true;
renderPlanner();
});
@@ -1455,26 +1560,53 @@ function renderDayCell(day, tasks, compact = false, spellingTests = [], today =
const dayTasks = tasks.filter((t) => t.date === day.date);
const dayTests = spellingTests.filter((t) => t.date === day.date);
const isToday = day.date === today;
const isPast = day.date < today;
const doneCount = dayTasks.filter(t => t.done).length;
const total = dayTasks.length + dayTests.length;
const testBadges = dayTests.map((t) => {
const pct = Math.round((t.score / t.total) * 100);
return `<div class="planner-task planner-test-badge" title="${esc(t.list)}">⭐ Spelling ${t.score}/${t.total} (${pct}%)</div>`;
}).join('');
const taskHtml = dayTasks.map((t) => {
const colorStyle = t.courseColor ? ` style="border-left:3px solid ${esc(t.courseColor)}"` : '';
return `<div class="planner-task${t.done ? ' done' : ''}" draggable="true" data-task-id="${t.id}"${colorStyle}>
<button class="planner-done-btn${t.done ? ' is-done' : ''}" data-done-schedule="${t.id}" data-is-done="${t.done ? '1' : '0'}" title="${t.done ? 'Mark not done' : 'Mark done'}">✓</button>
<span>${t.itemId ? TYPE_ICON[t.type] : '📌'} ${esc(t.itemTitle || t.offlineTitle)}</span>
<button class="danger tiny" data-del-schedule="${t.id}">✕</button>
const cls = pct >= 80 ? 'good' : pct >= 60 ? 'mid' : 'bad';
return `<div class="planner-task planner-test-badge">
<span class="task-icon">✏️</span>
<span class="task-title">Spelling test</span>
<span class="task-score ${cls}">${pct}%</span>
</div>`;
}).join('');
const fmtDate = (d) => { const dt = new Date(d + 'T00:00:00'); return dt.toLocaleString('default', { month: 'short', day: 'numeric' }); };
return `<div class="planner-day${compact ? ' planner-day-compact' : ''}${isToday ? ' today' : ''}" data-drop-date="${day.date}">
<h3>${compact ? day.name.slice(0,3) : day.name}<small>${fmtDate(day.date)}</small></h3>
<div class="planner-tasks" data-drop-date="${day.date}">
${testBadges}
${taskHtml || (!testBadges ? `<p class="hint tiny">—</p>` : '')}
const taskHtml = dayTasks.map((t) => {
const border = t.courseColor ? `border-left-color:${esc(t.courseColor)}` : '';
const courseName = t.courseName ? `<span class="task-course">${esc(t.courseName)}</span>` : '';
return `<div class="planner-task${t.done ? ' done' : ''}" draggable="true" data-task-id="${t.id}" style="${border}">
<button class="planner-done-btn${t.done ? ' is-done' : ''}" data-done-schedule="${t.id}" data-is-done="${t.done ? '1' : '0'}" title="${t.done ? 'Undo' : 'Mark done'}">✓</button>
<div class="task-body">
<span class="task-title">${t.itemId ? TYPE_ICON[t.type] || '' : '📌'} ${esc(t.itemTitle || t.offlineTitle)}</span>
${courseName}
</div>
<button class="secondary small" data-add-task="${day.date}">+ Add</button>
<button class="planner-del-btn" data-del-schedule="${t.id}" title="Remove">✕</button>
</div>`;
}).join('');
const progress = total > 0
? `<span class="day-progress${doneCount === total ? ' all-done' : ''}">${doneCount}/${total}</span>`
: '';
const emptyState = !taskHtml && !testBadges
? `<button class="planner-empty-add" data-add-task="${day.date}">+ Add task</button>`
: '';
const fmtDate = (d) => { const dt = new Date(d + 'T00:00:00'); return dt.toLocaleString('default', { month: 'short', day: 'numeric' }); };
return `<div class="planner-day${compact ? ' planner-day-compact' : ''}${isToday ? ' is-today' : ''}${isPast && !compact ? ' is-past' : ''}" data-drop-date="${day.date}">
<div class="planner-day-header">
<div class="day-label">
<span class="day-name">${compact ? day.name.slice(0,3) : day.name}</span>
<span class="day-date">${fmtDate(day.date)}</span>
</div>
${progress}
</div>
<div class="planner-tasks" data-drop-date="${day.date}">
${testBadges}${taskHtml}${emptyState}
</div>
${taskHtml || testBadges ? `<button class="planner-add-more" data-add-task="${day.date}">+ Add</button>` : ''}
</div>`;
}
+391 -68
View File
@@ -543,16 +543,21 @@ button.danger:hover { background: #b91c1c !important; }
/* ============================================================ GRADEBOOK RESULTS */
.results-student { margin-bottom: 1.25rem; }
.results-student h3 { margin-bottom: .4rem; font-size: 1rem; }
.results-student { margin-bottom: 1.5rem; }
.results-student h3 { margin-bottom: .5rem; font-size: 1rem; font-weight: 700; }
table.results {
width: 100%; border-collapse: collapse; background: var(--card);
border-radius: var(--radius); overflow: hidden; font-size: .9rem;
border: 1.5px solid var(--border);
border-radius: var(--radius); overflow: hidden; font-size: .88rem;
border: 1.5px solid var(--border); box-shadow: var(--shadow-xs);
}
table.results th, table.results td { padding: .6rem .9rem; text-align: left; }
table.results th {
background: #eef2ff; font-weight: 700;
font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: #4f46e5;
border-bottom: 1.5px solid var(--border);
}
table.results th, table.results td { padding: .55rem .85rem; text-align: left; }
table.results th { background: var(--card-2); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.results tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
table.results tr:hover td { background: #fafbff; }
.score-good { color: var(--good); font-weight: 700; }
.score-bad { color: var(--bad); font-weight: 700; }
@@ -570,14 +575,16 @@ table.results tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.nav-pill {
font-family: var(--font-kid);
font-size: .95rem; font-weight: 700;
background: rgba(255,255,255,.1); color: rgba(255,255,255,.6);
border: 1.5px solid rgba(255,255,255,.18);
background: rgba(0,0,0,.05); color: var(--ink-2);
border: 1.5px solid var(--border);
border-radius: 999px; padding: .45rem 1.1rem; cursor: pointer;
transition: background .15s, color .15s, border-color .15s;
}
.nav-pill:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.nav-pill.active {
background: var(--accent); color: #fff; border-color: var(--accent);
}
.nav-pill.active:hover { background: var(--accent-dark); }
.tab-panel { text-align: left; }
@keyframes tab-slide-right { from { transform: translateX(48px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@@ -801,43 +808,217 @@ table.results tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
/* ============================================================ ADMIN CONSOLE */
.admin-header {
display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
background: var(--card);
padding: .5rem 1.5rem;
min-height: 52px;
border-bottom: 1.5px solid var(--border);
position: sticky; top: 0; z-index: 50;
row-gap: .25rem;
/* ─── ADMIN SIDEBAR LAYOUT ─────────────────────────────────── */
#console { display: flex; height: 100vh; overflow: hidden; background: var(--bg); }
.admin-sidebar {
width: 224px;
min-width: 224px;
background: #111827;
display: flex;
flex-direction: column;
height: 100vh;
position: sticky;
top: 0;
overflow-y: auto;
z-index: 40;
flex-shrink: 0;
}
.admin-logo {
font-size: 1.1rem; font-weight: 800; color: var(--ink);
text-decoration: none; letter-spacing: -.01em;
display: flex; align-items: center; gap: .5rem;
display: flex; align-items: center; gap: .65rem;
padding: 1.4rem 1.25rem 1rem;
text-decoration: none;
color: #fff;
font-size: .95rem; font-weight: 800; letter-spacing: -.01em;
border-bottom: 1px solid rgba(255,255,255,.07);
margin-bottom: .5rem;
}
.admin-logo::before { content: '🏫'; font-size: 1.3rem; }
.admin-logo-icon { font-size: 1.4rem; line-height: 1; }
.admin-nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.admin-nav button,
.nav-pill {
font-family: inherit; font-size: .82rem; font-weight: 600;
background: transparent; color: var(--muted);
border: none; border-radius: 8px;
padding: .45rem .9rem; cursor: pointer;
transition: background .15s, color .15s;
.admin-nav {
display: flex; flex-direction: column; gap: 2px;
padding: 0 .75rem;
flex: 1;
}
.admin-nav button:hover,
.nav-pill:hover { background: var(--accent-light); color: var(--accent-dark); }
.admin-nav button.active,
.nav-pill.active { background: var(--accent-light); color: var(--accent); font-weight: 700; }
.admin-main { max-width: 1400px; margin: 0 auto; padding: 1.75rem 1.5rem 5rem; }
.admin-main h1 { margin-bottom: 1rem; clear: both; font-size: 1.4rem; font-weight: 800; }
.admin-main h2 { margin: 1.5rem 0 .5rem; font-size: 1rem; font-weight: 700; color: var(--ink-2); }
.nav-section-label {
font-size: .65rem; font-weight: 700; letter-spacing: .1em;
text-transform: uppercase; color: rgba(255,255,255,.3);
padding: 1.1rem .5rem .3rem;
}
.admin-nav .nav-pill,
.admin-sidebar-footer .nav-pill {
display: flex; align-items: center; gap: .65rem;
font-family: inherit; font-size: .85rem; font-weight: 500;
background: transparent; color: rgba(255,255,255,.55);
border: none; border-radius: 9px;
padding: .6rem .75rem; cursor: pointer; text-align: left;
width: 100%;
transition: background .12s, color .12s;
}
.nav-icon { font-size: 1rem; line-height: 1; flex-shrink: 0; }
.admin-nav .nav-pill:hover,
.admin-sidebar-footer .nav-pill:hover { background: rgba(255,255,255,.07); color: rgba(255,255,255,.9); }
.admin-nav .nav-pill.active {
background: var(--accent);
color: #fff; font-weight: 700;
box-shadow: 0 2px 10px rgba(79,126,248,.35);
}
.admin-nav .nav-pill.grading-pending { background: var(--bad) !important; color: #fff !important; }
.admin-sidebar-footer {
padding: .75rem .75rem 1rem;
border-top: 1px solid rgba(255,255,255,.07);
margin-top: auto;
}
.admin-sidebar-footer .nav-pill { color: rgba(255,255,255,.45); }
/* top bar */
.admin-body {
flex: 1; display: flex; flex-direction: column;
overflow-y: auto; min-width: 0;
}
.admin-topbar {
display: flex; align-items: center; gap: .75rem;
padding: 0 1.75rem;
height: 56px; min-height: 56px;
background: var(--card);
border-bottom: 1px solid var(--border);
position: sticky; top: 0; z-index: 30;
box-shadow: var(--shadow-xs);
}
.sidebar-toggle {
display: none; background: none; border: none; cursor: pointer;
font-size: 1.2rem; color: var(--ink-2); padding: .25rem;
}
.admin-page-title {
font-size: 1rem; font-weight: 700; color: var(--ink);
flex: 1; margin: 0;
}
.admin-topbar-right { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.topbar-btn {
font-family: inherit; font-size: .78rem; font-weight: 600;
background: var(--card-2); color: var(--ink-2);
border: 1px solid var(--border); border-radius: 8px;
padding: .35rem .8rem; cursor: pointer; text-decoration: none;
transition: background .12s;
}
.topbar-btn:hover { background: var(--border); }
.topbar-lock { color: var(--muted); }
/* main content */
.admin-main { padding: 1.75rem 1.75rem 5rem; }
.admin-main h1 {
margin-bottom: 1.25rem; clear: both;
font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em;
color: var(--ink);
}
.admin-main h2 {
margin: 1.75rem 0 .6rem; font-size: .72rem; font-weight: 700;
color: var(--muted); text-transform: uppercase; letter-spacing: .09em;
}
.panel { text-align: left; }
/* ─── DASHBOARD PANEL ─────────────────────────────────────── */
.dash-greeting {
margin-bottom: 1.5rem;
}
.dash-greeting h1 {
font-size: 1.75rem; font-weight: 900; letter-spacing: -.03em;
margin: 0 0 .2rem; color: var(--ink);
}
.dash-greeting p {
margin: 0; color: var(--muted); font-size: .9rem;
}
.dash-kid-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
gap: 1rem;
margin-bottom: 1.75rem;
}
.dash-kid-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius-lg);
padding: 1.25rem 1.5rem;
box-shadow: var(--shadow-sm);
position: relative;
overflow: hidden;
}
.dash-kid-card::before {
content: '';
position: absolute; top: 0; left: 0; right: 0; height: 4px;
background: var(--kid-accent, var(--accent));
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dash-kid-top {
display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
}
.dash-kid-avatar { font-size: 2rem; line-height: 1; }
.dash-kid-name { font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.dash-kid-streak { font-size: .78rem; color: var(--gold); font-weight: 700; }
.dash-kid-stats {
display: grid; grid-template-columns: 1fr 1fr; gap: .6rem;
}
.dash-stat-box {
background: var(--card-2); border-radius: 10px; padding: .7rem .75rem;
text-align: center;
}
.dash-stat-num { font-size: 1.6rem; font-weight: 900; line-height: 1; color: var(--ink); }
.dash-stat-lbl { font-size: .68rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }
.dash-progress-bar {
margin-top: .85rem;
background: var(--border); border-radius: 99px; height: 7px; overflow: hidden;
}
.dash-progress-fill {
height: 100%; border-radius: 99px;
background: var(--kid-accent, var(--accent));
transition: width .4s ease;
}
.dash-bottom-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1.25rem;
}
.dash-col { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm); }
.dash-col-title { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .09em; margin: 0 0 .85rem; }
.dash-schedule-list { display: flex; flex-direction: column; gap: .4rem; }
.dash-schedule-item {
display: flex; align-items: center; gap: .6rem;
padding: .5rem .65rem; border-radius: 8px;
font-size: .82rem; color: var(--ink-2);
}
.dash-schedule-item.done { opacity: .45; text-decoration: line-through; }
.dash-schedule-item .sch-dot {
width: 8px; height: 8px; border-radius: 50%;
background: var(--border); flex-shrink: 0;
}
.dash-schedule-item.done .sch-dot { background: var(--good); }
.dash-schedule-who { font-size: .7rem; color: var(--muted); margin-left: auto; white-space: nowrap; }
.dash-score-list { display: flex; flex-direction: column; gap: .4rem; }
.dash-score-item {
display: flex; align-items: center; gap: .65rem;
padding: .5rem .65rem; border-radius: 8px;
font-size: .82rem; color: var(--ink-2);
}
.dash-score-item:hover { background: var(--card-2); }
.dash-score-pct {
margin-left: auto; font-weight: 800; font-size: .95rem;
color: var(--good);
white-space: nowrap;
}
.dash-score-pct.low { color: var(--bad); }
.dash-score-pct.mid { color: var(--gold); }
/* ============================================================ PARENT DASH CARD (student home) */
.parent-dash-card {
@@ -996,61 +1177,191 @@ button.tiny { font-size: .72rem !important; padding: .15rem .5rem !important; }
/* ============================================================ PLANNER */
.week-label { font-weight: 700; }
/* ── toolbar ── */
.planner-toolbar {
display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
gap: .6rem; margin-bottom: .75rem;
}
.planner-toolbar-left { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.planner-toolbar-right { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.planner-view-toggle {
display: flex; border: 1.5px solid var(--border); border-radius: 9px; overflow: hidden;
}
.view-toggle-btn {
font-family: inherit; font-size: .8rem; font-weight: 600;
background: transparent; color: var(--ink-2);
border: none; padding: .38rem .85rem; cursor: pointer;
transition: background .12s, color .12s;
}
.view-toggle-btn:hover { background: var(--card-2); }
.view-toggle-btn.active { background: var(--accent); color: #fff; }
.planner-nav-group { display: flex; align-items: center; gap: .35rem; }
.planner-nav-btn {
font-family: inherit; font-size: 1.2rem; font-weight: 700; line-height: 1;
background: var(--card); color: var(--ink-2);
border: 1.5px solid var(--border); border-radius: 8px;
width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center;
transition: border-color .12s, background .12s;
}
.planner-nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.week-label { font-size: .9rem; font-weight: 700; min-width: 130px; text-align: center; }
.planner-kid-select {
font-family: inherit; font-size: .85rem; font-weight: 600;
background: var(--card); border: 1.5px solid var(--border);
border-radius: 9px; padding: .35rem .7rem; cursor: pointer; color: var(--ink);
}
/* ── auto-schedule bar ── */
.planner-auto-bar {
display: flex; align-items: center; gap: .65rem; flex-wrap: wrap;
background: var(--card); border: 1.5px solid var(--border);
border-radius: var(--radius); padding: .65rem 1rem;
margin-bottom: 1rem; font-size: .82rem; color: var(--ink-2);
}
.planner-auto-label { font-weight: 700; color: var(--ink); white-space: nowrap; }
.planner-auto-bar select, .planner-auto-bar input[type="date"],
.planner-auto-bar input[type="number"] {
font-family: inherit; font-size: .82rem;
background: var(--card-2); border: 1.5px solid var(--border);
border-radius: 7px; padding: .3rem .5rem; color: var(--ink);
}
/* ── week grid ── */
.planner-grid {
display: grid; grid-template-columns: repeat(5, 1fr);
gap: .75rem; margin-top: 1rem;
gap: .75rem;
}
.planner-day {
background: var(--card); border-radius: var(--radius);
padding: .85rem; border: 1.5px solid var(--border);
min-height: 120px; display: flex; flex-direction: column;
border: 1.5px solid var(--border);
display: flex; flex-direction: column;
transition: border-color .15s;
}
.planner-day h3 { font-size: .9rem; margin-bottom: .5rem; font-weight: 700; }
.planner-day h3 small { display: block; font-weight: 400; color: var(--muted); }
.planner-day.is-today {
border-color: var(--accent);
box-shadow: 0 0 0 3px rgba(79,126,248,.12);
}
.planner-day.is-past { opacity: .75; }
.planner-grid.planner-month { display: block; }
.planner-month-header { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-bottom: 3px; }
.planner-month-header div { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); padding: .2rem 0; }
.planner-month-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-bottom: 3px; }
.planner-day-compact { border-radius: 8px; padding: .5rem; min-height: 60px; display: flex; flex-direction: column; background: var(--card); border: 1.5px solid var(--border); }
.planner-day-compact h3 { font-size: .72rem; margin-bottom: .3rem; }
.planner-day-compact .planner-task { font-size: .7rem; padding: .2rem .4rem; }
.planner-day-compact .planner-task span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90%; }
.planner-day-compact .secondary.small { font-size: .68rem; padding: .2rem .4rem; margin-top: .2rem; }
.planner-day-header {
display: flex; align-items: flex-start; justify-content: space-between;
padding: .65rem .75rem .5rem;
border-bottom: 1px solid var(--border);
}
.day-label { display: flex; flex-direction: column; gap: .05rem; }
.day-name {
font-size: .82rem; font-weight: 800; color: var(--ink);
text-transform: uppercase; letter-spacing: .04em;
}
.planner-day.is-today .day-name { color: var(--accent); }
.day-date { font-size: .72rem; color: var(--muted); font-weight: 500; }
.secondary.active-view { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
.day-progress {
font-size: .72rem; font-weight: 700; color: var(--muted);
background: var(--card-2); border-radius: 99px;
padding: .2rem .5rem; white-space: nowrap;
}
.day-progress.all-done { background: var(--good-bg); color: var(--good); }
.planner-tasks { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .5rem; min-height: 1.5rem; }
/* ── task cards ── */
.planner-tasks { display: flex; flex-direction: column; gap: .3rem; padding: .5rem .5rem 0; flex: 1; min-height: 48px; }
.planner-task {
display: flex; justify-content: space-between; align-items: center; gap: .4rem;
background: var(--accent-light); border-radius: 6px; padding: .4rem .6rem; font-size: .8rem;
border: 1px solid rgba(79,126,248,.15);
display: flex; align-items: flex-start; gap: .4rem;
background: var(--card-2); border-radius: 8px; padding: .45rem .5rem;
border: 1px solid var(--border);
border-left: 3px solid var(--border);
font-size: .78rem; position: relative;
}
.planner-task.done { opacity: .5; text-decoration: line-through; }
.planner-task.done { opacity: .5; }
.planner-task.done .task-title { text-decoration: line-through; }
.planner-task[draggable] { cursor: grab; }
.planner-task[draggable]:active { cursor: grabbing; }
.planner-task.dragging { opacity: .3; }
.planner-task.dragging { opacity: .25; }
.planner-task.insert-before { border-top: 2px solid var(--accent); }
.planner-done-btn {
flex-shrink: 0; width: 18px; height: 18px; padding: 0;
flex-shrink: 0; width: 18px; height: 18px; padding: 0; margin-top: 1px;
border: 1.5px solid var(--border-hover); border-radius: 4px;
background: transparent; color: transparent; font-size: .7rem; cursor: pointer;
background: transparent; color: transparent; font-size: .68rem; cursor: pointer;
display: flex; align-items: center; justify-content: center;
transition: border-color .15s, color .15s, background .15s;
transition: border-color .12s, color .12s, background .12s;
}
.planner-done-btn:hover { border-color: var(--good); color: var(--good); }
.planner-done-btn.is-done { border-color: var(--good); color: var(--good); background: var(--good-bg); }
.planner-day.today { outline: 2px solid var(--accent); outline-offset: 2px; }
.planner-day.today > h3 { color: var(--accent); }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.task-title { font-weight: 600; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
.task-course { font-size: .68rem; color: var(--muted); font-weight: 500; }
.task-score { font-size: .7rem; font-weight: 700; }
.task-score.good { color: var(--good); }
.task-score.mid { color: var(--gold); }
.task-score.bad { color: var(--bad); }
.planner-del-btn {
flex-shrink: 0; background: none; border: none; cursor: pointer;
color: var(--muted); font-size: .7rem; padding: .1rem .2rem; border-radius: 4px;
opacity: 0; transition: opacity .12s, color .12s;
}
.planner-task:hover .planner-del-btn { opacity: 1; }
.planner-del-btn:hover { color: var(--bad); }
.planner-test-badge {
background: var(--accent-light); border-left: 3px solid var(--accent);
font-size: .75rem; cursor: default; pointer-events: none;
background: var(--gold-bg); border-left-color: var(--gold) !important;
cursor: default; pointer-events: none;
}
.planner-tasks.drop-target {
background: rgba(79,126,248,.08);
border-radius: 8px; outline: 2px dashed var(--accent);
background: rgba(79,126,248,.06); border-radius: 8px;
outline: 2px dashed var(--accent); outline-offset: -2px;
}
/* empty state + add buttons */
.planner-empty-add {
width: 100%; background: none; border: 1.5px dashed var(--border);
border-radius: 8px; color: var(--muted); font-size: .8rem; font-weight: 600;
padding: .6rem; cursor: pointer; text-align: center; font-family: inherit;
transition: border-color .12s, color .12s;
}
.planner-empty-add:hover { border-color: var(--accent); color: var(--accent); }
.planner-add-more {
background: none; border: none; color: var(--muted); font-size: .75rem;
font-weight: 600; cursor: pointer; padding: .4rem .75rem; width: 100%;
text-align: left; font-family: inherit; border-top: 1px solid var(--border);
transition: color .12s, background .12s;
}
.planner-add-more:hover { color: var(--accent); background: var(--accent-light); }
/* ── month grid ── */
.planner-grid.planner-month { display: block; }
.planner-month-header {
display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-bottom: 3px;
}
.planner-month-header div {
text-align: center; font-size: .7rem; font-weight: 800; color: var(--muted);
text-transform: uppercase; letter-spacing: .06em; padding: .3rem 0;
}
.planner-month-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; margin-bottom: 3px; }
.planner-day-compact {
border-radius: 8px; min-height: 72px; display: flex; flex-direction: column;
background: var(--card); border: 1.5px solid var(--border);
}
.planner-day-compact .planner-day-header {
padding: .35rem .45rem .3rem; border-bottom: none;
}
.planner-day-compact .day-name { font-size: .68rem; }
.planner-day-compact .day-date { font-size: .63rem; }
.planner-day-compact .planner-tasks { padding: .2rem .35rem 0; gap: .2rem; }
.planner-day-compact .planner-task { font-size: .65rem; padding: .2rem .35rem; }
.planner-day-compact .planner-task .task-course { display: none; }
.planner-day-compact .planner-del-btn { display: none; }
.planner-day-compact .planner-done-btn { width: 14px; height: 14px; font-size: .6rem; }
.planner-day-compact .planner-add-more,
.planner-day-compact .planner-empty-add { font-size: .65rem; padding: .25rem .35rem; }
.planner-day-compact.is-today { border-color: var(--accent); }
.add-task-form { display: flex; flex-direction: column; gap: .4rem; margin-top: .5rem; }
.add-task-form select, .add-task-form input {
font-size: .82rem; padding: .4rem; border: 1.5px solid var(--border);
@@ -1075,7 +1386,19 @@ button.tiny { font-size: .72rem !important; padding: .15rem .5rem !important; }
.spell-input { font-size: 1.6rem; }
.study-word { font-size: 2rem; }
.today-row .row-title { font-size: .93rem; }
.admin-header { padding: 0 1rem; gap: 1rem; }
.admin-main { padding: 1.25rem 1rem 4rem; }
}
@media (max-width: 768px) {
.admin-sidebar {
position: fixed; left: -224px; top: 0; bottom: 0;
transition: left .22s ease; z-index: 200;
}
.admin-sidebar.open { left: 0; }
.sidebar-toggle { display: block; }
.dash-bottom-row { grid-template-columns: 1fr; }
.dash-kid-grid { grid-template-columns: 1fr; }
.admin-topbar { padding: 0 1rem; }
.admin-main { padding: 1.25rem 1rem 4rem; }
}
+761
View File
@@ -0,0 +1,761 @@
/**
* Demo seed script — wipes all existing data and inserts realistic
* homeschool demo data for two kids (Emma & Liam).
*
* Run: node seed.js
*/
import { db } from './db.js';
/* ── helpers ──────────────────────────────────────────────── */
const today = () => new Date().toISOString().slice(0, 10);
const daysAgo = n => {
const d = new Date(); d.setDate(d.getDate() - n);
return d.toISOString().slice(0, 10);
};
const daysAhead = n => {
const d = new Date(); d.setDate(d.getDate() + n);
return d.toISOString().slice(0, 10);
};
const tsAgo = (days, hours = 10) => {
const d = new Date();
d.setDate(d.getDate() - days);
d.setHours(hours, 0, 0, 0);
return d.toISOString();
};
/* ── wipe ─────────────────────────────────────────────────── */
db.exec(`
DELETE FROM test_answers;
DELETE FROM tests;
DELETE FROM submission_history;
DELETE FROM submissions;
DELETE FROM schedule;
DELETE FROM progress;
DELETE FROM attempts;
DELETE FROM assignments;
DELETE FROM card_progress;
DELETE FROM cards;
DELETE FROM decks;
DELETE FROM words;
DELETE FROM lists;
DELETE FROM quiz_questions;
DELETE FROM items;
DELETE FROM units;
DELETE FROM enrollments;
DELETE FROM courses;
DELETE FROM students;
DELETE FROM messages;
`);
console.log('Wiped all tables.');
/* ════════════════════════════════════════════════════════════
STUDENTS
═════════════════════════════════════════════════════════════ */
const insertStudent = db.prepare(`
INSERT INTO students (id, name, emoji, created_at, theme, streak_count, best_streak, streak_date)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`);
insertStudent.run(1, 'Emma', '🦊', tsAgo(60), 'theme-purple', 5, 12, today());
insertStudent.run(2, 'Liam', '🐻', tsAgo(45), 'theme-teal', 3, 8, today());
console.log('Students created.');
/* ════════════════════════════════════════════════════════════
COURSES
═════════════════════════════════════════════════════════════ */
const insertCourse = db.prepare(`
INSERT INTO courses (id, name, subject, color, archived)
VALUES (?, ?, ?, ?, 0)
`);
insertCourse.run(1, 'Language Arts', 'English', '#7c3aed');
insertCourse.run(2, 'Mathematics', 'Math', '#0d9488');
insertCourse.run(3, 'Earth Science', 'Science', '#16a34a');
insertCourse.run(4, 'American History', 'History', '#ea580c');
insertCourse.run(5, 'Bible', 'Bible', '#d97706');
console.log('Courses created.');
/* ── enrollments ──────────────────────────────────────────── */
const enroll = db.prepare('INSERT INTO enrollments (student_id, course_id) VALUES (?, ?)');
// Emma takes all 5; Liam takes 4 (no Bible)
[1,2,3,4,5].forEach(c => enroll.run(1, c));
[1,2,3,4].forEach(c => enroll.run(2, c));
/* ════════════════════════════════════════════════════════════
UNITS + ITEMS
═════════════════════════════════════════════════════════════ */
const insertUnit = db.prepare(`INSERT INTO units (id, course_id, name, sort) VALUES (?, ?, ?, ?)`);
const insertItem = db.prepare(`
INSERT INTO items (id, unit_id, type, title, body, points, ref_id, sort, due_date, allow_retakes, evidence_mode)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`);
const insertQ = db.prepare(`
INSERT INTO quiz_questions (id, item_id, type, prompt, choices, correct_answer, points, sort)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`);
let unitId = 1, itemId = 1, qId = 1;
/* ─── Language Arts ────────────────────────────────────────
Unit 1: Grammar Foundations
Unit 2: Creative Writing */
insertUnit.run(unitId, 1, 'Grammar Foundations', 1);
const laUnit1 = unitId++;
// Lesson: Parts of Speech
insertItem.run(itemId, laUnit1, 'lesson', 'Parts of Speech', `
<h2>What are Parts of Speech?</h2>
<p>Every word in English belongs to a <strong>part of speech</strong> — a category that describes how the word works in a sentence.</p>
<h3>The 8 Parts of Speech</h3>
<ul>
<li><strong>Noun</strong> — names a person, place, thing, or idea. <em>Example: dog, school, happiness</em></li>
<li><strong>Pronoun</strong> — replaces a noun. <em>Example: he, she, they, it</em></li>
<li><strong>Verb</strong> — shows action or state of being. <em>Example: run, is, think</em></li>
<li><strong>Adjective</strong> — describes a noun. <em>Example: blue, tall, three</em></li>
<li><strong>Adverb</strong> — describes a verb, adjective, or another adverb. <em>Example: quickly, very, well</em></li>
<li><strong>Preposition</strong> — shows relationship. <em>Example: in, on, under, beside</em></li>
<li><strong>Conjunction</strong> — joins words or phrases. <em>Example: and, but, or, because</em></li>
<li><strong>Interjection</strong> — expresses emotion. <em>Example: Wow! Oh! Ouch!</em></li>
</ul>
<p>Learning parts of speech helps you understand how sentences are built and makes you a stronger reader and writer.</p>
`, 0, null, 1, daysAgo(14), 0, 'none');
const lessonPos = itemId++;
// Quiz: Parts of Speech
insertItem.run(itemId, laUnit1, 'quiz', 'Parts of Speech Quiz', null, 20, null, 2, daysAgo(10), 1, 'none');
const quizPos = itemId++;
insertQ.run(qId++, quizPos, 'mc', 'Which word is a NOUN?', JSON.stringify(['quickly','beautiful','mountain','runs']), 'mountain', 5, 1);
insertQ.run(qId++, quizPos, 'mc', 'Which word is a VERB?', JSON.stringify(['slowly','purple','jump','the']), 'jump', 5, 2);
insertQ.run(qId++, quizPos, 'mc', 'Which word is an ADJECTIVE?', JSON.stringify(['gracefully','enormous','laugh','because']), 'enormous', 5, 3);
insertQ.run(qId++, quizPos, 'sa', 'Write a sentence using a preposition.', null, null, 5, 4);
// Lesson: Sentence Structure
insertItem.run(itemId, laUnit1, 'lesson', 'Sentence Structure', `
<h2>Building Strong Sentences</h2>
<p>Every complete sentence needs two things: a <strong>subject</strong> (who or what the sentence is about) and a <strong>predicate</strong> (what the subject does or is).</p>
<h3>Simple Sentences</h3>
<p>A simple sentence has one independent clause: <em>The dog barked.</em></p>
<h3>Compound Sentences</h3>
<p>Two independent clauses joined by a conjunction: <em>The dog barked, and the cat hid.</em></p>
<h3>Complex Sentences</h3>
<p>One independent clause + one dependent clause: <em>Because it was raining, we stayed inside.</em></p>
<p>Using a variety of sentence types makes your writing more interesting to read!</p>
`, 0, null, 3, daysAgo(7), 0, 'none');
itemId++;
insertUnit.run(unitId, 1, 'Creative Writing', 2);
const laUnit2 = unitId++;
insertItem.run(itemId, laUnit2, 'lesson', 'The Writing Process', `
<h2>Five Steps to Great Writing</h2>
<ol>
<li><strong>Prewrite</strong> — Brainstorm ideas. Use a web, list, or outline.</li>
<li><strong>Draft</strong> — Write your ideas without worrying about perfection.</li>
<li><strong>Revise</strong> — Improve your ideas. Add details, rearrange, clarify.</li>
<li><strong>Edit</strong> — Fix spelling, grammar, and punctuation.</li>
<li><strong>Publish</strong> — Share your finished work!</li>
</ol>
<p>Good writers don't write perfectly the first time — they revise and improve!</p>
`, 0, null, 1, daysAgo(4), 0, 'none');
itemId++;
insertItem.run(itemId, laUnit2, 'assignment', 'Descriptive Paragraph', `
Write a descriptive paragraph (at least 5 sentences) about your favorite place.
Use vivid adjectives and at least two different sentence types (simple, compound, or complex).
Remember to:
- Start with a topic sentence
- Include sensory details (what you see, hear, smell, feel)
- End with a concluding sentence
`, 25, null, 2, daysAhead(3), 0, 'none');
itemId++;
/* ─── Mathematics ──────────────────────────────────────────
Unit 1: Fractions
Unit 2: Geometry */
insertUnit.run(unitId, 2, 'Fractions & Decimals', 1);
const mathUnit1 = unitId++;
insertItem.run(itemId, mathUnit1, 'lesson', 'Understanding Fractions', `
<h2>What Is a Fraction?</h2>
<p>A fraction represents a <strong>part of a whole</strong>. It has two parts:</p>
<ul>
<li><strong>Numerator</strong> — the top number (how many parts you have)</li>
<li><strong>Denominator</strong> — the bottom number (how many equal parts the whole is divided into)</li>
</ul>
<h3>Equivalent Fractions</h3>
<p>Fractions that name the same amount are called <strong>equivalent fractions</strong>.</p>
<p>Example: 1/2 = 2/4 = 4/8</p>
<h3>Simplifying Fractions</h3>
<p>Divide the numerator and denominator by their <strong>greatest common factor (GCF)</strong>.</p>
<p>Example: 8/12 → GCF is 4 → 2/3</p>
`, 0, null, 1, daysAgo(21), 0, 'none');
itemId++;
insertItem.run(itemId, mathUnit1, 'quiz', 'Fractions Quiz', null, 30, null, 2, daysAgo(14), 1, 'none');
const quizFrac = itemId++;
insertQ.run(qId++, quizFrac, 'mc', 'What is the simplified form of 6/9?', JSON.stringify(['1/3','2/3','3/4','6/9']), '2/3', 10, 1);
insertQ.run(qId++, quizFrac, 'mc', 'Which fraction is equivalent to 1/2?', JSON.stringify(['2/3','3/4','4/8','5/9']), '4/8', 10, 2);
insertQ.run(qId++, quizFrac, 'sa', 'Write two fractions that are equivalent to 3/4.', null, null, 10, 3);
insertItem.run(itemId, mathUnit1, 'lesson', 'Adding & Subtracting Fractions', `
<h2>Same Denominator</h2>
<p>When denominators are the same, just add or subtract the numerators:</p>
<p>3/8 + 2/8 = 5/8</p>
<h2>Different Denominators</h2>
<p>Find the <strong>Least Common Denominator (LCD)</strong>, convert, then add:</p>
<p>1/3 + 1/4 → LCD = 12 → 4/12 + 3/12 = 7/12</p>
`, 0, null, 3, daysAgo(7), 0, 'none');
itemId++;
insertItem.run(itemId, mathUnit1, 'assignment', 'Fractions Worksheet', `
Solve these fraction problems. Show your work!
1. 2/5 + 1/5 =
2. 3/4 - 1/4 =
3. 1/3 + 1/2 =
4. 5/6 - 1/3 =
5. Simplify 10/15
6. Simplify 9/12
7. Are 2/3 and 8/12 equivalent? Explain why.
`, 20, null, 4, daysAhead(1), 1, 'none');
itemId++;
insertUnit.run(unitId, 2, 'Geometry', 2);
const mathUnit2 = unitId++;
insertItem.run(itemId, mathUnit2, 'lesson', 'Polygons & Angles', `
<h2>What Is a Polygon?</h2>
<p>A <strong>polygon</strong> is a closed shape made of straight line segments.</p>
<h3>Common Polygons</h3>
<ul>
<li>Triangle — 3 sides, angles sum to 180°</li>
<li>Quadrilateral — 4 sides, angles sum to 360°</li>
<li>Pentagon — 5 sides</li>
<li>Hexagon — 6 sides</li>
</ul>
<h3>Types of Angles</h3>
<ul>
<li><strong>Acute</strong> — less than 90°</li>
<li><strong>Right</strong> — exactly 90°</li>
<li><strong>Obtuse</strong> — between 90° and 180°</li>
<li><strong>Straight</strong> — exactly 180°</li>
</ul>
`, 0, null, 1, daysAhead(5), 0, 'none');
itemId++;
/* ─── Earth Science ─────────────────────────────────────────
Unit 1: The Water Cycle
Unit 2: Ecosystems */
insertUnit.run(unitId, 3, 'The Water Cycle', 1);
const sciUnit1 = unitId++;
insertItem.run(itemId, sciUnit1, 'lesson', 'Water Cycle Overview', `
<h2>Earth's Water Is Always Moving</h2>
<p>The <strong>water cycle</strong> (also called the hydrological cycle) describes the continuous movement of water through Earth's systems.</p>
<h3>The Four Main Stages</h3>
<ol>
<li><strong>Evaporation</strong> — Heat from the sun turns liquid water into water vapor, which rises into the atmosphere.</li>
<li><strong>Condensation</strong> — Water vapor cools and forms tiny droplets that make clouds and fog.</li>
<li><strong>Precipitation</strong> — Water falls from clouds as rain, snow, sleet, or hail.</li>
<li><strong>Collection</strong> — Water gathers in oceans, lakes, rivers, and groundwater, and the cycle begins again.</li>
</ol>
<p>The sun is the energy source that drives the water cycle!</p>
`, 0, null, 1, daysAgo(18), 0, 'none');
itemId++;
insertItem.run(itemId, sciUnit1, 'quiz', 'Water Cycle Quiz', null, 25, null, 2, daysAgo(12), 1, 'none');
const quizWater = itemId++;
insertQ.run(qId++, quizWater, 'mc', 'What is the process where liquid water becomes water vapor?', JSON.stringify(['Condensation','Precipitation','Evaporation','Collection']), 'Evaporation', 5, 1);
insertQ.run(qId++, quizWater, 'mc', 'What energy source drives the water cycle?', JSON.stringify(['The moon','Wind','The sun','Earth\'s core']), 'The sun', 5, 2);
insertQ.run(qId++, quizWater, 'mc', 'What is it called when water falls from clouds?', JSON.stringify(['Evaporation','Condensation','Collection','Precipitation']), 'Precipitation', 5, 3);
insertQ.run(qId++, quizWater, 'mc', 'Which of these is NOT a form of precipitation?', JSON.stringify(['Rain','Snow','Fog','Hail']), 'Fog', 5, 4);
insertQ.run(qId++, quizWater, 'sa', 'Explain in your own words what condensation is.', null, null, 5, 5);
insertItem.run(itemId, sciUnit1, 'assignment', 'Water Cycle Diagram', `
Draw and label a diagram of the water cycle. Your diagram must include:
- At least 4 labeled stages (evaporation, condensation, precipitation, collection)
- Arrows showing the direction of movement
- The sun as the energy source
- At least one body of water (ocean, lake, or river)
Take a photo of your completed diagram and submit it, or describe it in writing.
`, 30, null, 3, daysAhead(2), 0, 'photo');
itemId++;
insertUnit.run(unitId, 3, 'Ecosystems', 2);
const sciUnit2 = unitId++;
insertItem.run(itemId, sciUnit2, 'lesson', 'Food Chains & Food Webs', `
<h2>Energy in Ecosystems</h2>
<p>All living things need energy. In an ecosystem, energy flows from one organism to another through <strong>food chains</strong>.</p>
<h3>Producers</h3>
<p>Plants are <strong>producers</strong> — they make their own food using sunlight (photosynthesis).</p>
<h3>Consumers</h3>
<ul>
<li><strong>Primary consumers</strong> — eat plants (herbivores). Example: rabbits, deer, caterpillars</li>
<li><strong>Secondary consumers</strong> — eat primary consumers. Example: foxes, frogs, small birds</li>
<li><strong>Tertiary consumers</strong> — eat secondary consumers. Example: eagles, sharks, wolves</li>
</ul>
<h3>Decomposers</h3>
<p>Fungi and bacteria break down dead organisms and return nutrients to the soil.</p>
`, 0, null, 1, daysAhead(7), 0, 'none');
itemId++;
/* ─── American History ─────────────────────────────────────
Unit 1: Colonial America
Unit 2: American Revolution */
insertUnit.run(unitId, 4, 'Colonial America', 1);
const histUnit1 = unitId++;
insertItem.run(itemId, histUnit1, 'lesson', 'The 13 Original Colonies', `
<h2>Building a New World</h2>
<p>Between 1607 and 1733, thirteen English colonies were established along the eastern coast of North America.</p>
<h3>Three Regions</h3>
<h4>New England Colonies</h4>
<p>Massachusetts, Connecticut, Rhode Island, New Hampshire — Known for fishing, shipbuilding, and trade.</p>
<h4>Middle Colonies</h4>
<p>New York, New Jersey, Pennsylvania, Delaware — Known as the "breadbasket" for their grain farms.</p>
<h4>Southern Colonies</h4>
<p>Virginia, Maryland, North Carolina, South Carolina, Georgia — Known for tobacco, rice, and indigo plantations.</p>
<p>Life in the colonies was shaped by religion, the land, and relationships with Native Americans.</p>
`, 0, null, 1, daysAgo(25), 0, 'none');
itemId++;
insertItem.run(itemId, histUnit1, 'quiz', 'Colonial America Quiz', null, 20, null, 2, daysAgo(20), 1, 'none');
const quizColonial = itemId++;
insertQ.run(qId++, quizColonial, 'mc', 'Which region was known as the "breadbasket" colonies?', JSON.stringify(['New England','Middle Colonies','Southern Colonies','Western Territories']), 'Middle Colonies', 5, 1);
insertQ.run(qId++, quizColonial, 'mc', 'What was the first permanent English settlement in America?', JSON.stringify(['Plymouth','Boston','Jamestown','Philadelphia']), 'Jamestown', 5, 2);
insertQ.run(qId++, quizColonial, 'mc', 'How many original colonies were there?', JSON.stringify(['10','12','13','15']), '13', 5, 3);
insertQ.run(qId++, quizColonial, 'sa', 'Name two crops grown in the Southern Colonies.', null, null, 5, 4);
insertItem.run(itemId, histUnit1, 'lesson', 'Daily Life in the Colonies', `
<h2>Life in Colonial Times</h2>
<p>Colonial children had very different lives from kids today. Most families farmed and made things by hand.</p>
<h3>Education</h3>
<p>Children in New England attended <strong>dame schools</strong> taught by women in their homes. They learned to read using the <em>New England Primer</em>. Boys might go on to a Latin grammar school; girls usually stayed home to learn household skills.</p>
<h3>Work</h3>
<p>Children helped with farm chores, cooking, spinning, and candle-making from a young age.</p>
<h3>Religion</h3>
<p>Religion was central to colonial life. Many colonists came to America seeking religious freedom.</p>
`, 0, null, 3, daysAgo(15), 0, 'none');
itemId++;
insertUnit.run(unitId, 4, 'American Revolution', 2);
const histUnit2 = unitId++;
insertItem.run(itemId, histUnit2, 'lesson', 'Road to Revolution', `
<h2>Growing Tensions</h2>
<p>By the 1760s, colonists were frustrated with British rule. Several key events pushed them toward revolution.</p>
<h3>Taxation Without Representation</h3>
<p>Britain taxed the colonies — the <strong>Stamp Act (1765)</strong> and <strong>Townshend Acts (1767)</strong> — without giving them a voice in Parliament. Colonists protested "No taxation without representation!"</p>
<h3>Boston Massacre (1770)</h3>
<p>British soldiers fired into a crowd of colonists, killing five people. This event inflamed anti-British feelings.</p>
<h3>Boston Tea Party (1773)</h3>
<p>Colonists dumped 342 chests of British tea into Boston Harbor to protest the Tea Act. Britain responded with the Intolerable Acts.</p>
<p>These events pushed the colonies toward declaring independence.</p>
`, 0, null, 1, daysAhead(4), 0, 'none');
itemId++;
/* ─── Bible ────────────────────────────────────────────────
Unit 1: Old Testament Heroes */
insertUnit.run(unitId, 5, 'Old Testament Heroes', 1);
const bibleUnit1 = unitId++;
insertItem.run(itemId, bibleUnit1, 'lesson', 'Noah and the Ark', `
<h2>A Story of Faith and Obedience</h2>
<p>The story of Noah is found in <strong>Genesis 6–9</strong>.</p>
<h3>God's Instruction</h3>
<p>God saw that the world had become full of wickedness. He chose Noah — a righteous man — and instructed him to build an ark (a large wooden boat) to save his family and two of every kind of animal.</p>
<h3>Noah's Obedience</h3>
<p>Though it had never rained before (some scholars believe), Noah trusted God and obeyed. He built the ark exactly as God instructed.</p>
<h3>The Flood</h3>
<p>It rained for <strong>40 days and 40 nights</strong>. The floodwaters covered the earth for 150 days before receding.</p>
<h3>God's Promise</h3>
<p>After the flood, God placed a <strong>rainbow</strong> in the sky as a sign of His covenant — a promise never to flood the entire earth again.</p>
<blockquote>"I have set my rainbow in the clouds, and it will be the sign of the covenant between me and the earth." — Genesis 9:13</blockquote>
`, 0, null, 1, daysAgo(10), 0, 'none');
itemId++;
insertItem.run(itemId, bibleUnit1, 'quiz', 'Noah and the Ark Quiz', null, 15, null, 2, daysAgo(7), 1, 'none');
const quizNoah = itemId++;
insertQ.run(qId++, quizNoah, 'mc', 'Where is the story of Noah found in the Bible?', JSON.stringify(['Exodus','Matthew','Genesis','Psalms']), 'Genesis', 5, 1);
insertQ.run(qId++, quizNoah, 'mc', 'How many days and nights did it rain?', JSON.stringify(['7','20','40','100']), '40', 5, 2);
insertQ.run(qId++, quizNoah, 'sa', 'What did the rainbow represent after the flood?', null, null, 5, 3);
insertItem.run(itemId, bibleUnit1, 'lesson', 'David and Goliath', `
<h2>Courage and Faith</h2>
<p>Found in <strong>1 Samuel 17</strong>, the story of David and Goliath shows that with God, the smallest person can overcome great challenges.</p>
<h3>The Challenge</h3>
<p>Goliath was a Philistine warrior over 9 feet tall who taunted the Israelite army. No soldier was brave enough to fight him — except a young shepherd boy named <strong>David</strong>.</p>
<h3>David's Confidence</h3>
<p>David told King Saul that God had helped him protect his sheep from lions and bears, so God would help him defeat Goliath too.</p>
<h3>The Victory</h3>
<p>Armed with only his <strong>sling and five smooth stones</strong>, David ran toward Goliath, slung a stone, and struck the giant in the forehead. Goliath fell, and the Philistines fled.</p>
`, 0, null, 3, daysAhead(3), 0, 'none');
itemId++;
console.log('Courses, units, and items created.');
/* ════════════════════════════════════════════════════════════
SUBMISSIONS (completed work with scores)
═════════════════════════════════════════════════════════════ */
const insertSub = db.prepare(`
INSERT INTO submissions (id, student_id, item_id, status, score, points_possible, answers, completed_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`);
const insertSubHist = db.prepare(`
INSERT INTO submission_history (student_id, item_id, score, points_possible, answers, completed_at)
VALUES (?, ?, ?, ?, ?, ?)
`);
let subId = 1;
// Emma's completed work
// Parts of Speech lesson — done
insertSub.run(subId++, 1, lessonPos, 'done', null, 0, null, tsAgo(13));
// Parts of Speech Quiz — 15/20
const posAnswers = JSON.stringify({ 1: 'mountain', 2: 'jump', 3: 'enormous', 4: 'We went to the park in the morning.' });
insertSub.run(subId++, 1, quizPos, 'done', 15, 20, posAnswers, tsAgo(9));
insertSubHist.run(1, quizPos, 15, 20, posAnswers, tsAgo(9));
// Fractions Quiz — 25/30 (Emma)
const fracAnswers = JSON.stringify({ 1: '2/3', 2: '4/8', 3: '6/8 and 9/12' });
insertSub.run(subId++, 1, quizFrac, 'done', 25, 30, fracAnswers, tsAgo(13));
insertSubHist.run(1, quizFrac, 25, 30, fracAnswers, tsAgo(13));
// Water Cycle Quiz — 20/25 (Emma)
const waterAnswers = JSON.stringify({ 1: 'Evaporation', 2: 'The sun', 3: 'Precipitation', 4: 'Fog', 5: 'Condensation is when water vapor cools and turns back into liquid droplets.' });
insertSub.run(subId++, 1, quizWater, 'done', 20, 25, waterAnswers, tsAgo(11));
insertSubHist.run(1, quizWater, 20, 25, waterAnswers, tsAgo(11));
// Colonial America Quiz — 18/20 (Emma)
const colonialAnswers = JSON.stringify({ 1: 'Middle Colonies', 2: 'Jamestown', 3: '13', 4: 'Tobacco and rice' });
insertSub.run(subId++, 1, quizColonial, 'done', 18, 20, colonialAnswers, tsAgo(19));
insertSubHist.run(1, quizColonial, 18, 20, colonialAnswers, tsAgo(19));
// Noah quiz — 12/15 (Emma)
const noahAnswers = JSON.stringify({ 1: 'Genesis', 2: '40', 3: "The rainbow was God's promise never to flood the whole earth again." });
insertSub.run(subId++, 1, quizNoah, 'done', 12, 15, noahAnswers, tsAgo(6));
insertSubHist.run(1, quizNoah, 12, 15, noahAnswers, tsAgo(6));
// Liam's completed work
// Fractions Quiz — 20/30 (Liam, first attempt)
const fracAnswersLiam1 = JSON.stringify({ 1: '2/3', 2: '3/4', 3: '4/6 and 8/12' });
insertSub.run(subId++, 2, quizFrac, 'done', 20, 30, fracAnswersLiam1, tsAgo(15));
insertSubHist.run(2, quizFrac, 20, 30, fracAnswersLiam1, tsAgo(15));
// Liam retook — 27/30
const fracAnswersLiam2 = JSON.stringify({ 1: '2/3', 2: '4/8', 3: '6/8 and 9/12' });
insertSub.run(subId++, 2, quizFrac, 'done', 27, 30, fracAnswersLiam2, tsAgo(12));
insertSubHist.run(2, quizFrac, 27, 30, fracAnswersLiam2, tsAgo(12));
// Water Cycle — 22/25 (Liam)
const waterLiam = JSON.stringify({ 1: 'Evaporation', 2: 'The sun', 3: 'Precipitation', 4: 'Fog', 5: 'When warm air cools it turns into water droplets.' });
insertSub.run(subId++, 2, quizWater, 'done', 22, 25, waterLiam, tsAgo(10));
insertSubHist.run(2, quizWater, 22, 25, waterLiam, tsAgo(10));
// Colonial — 15/20 (Liam)
const colonialLiam = JSON.stringify({ 1: 'Middle Colonies', 2: 'Jamestown', 3: '13', 4: 'Tobacco and corn' });
insertSub.run(subId++, 2, quizColonial, 'done', 15, 20, colonialLiam, tsAgo(18));
insertSubHist.run(2, quizColonial, 15, 20, colonialLiam, tsAgo(18));
// Parts of Speech (Liam) — 16/20
const posLiam = JSON.stringify({ 1: 'mountain', 2: 'jump', 3: 'enormous', 4: 'I put the book on the table.' });
insertSub.run(subId++, 2, quizPos, 'done', 16, 20, posLiam, tsAgo(8));
insertSubHist.run(2, quizPos, 16, 20, posLiam, tsAgo(8));
console.log('Submissions created.');
/* ════════════════════════════════════════════════════════════
SPELLING LISTS
═════════════════════════════════════════════════════════════ */
const insertList = db.prepare('INSERT INTO lists (id, name, builtin, group_name) VALUES (?, ?, 0, ?)');
const insertWord = db.prepare('INSERT INTO words (id, list_id, word, sentence, definition) VALUES (?, ?, ?, ?, ?)');
let listId = 1, wordId = 1;
// List 1: 4th Grade Week 1
insertList.run(listId, '4th Grade — Week 1', 'Grade 4');
const list1 = listId++;
const week1words = [
['beautiful', 'The sunset was absolutely beautiful.', 'pleasing to the senses or mind'],
['necessary', 'It is necessary to drink water every day.', 'needed; essential'],
['separate', 'Please separate the red and blue blocks.', 'to set apart; to divide'],
['because', 'I stayed inside because it was raining.', 'for the reason that'],
['different', 'Each snowflake is different from every other.','not the same as another'],
['important', 'Exercise is important for staying healthy.', 'having great significance'],
['knowledge', 'Reading books builds your knowledge.', 'facts or skills acquired through learning'],
['surprise', 'The party was a complete surprise.', 'an unexpected event or feeling'],
['through', 'We walked through the park.', 'moving from one side to the other'],
['whether', 'I wasn\'t sure whether to go or stay.', 'expressing a doubt or choice'],
];
week1words.forEach(([w, s, d]) => insertWord.run(wordId++, list1, w, s, d));
// List 2: 4th Grade Week 2
insertList.run(listId, '4th Grade — Week 2', 'Grade 4');
const list2 = listId++;
const week2words = [
['character', 'The main character in the story was brave.', 'a person in a story; a person\'s qualities'],
['complete', 'Did you complete your homework?', 'having all necessary parts; to finish'],
['continue', 'We will continue reading tomorrow.', 'to keep going'],
['difficult', 'The math problem was very difficult.', 'not easy; hard to do'],
['environment', 'We should protect the natural environment.', 'the surroundings in which one lives'],
['frequently', 'She frequently visits her grandparents.', 'often; many times'],
['government', 'The government makes laws for the country.', 'the group that rules a nation'],
['language', 'English is a fascinating language.', 'a system of words used to communicate'],
['position', 'What position does he play on the team?', 'a place where someone or something is located'],
['remember', 'I will always remember that day.', 'to keep in mind; to recall'],
];
week2words.forEach(([w, s, d]) => insertWord.run(wordId++, list2, w, s, d));
// List 3: Science Vocabulary
insertList.run(listId, 'Science Vocabulary', 'Science');
const list3 = listId++;
const sciWords = [
['evaporation', 'Evaporation turns liquid water into vapor.', 'process of liquid changing to gas'],
['condensation', 'Condensation forms on a cold glass on a hot day.', 'process of gas changing to liquid'],
['precipitation','Precipitation includes rain, snow, and hail.', 'water falling from clouds'],
['ecosystem', 'A pond is a small ecosystem.', 'a community of living and nonliving things'],
['photosynthesis','Plants use photosynthesis to make food.', 'how plants make food using sunlight'],
['organism', 'Every living thing is an organism.', 'any living thing'],
['hypothesis', 'We formed a hypothesis before the experiment.', 'an educated guess to be tested'],
['atmosphere', 'The atmosphere protects Earth from the sun\'s rays.', 'the layer of gases around a planet'],
];
sciWords.forEach(([w, s, d]) => insertWord.run(wordId++, list3, w, s, d));
// List 4: Bible Memory Words
insertList.run(listId, 'Bible Memory Words', 'Bible');
const list4 = listId++;
const bibleWords = [
['covenant', 'God made a covenant with Noah.', 'a serious agreement or promise'],
['righteous', 'Noah was a righteous man.', 'morally right; following God\'s ways'],
['obedient', 'David was obedient to God\'s calling.', 'doing what you are told; compliant'],
['sacrifice', 'Abraham trusted God with the sacrifice.', 'giving something valuable for a purpose'],
['steadfast', 'Be steadfast in your faith.', 'firm and unwavering'],
['gracious', 'God is gracious and full of compassion.', 'showing grace; kind and merciful'],
];
bibleWords.forEach(([w, s, d]) => insertWord.run(wordId++, list4, w, s, d));
console.log('Spelling lists and words created.');
/* ── assignments (connect students to lists) ──────────────── */
const insertAssignment = db.prepare('INSERT INTO assignments (student_id, list_id, assigned_at) VALUES (?, ?, ?)');
insertAssignment.run(1, list1, tsAgo(14)); // Emma → Week 1
insertAssignment.run(1, list2, tsAgo(7)); // Emma → Week 2
insertAssignment.run(1, list3, tsAgo(18)); // Emma → Science
insertAssignment.run(1, list4, tsAgo(10)); // Emma → Bible
insertAssignment.run(2, list1, tsAgo(14)); // Liam → Week 1
insertAssignment.run(2, list2, tsAgo(7)); // Liam → Week 2
insertAssignment.run(2, list3, tsAgo(18)); // Liam → Science
/* ── spelling progress (Leitner boxes) ────────────────────── */
const insertProgress = db.prepare(`
INSERT INTO progress (student_id, word_id, box, due, attempts, correct)
VALUES (?, ?, ?, ?, ?, ?)
`);
// Emma has practiced all of Week 1 — most words are in boxes 3-5
const emmaWordIds = Array.from({length: 10}, (_, i) => i + 1); // words 1-10 are list1
const boxDist = [5,5,4,4,3,3,3,2,4,5];
emmaWordIds.forEach((wid, i) => {
const box = boxDist[i];
const due = box >= 4 ? daysAhead(7) : box === 3 ? daysAhead(2) : today();
insertProgress.run(1, wid, box, due, 4 + box, 3 + box);
});
// Emma — Week 2 words partially practiced (boxes 1-3)
const week2ids = Array.from({length: 10}, (_, i) => i + 11);
week2ids.forEach((wid, i) => {
const box = Math.min(3, 1 + Math.floor(i / 4));
insertProgress.run(1, wid, box, i < 5 ? today() : daysAhead(1), 1 + box, box);
});
// Liam — Week 1 partially (boxes 1-3)
emmaWordIds.forEach((wid, i) => {
const box = Math.min(3, 1 + Math.floor(i / 4));
insertProgress.run(2, wid, box, i < 4 ? today() : daysAhead(1), 1 + box, box);
});
/* ── spelling tests ───────────────────────────────────────── */
const insertTest = db.prepare('INSERT INTO tests (id, student_id, list_id, score, total, at) VALUES (?, ?, ?, ?, ?, ?)');
const insertTA = db.prepare('INSERT INTO test_answers (test_id, word_id, typed, correct) VALUES (?, ?, ?, ?)');
// Emma — 3 spelling tests
insertTest.run(1, 1, list1, 8, 10, tsAgo(12));
// test answers for test 1
emmaWordIds.slice(0, 10).forEach((wid, i) => {
const word = week1words[i][0];
const right = i < 8;
const typed = right ? word : (i === 8 ? 'thrugh' : 'wether');
insertTA.run(1, wid, typed, right ? 1 : 0);
});
insertTest.run(2, 1, list1, 10, 10, tsAgo(5));
emmaWordIds.slice(0, 10).forEach((wid, i) => {
insertTA.run(2, wid, week1words[i][0], 1);
});
insertTest.run(3, 1, list3, 7, 8, tsAgo(2));
Array.from({length: 8}, (_, i) => i + 21).forEach((wid, i) => {
const right = i < 7;
insertTA.run(3, wid, right ? sciWords[i][0] : 'atmosfere', right ? 1 : 0);
});
// Liam — 2 spelling tests
insertTest.run(4, 2, list1, 7, 10, tsAgo(11));
emmaWordIds.slice(0, 10).forEach((wid, i) => {
const right = i < 7;
const word = week1words[i][0];
insertTA.run(4, wid, right ? word : word.replace(/[aeiou]/, ''), right ? 1 : 0);
});
insertTest.run(5, 2, list1, 9, 10, tsAgo(4));
emmaWordIds.slice(0, 10).forEach((wid, i) => {
const right = i !== 4;
insertTA.run(5, wid, right ? week1words[i][0] : 'diffrent', right ? 1 : 0);
});
console.log('Spelling tests created.');
/* ════════════════════════════════════════════════════════════
FLASHCARD DECKS
═════════════════════════════════════════════════════════════ */
const insertDeck = db.prepare('INSERT INTO decks (id, name, builtin, group_name) VALUES (?, ?, 0, ?)');
const insertCard = db.prepare('INSERT INTO cards (id, deck_id, front, back) VALUES (?, ?, ?, ?)');
let deckId = 1, cardId = 1;
insertDeck.run(deckId, 'Math Facts — Multiplication', 'Math');
const deck1 = deckId++;
const multFacts = [
['6 × 7', '42'], ['6 × 8', '48'], ['7 × 7', '49'], ['7 × 8', '56'],
['8 × 8', '64'], ['8 × 9', '72'], ['9 × 7', '63'], ['9 × 9', '81'],
['6 × 9', '54'], ['7 × 9', '63'], ['4 × 8', '32'], ['5 × 7', '35'],
];
multFacts.forEach(([f, b]) => insertCard.run(cardId++, deck1, f, b));
insertDeck.run(deckId, 'US States & Capitals', 'Geography');
const deck2 = deckId++;
const states = [
['California', 'Sacramento'], ['Texas', 'Austin'], ['Florida', 'Tallahassee'],
['New York', 'Albany'], ['Pennsylvania', 'Harrisburg'], ['Ohio', 'Columbus'],
['Virginia', 'Richmond'], ['Georgia', 'Atlanta'], ['Michigan', 'Lansing'],
['Massachusetts', 'Boston'], ['Illinois', 'Springfield'], ['Arizona', 'Phoenix'],
];
states.forEach(([f, b]) => insertCard.run(cardId++, deck2, `Capital of ${f}`, b));
insertDeck.run(deckId, 'Science Vocabulary', 'Science');
const deck3 = deckId++;
sciWords.forEach(([w, , d]) => insertCard.run(cardId++, deck3, w, d));
insertDeck.run(deckId, 'Grammar Terms', 'English');
const deck4 = deckId++;
const grammarCards = [
['Noun', 'A word that names a person, place, thing, or idea'],
['Verb', 'A word that shows action or state of being'],
['Adjective', 'A word that describes a noun'],
['Adverb', 'A word that describes a verb, adjective, or another adverb'],
['Pronoun', 'A word that takes the place of a noun'],
['Preposition', 'A word that shows relationship (in, on, under, beside)'],
['Conjunction', 'A word that joins words or clauses (and, but, or, because)'],
['Subject', 'Who or what the sentence is about'],
['Predicate', 'What the subject does or is'],
['Independent clause', 'A group of words that can stand alone as a sentence'],
];
grammarCards.forEach(([f, b]) => insertCard.run(cardId++, deck4, f, b));
console.log('Flashcard decks created.');
/* ── card progress (Emma has practiced Math deck) ─────────── */
const insertCardProg = db.prepare(`
INSERT INTO card_progress (student_id, card_id, box, due, attempts, correct)
VALUES (?, ?, ?, ?, ?, ?)
`);
const mathCardIds = Array.from({length: 12}, (_, i) => i + 1);
const mathBoxes = [5,5,4,4,3,3,5,2,4,3,4,5];
mathCardIds.forEach((cid, i) => {
const box = mathBoxes[i];
const due = box >= 4 ? daysAhead(5) : box === 3 ? daysAhead(1) : today();
insertCardProg.run(1, cid, box, due, 3 + box, 2 + box);
});
/* ════════════════════════════════════════════════════════════
SCHEDULE (planner entries for this week)
═════════════════════════════════════════════════════════════ */
const insertSchedule = db.prepare(`
INSERT INTO schedule (student_id, date, item_id, title, done, sort, status)
VALUES (?, ?, ?, ?, ?, ?, 'pending')
`);
// Get day-of-week offsets so we land Mon–Fri
const getWeekday = (offset) => {
const d = new Date();
const day = d.getDay(); // 0=Sun
const monday = new Date(d);
monday.setDate(d.getDate() - (day === 0 ? 6 : day - 1));
monday.setDate(monday.getDate() + offset);
return monday.toISOString().slice(0, 10);
};
const mon = getWeekday(0), tue = getWeekday(1), wed = getWeekday(2),
thu = getWeekday(3), fri = getWeekday(4);
// Emma's schedule this week
insertSchedule.run(1, mon, null, 'Morning Bible reading — Genesis 7', 1, 1);
insertSchedule.run(1, mon, null, 'Spelling practice — Week 2 words', 0, 2);
insertSchedule.run(1, tue, null, 'Math: Adding Fractions worksheet', 0, 1);
insertSchedule.run(1, tue, null, 'History reading: Road to Revolution', 0, 2);
insertSchedule.run(1, wed, null, 'Science: Water Cycle review', 0, 1);
insertSchedule.run(1, wed, null, 'Language Arts: Descriptive paragraph draft', 0, 2);
insertSchedule.run(1, thu, null, 'Spelling test — Week 2', 0, 1);
insertSchedule.run(1, thu, null, 'Math: Geometry lesson', 0, 2);
insertSchedule.run(1, fri, null, 'Free reading (30 min)', 0, 1);
insertSchedule.run(1, fri, null, 'Review week — all subjects', 0, 2);
// Liam's schedule
insertSchedule.run(2, mon, null, 'Spelling practice — Week 2 words', 0, 1);
insertSchedule.run(2, mon, null, 'Math: Fractions review', 0, 2);
insertSchedule.run(2, tue, null, 'Science: Water Cycle notes', 0, 1);
insertSchedule.run(2, tue, null, 'Language Arts: Parts of Speech', 0, 2);
insertSchedule.run(2, wed, null, 'History: Colonial Life lesson', 0, 1);
insertSchedule.run(2, wed, null, 'Math: Geometry intro', 0, 2);
insertSchedule.run(2, thu, null, 'Spelling test — Week 2', 0, 1);
insertSchedule.run(2, fri, null, 'Free reading (30 min)', 0, 1);
console.log('Schedule created.');
/* ════════════════════════════════════════════════════════════
MESSAGES
═════════════════════════════════════════════════════════════ */
const insertMsg = db.prepare(`
INSERT INTO messages (student_id, sender, body, sent_at, read_at)
VALUES (?, ?, ?, ?, ?)
`);
insertMsg.run(1, 'parent', 'Great job on your spelling test, Emma! 10/10! 🎉', tsAgo(5), tsAgo(5));
insertMsg.run(1, 'student', 'Thanks! I practiced a lot. Can we do science experiments today?', tsAgo(5), tsAgo(5));
insertMsg.run(1, 'parent', 'I love that idea! Let\'s do the water cycle experiment after lunch.', tsAgo(5), tsAgo(5));
insertMsg.run(2, 'parent', 'Liam, remember to finish your fractions worksheet before dinner.', tsAgo(2), tsAgo(2));
insertMsg.run(2, 'student', 'Ok! I already did problems 1-4, just have 5-7 left.', tsAgo(2), null);
console.log('Messages created.');
/* ════════════════════════════════════════════════════════════
SETTINGS
═════════════════════════════════════════════════════════════ */
const upsertSetting = db.prepare('INSERT OR REPLACE INTO settings (key, value) VALUES (?, ?)');
upsertSetting.run('school_name', 'Emmert Academy');
upsertSetting.run('timezone', 'America/Chicago');
console.log('\n✅ Demo data seeded successfully!');
console.log(' Students: Emma (🦊) and Liam (🐻)');
console.log(' Courses: Language Arts, Math, Earth Science, American History, Bible');
console.log(' Spelling: 4 lists with 36 words total');
console.log(' Flashcards: 4 decks with', 12 + 12 + 8 + 10, 'cards');
console.log(' Quiz submissions with scores for both students');
console.log(' Weekly planner schedules');
+18
View File
@@ -829,6 +829,24 @@ app.post('/api/parent/pin', requirePin, (req, res) => {
res.json({ ok: true });
});
app.get('/api/admin/schedule', requirePin, (req, res) => {
const { date } = req.query;
const d = date || new Date().toISOString().slice(0, 10);
const rows = db.prepare(`SELECT * FROM schedule WHERE date = ? ORDER BY student_id, sort`).all(d);
res.json({ rows });
});
app.get('/api/admin/recent-scores', requirePin, (req, res) => {
const scores = db.prepare(`
SELECT s.id, s.student_id, i.title, s.score, s.total, s.submitted_at
FROM submissions s
JOIN items i ON i.id = s.item_id
ORDER BY s.submitted_at DESC
LIMIT 20
`).all();
res.json({ scores });
});
app.get('/api/admin/app-settings', requirePin, (req, res) => {
res.json({
school_name: getSetting('school_name') || '',