Amaresh taking over for Linh - Student Evaluation Results Backend APIs - #2108
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
|
|
…, reduce cognitive complexity in userHelper
|
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.
AmaanSyed09
left a comment
There was a problem hiding this comment.
Reviewed and tested locally on the branch linh_student_eval_clean using npm run dev.
Verified:
- Backend started successfully without issues.
- GET /api/student/evaluation-results returns 200 OK with a valid JWT and the expected evaluation summary response.
- GET /api/student/evaluation-results/notifications returns 200 OK with the expected notification status (hasNewResults, unreadCount, lastViewedAt, and latestNotificationAt).
- Requests without an Authorization header correctly return 401 Unauthorized.
- Requests with an invalid JWT correctly return 401 Unauthorized (Invalid token).
- Student endpoints are protected, and authentication behaves as expected.
No issues found during testing. Looks good to me.
BosuBose132
left a comment
There was a problem hiding this comment.
Reviewed and tested PR #2108 locally on the pr-2108 / linh_student_eval_clean backend branch.
What I verified:
- Backend dependencies installed successfully.
- Backend started successfully using npm run dev.
- GET /api/student/evaluation-results returned 200 OK with a valid token.
- The response included the expected structure with summary, categories, and taskResults.
- For the test user with no evaluation results, the endpoint returned a safe empty-state response with performanceLevel as “No Results”, empty categories, and empty taskResults.
- GET /api/student/evaluation-results/notifications returned 200 OK with the expected notification fields: hasNewResults, unreadCount, lastViewedAt, and latestNotificationAt.
- Requests without an Authorization header returned 401 Unauthorized.
- Requests with an invalid token returned 401 Unauthorized / Invalid token.
- No backend crash or related terminal errors were observed during testing.
Based on the tested student evaluation result endpoints and authentication behavior, the backend changes look good to me.
There was a problem hiding this comment.
Hi I reviewed #2108 on my local. This is working as expected.
Passing cases
-Backend validates auth status of the user.
-Admin is able to post the result for particular student id in the given category using /api/educator/evaluation-results/publish
-User is able get back the rresponse with 200 code status on api/student/evaluation-results
-User is able get back notification stats back on this backend endpoint /api/student/evaluation-results/notifications
There was a problem hiding this comment.
Review Summary of PR #2108
Reviewed and tested PR #2108 locally on the pr-2108 / linh_student_eval_clean backend branch.
Verified:
- Backend started successfully using
npm run dev. - Requests without an Authorization header returned 401 Unauthorized.
- Requests with an invalid token returned 401 Unauthorized / Invalid token.
GET /api/student/evaluation-resultsreturned 200 OK with a valid token.- The response included the expected structure with
summary,categories, andtaskResults. - For the test user with no evaluation results, the endpoint returned a safe empty-state response with
performanceLevelas "No Results", emptycategories, and emptytaskResults.
- The response included the expected structure with
GET /api/student/evaluation-results/notificationsreturned 200 OK with the expected notification fields:hasNewResults,unreadCount,lastViewedAt, andlatestNotificationAt.
Conclusion
CarolineYXW
left a comment
There was a problem hiding this comment.
Hello, I tested the new student evaluation endpoints locally using curl.
- Confirmed unauthenticated and invalid-token requests return 401.
- Confirmed GET /api/student/evaluation-results returns 200 with the expected summary, categories, and taskResults structure, including the empty “No Results” state.
- Confirmed GET /api/student/evaluation-results/notifications returns the expected notification fields, and unauthenticated access returns 401.
- Confirmed the publish endpoint correctly rejects missing studentId, empty evaluations, and malformed evaluation objects with 400 responses.
I was not able to test a successful 201 publish flow because I did not have a seeded student evaluation payload, but the validation and retrieval flows worked as expected. No issues found from my testing.
sitaram1921
left a comment
There was a problem hiding this comment.
Reviewed PR 2108 (Student Evaluation Results Backend APIs). Tested the three new endpoints directly via Postman (publish, get results, notifications) since there is no frontend for this yet. Publish and notifications work correctly. Noticed that category-level aggregation (weightage, marks, percentage, performanceLevel) does not reflect the submitted tasks, a 90 percent task showed up as 0 percent and Needs Improvement at the category and summary level. Flagged for the author to confirm expected behavior.
AnshShah-18
left a comment
There was a problem hiding this comment.
Reviewed and tested PR #2108 locally on pr-2108
Verified that the backend starts successfully, authentication rejects missing and invalid tokens, the student evaluation and notification endpoints return the expected responses, publish validation returns the correct 400 errors, and a valid publish request returns 201 and creates the related notification. Viewing the results also correctly updates the viewed timestamp and notification status.
The tested authentication, validation, publishing, retrieval, and notification flows are working as expected. Approving this PR.
iAbhi001
left a comment
There was a problem hiding this comment.
Checked out pr-2108 and gave PR #2108 a full test locally.
Everything looks good on my end. The backend boots up fine, and auth properly blocks missing or bogus tokens. I tested the student evaluation and notification endpoints, and they're returning the right responses. Validation on publish triggers the expected 400 errors when it should, and sending a valid publish request hits a 201 and creates the notification as intended. Also verified that viewing results updates the timestamp and marks the notification as read.
Auth, validation, publishing, retrieval, and notification flows are all working as expected—LGTM, approving!
|
Thank you all, merging! |













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: