-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add instructor endorsement feature for student/TA posts #241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add endorsement database fields and core functionality - Implement API endpoints for endorsing/unendorsing posts - Add instructor privilege system and permission checks - Update post rendering to display endorsement status - Add frontend UI components and client-side handlers - Create database migration for instructors group - Add comprehensive language support and error messages This feature allows instructors to endorse posts from students/TAs to provide authoritative confirmation and reduce confusion in community forums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces an instructor endorsement feature that allows instructors to endorse student/TA posts to provide authoritative confirmation and reduce confusion in forums. The feature implements comprehensive backend functionality with API endpoints, database fields, privilege system, and frontend UI components.
Key Changes:
- Creates instructor user privilege system with dedicated "instructors" group
- Implements full endorsement API with database fields for tracking endorsement state
- Adds frontend UI components and real-time client-side handling
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/user/index.js | Adds instructor privilege check function |
| src/upgrades/1727697600000.js | Database migration to create instructors group |
| src/topics/posts.js | Integrates endorsement data into post rendering |
| src/routes/write/posts.js | Defines API routes for endorsement operations |
| src/privileges/users.js | Implements instructor group membership check |
| src/privileges/topics.js | Adds instructor privilege to topic context |
| src/privileges/posts.js | Implements endorsement permission logic |
| src/posts/index.js | Loads endorsement module |
| src/posts/endorsement.js | Core endorsement functionality |
| src/posts/data.js | Adds endorsement fields to post data structure |
| src/controllers/write/posts.js | HTTP controllers for endorsement endpoints |
| src/api/posts_endorsement.js | Dedicated API handlers for endorsement |
| src/api/posts.js | Main API endpoint implementations |
| public/src/client/topic/postTools.js | Client-side endorsement UI handlers |
| public/language/en-GB/topic.json | UI text for endorsement feature |
| public/language/en-GB/error.json | Error messages for endorsement operations |
| ENDORSEMENT_FEATURE.md | Feature documentation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| module.exports = { | ||
| name: 'Create instructors group', | ||
| timestamp: Date.UTC(2025, 8, 30, 12, 0, 0), |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timestamp uses Date.UTC(2025, 8, 30, 12, 0, 0) which creates a date in September 2025 (month 8), but this appears to be inconsistent with the filename timestamp 1727697600000 which corresponds to September 30, 2024. The year should be 2024, not 2025.
| 'use strict'; | ||
|
|
||
| const posts = require('../posts'); | ||
|
|
||
| const apiPosts = module.exports; | ||
|
|
||
| apiPosts.endorse = async (caller, data) => { | ||
| return await posts.endorse(data.pid, caller.uid); | ||
| }; | ||
|
|
||
| apiPosts.unendorse = async (caller, data) => { | ||
| return await posts.unendorse(data.pid, caller.uid); | ||
| }; | ||
|
|
||
| apiPosts.getEndorsement = async (caller, data) => { | ||
| const endorsementData = await posts.getEndorsementData([data.pid]); | ||
| return endorsementData[0] || { endorsed: false }; | ||
| }; No newline at end of file |
Copilot
AI
Oct 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file duplicates the exact same functionality as the methods added to src/api/posts.js (lines 656-667). Having identical API implementations in two separate files creates maintenance overhead and potential inconsistency. Consider removing this duplicate file and using only the implementations in src/api/posts.js.
| 'use strict'; | |
| const posts = require('../posts'); | |
| const apiPosts = module.exports; | |
| apiPosts.endorse = async (caller, data) => { | |
| return await posts.endorse(data.pid, caller.uid); | |
| }; | |
| apiPosts.unendorse = async (caller, data) => { | |
| return await posts.unendorse(data.pid, caller.uid); | |
| }; | |
| apiPosts.getEndorsement = async (caller, data) => { | |
| const endorsementData = await posts.getEndorsementData([data.pid]); | |
| return endorsementData[0] || { endorsed: false }; | |
| }; |
This feature allows instructors to endorse posts from students/TAs to provide authoritative confirmation and reduce confusion in community forums.