Skip to content

feat(notifications): persistent student notifications with per-student clear & email targeting - #68

Open
shaikzahoorahmed77-svg wants to merge 3 commits into
vicharanashala:mainfrom
shaikzahoorahmed77-svg:feat/student-notifications
Open

feat(notifications): persistent student notifications with per-student clear & email targeting#68
shaikzahoorahmed77-svg wants to merge 3 commits into
vicharanashala:mainfrom
shaikzahoorahmed77-svg:feat/student-notifications

Conversation

@shaikzahoorahmed77-svg

Copy link
Copy Markdown

Summary

This PR introduces persistent student notifications in MongoDB, real-time WebSocket distribution, per-student notification management (clearing), CSV target email filtering, and reliable notification bell ringing indicators across page navigation and reconnects.


Key Changes

Backend

  • Notification Model (backend/src/models/Notification.js): Created Mongoose model storing roomCode, announcement, target emails list, fileName, clearedBy (array of student User ObjectIds), and createdAt.
  • Notification API Routes (backend/src/routes/notifications.js):
    • GET /api/notifications: Fetches active, uncleared notifications matching the student's email or targeted to all.
    • POST /api/notifications/clear: Marks notifications as cleared strictly for the requesting student by appending their User ID to clearedBy.
  • WebSocket Socket Server (backend/src/index.js): Updated new_announcement handler to save the announcement to MongoDB (Notification.create) upon emission while keeping real-time socket broadcasting.

Frontend

  • Student Dashboard (frontend/src/pages/StudentDashboard.jsx):
    • Automatically fetches persistent uncleared notifications from MongoDB on mount/reload.
    • Updated "Clear all" and individual dismiss actions to update backend state so clearing is individual to each student.
    • Triggers the bell ringing animation whenever uncleared notifications exist.
  • Global Socket Store (frontend/src/stores/socketStore.js): Added a global new_announcement listener so students receive and record incoming notifications regardless of which page/route they are currently on.

Verification & Behavior

  • Target Email Filtering: Sockets and database queries verify student emails against uploaded CSV lists; non-targeted students will not see or receive specific announcements.
  • Per-Student Clear: Student A clearing their notifications adds Student A's ID to clearedBy without removing the notification for Student B.
  • Reliable Bell Indicator: The notification bell rings dynamically on the dashboard even if the student was offline or on another page when the announcement was created.

Zahoor Ahmed added 2 commits August 1, 2026 22:08
…port per-student clear and teacher can now announce code to join the room based on mails in csv file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant