Amaresh taking over for Linh - Student Evaluation Results Backend APIs#2108
Open
linh2020 wants to merge 11 commits into
Open
Amaresh taking over for Linh - Student Evaluation Results Backend APIs#2108linh2020 wants to merge 11 commits into
linh2020 wants to merge 11 commits into
Conversation
- break down assignAtoms function to fix 165-line limit - add publishEvaluationResults endpoint to educator router - extend notification and userProfile models for evaluation tracking - add studentEvaluationResultsRouter to app routes - update package.json with seed script for evaluation data
|
|
added 3 commits
June 19, 2026 09:44
…, reduce cognitive complexity in userHelper
|
pixelpix13
approved these changes
Jun 22, 2026
pixelpix13
left a comment
There was a problem hiding this comment.
Reviewed and tested locally on branch linh_student_eval_clean against hgnData_dev using npm run dev on port 4500.
Unit Tests
studentEvaluationResultsController.spec.js— 5/5 passedstudentEvaluationResultsService.spec.js— 4/4 passed
Manual API Flow
Verified:
POST /api/educator/evaluation-results/publishreturns201, upserts categories/tasks, and creates anevaluation_resultsnotification.GET /api/student/evaluation-results/notificationsreturns correcthasNewResults/unreadCountvalues before and after viewing results.GET /api/student/evaluation-resultsreturns summary, categories, and task results with the expected weighted score82.8and submission stats.- Viewing results marks evaluation results as viewed.
- Re-publishing updates the data and re-triggers notifications.
Auth / Validation Checks
Verified:
401when no token is provided.403when a student attempts to publish results.400for invalid publish payload.404when noeducationProfiles.studentrecord exists.
What Looks Good
- Clear separation between models, service, controllers, and routes.
- Student endpoints are JWT-scoped and do not expose
studentIdin the URL. - Publish flow correctly resets
lastEvaluationResultsViewedAtand creates typed notifications. - Weighted score aggregation and on-time/late submission logic work as expected.
Minor Notes
- PR description mentions
educatorController.spec.js, but that file does not appear to be included in the diff. I only saw the student evaluation controller and service specs. - Service tests mainly cover ObjectId sanitization; scoring and notification behavior are covered through manual testing but could benefit from unit-level coverage.
educatorController.jshas a large diff, so it may be worth a quick sanity check to confirm existing educator routes were not affected.
No blocking issues found from my testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
This PR adds backend support for the Student Viewing Evaluation Results feature by implementing secure API endpoints for students to view their evaluation data and check for new results. It introduces reusable calculation logic for performance metrics, dynamic score aggregation, and notification tracking to enable students to access their academic progress seamlessly.
These APIs provide structured data for:
Overall evaluation summary (scores, performance levels, submission stats)
Category-wise breakdown of results
Detailed task-level results with submission status
Notification state for new/unread evaluation results
This work enables the frontend to consume consistent, server-side calculated evaluation insights instead of duplicating logic in the UI, ensuring secure access and real-time updates.
Implements:
(PHASE 4 - Backend Tasks-Student Viewing Evaluation Results)
Related PRs (if any):
Main Changes Explained
Main Changes Explained
• Added new models: Created studentEvaluation.js and evaluationTask.js for storing evaluation categories and task details, with proper schemas, indexes, and validation.
• Enhanced existing models: Updated notification.js to include type and metadata fields for evaluation-specific notifications, plus a new index for efficient querying. Modified userProfile.js to add lastEvaluationResultsViewedAt in the student education profile for tracking viewed timestamps.
• Added new service: Implemented studentEvaluationResultsService.js with reusable utilities for calculating performance colors, aggregating scores/stats (e.g., on-time/late submissions), validating students, and managing notifications.
• Updated routes: Modified educatorRouter.js to add the /evaluation-results/publish POST endpoint. Created studentEvaluationResultsRouter.js for the new GET endpoints (/student/evaluation-results and /student/evaluation-results/notifications). Registered the new router in startup/routes.js.
• Added testing and utilities: Included unit tests (educatorController.spec.js, studentEvaluationResultsController.spec.js, studentEvaluationResultsService.spec.js),
• Database logic: Ensured secure student identity validation, dynamic calculation of average scores and submission stats, and performance color mapping for visual indicators. On publishing, inserts/updates evaluation data and creates notification records.
How to Test
Check out this branch: linh_student_eval_clean
Run: npm install, npm run dev (or equivalent backend start command)
Clear site data/cache if needed.
Example checks:
• Publish Results (Educator): POST /api/educator/evaluation-results/publish → Returns 201 with published categories
• Get Evaluation Results (Student): GET /api/student/evaluation-results → Returns summary, categories, and task results
• Check Notifications (Student): GET /api/student/evaluation-results/notifications → Returns hasNewResults, unreadCount, etc.
Note: