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.
What
Added functionality to pin important posts at the top of the Q&A section. This ensures that critical posts, such as announcements or key instructions, remain visible to students and do not get lost among other posts. Also added associated unit tests to verify this functionality.
Why
Addresses the user story:
"As an instructor, I want to pin important posts at the top of the Q&A section, so that students can see relevant announcements or information easily." (User story #5 ). close #5
This feature contributes to a more organized learning experience by making important information readily accessible to students.
How
Changes were made in:
src/api/categories.js (Backend logic to pin/unpin topics)
src/controllers/category.js (Ensure pinned topics are displayed at the top)
src/privileges/topics.js (Adjusting privileges to ensure only instructors can pin topics)
src/topics/pin.js (Handling the pin button interaction)
test/topics.js (Unit tests for pin functionality)
Testing
Manual user tests were conducted to confirm functionality as follows:
Login as an instructor.
Navigate to the Q&A section.
Select an existing topic or create a new one.
Click on the "Topic Tools" option and choose "Pin Topic."
Verify that the post remains pinned at the top of the Q&A section.
Login as a regular user (student) and verify that the pinned post is visible at the top of the Q&A section.
Ensure regular users cannot access the "Pin Topic" functionality.
Location of Automated Tests
File: test/topics.js
Lines: 691-702
These tests ensure that the server updates the topic object correctly when interacting with the pin button.