LearnSpace: full-stack educational whiteboard platform
Node.js/Express backend + vanilla JS frontend. Features: real-time collaborative whiteboard (SSE), multi-page support, LaTeX formulas, shapes/connectors, coordinate systems, number lines, compass, zoom/pan, Catmull-Rom pencil smoothing, ruler/protractor with rotation & resize controls, minimap navigation overlay, auto-measurements, multi-page thumbnails sidebar, PNG export, page templates. Student/teacher workflows: classes, assignments, library, dashboard. Mobile responsive. SQLite (better-sqlite3). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const db = require('../db/db');
|
||||
const sse = require('../sse');
|
||||
|
||||
function pushNotif(user_id, type, message, link) {
|
||||
try {
|
||||
const { lastInsertRowid } = db.prepare(
|
||||
"INSERT INTO notifications (user_id, type, message, link) VALUES (?, ?, ?, ?)"
|
||||
).run(user_id, type, message, link || null);
|
||||
sse.emit(user_id, { id: lastInsertRowid, type, message, link: link || null });
|
||||
} catch (e) { console.error('[pushNotif]', e.message); }
|
||||
}
|
||||
|
||||
/* ── Notify all active parent links for a student ────────────────────── */
|
||||
function pushParentNotif(studentId, type, message) {
|
||||
try {
|
||||
const links = db.prepare(
|
||||
'SELECT id FROM parent_links WHERE student_id = ? AND is_active = 1'
|
||||
).all(studentId);
|
||||
const ins = db.prepare(
|
||||
'INSERT INTO parent_notifications (parent_link_id, type, message) VALUES (?, ?, ?)'
|
||||
);
|
||||
for (const link of links) ins.run(link.id, type, message);
|
||||
} catch (e) { console.error('[pushParentNotif]', e.message); }
|
||||
}
|
||||
|
||||
module.exports = { pushNotif, pushParentNotif };
|
||||
Reference in New Issue
Block a user