Skip to content

add option for users to make posts/replies that are only visible to instructors#36

Open
pebble-fish wants to merge 6 commits into
mainfrom
feat/instructor
Open

add option for users to make posts/replies that are only visible to instructors#36
pebble-fish wants to merge 6 commits into
mainfrom
feat/instructor

Conversation

@pebble-fish

@pebble-fish pebble-fish commented Feb 27, 2026

Copy link
Copy Markdown

##User Story##
Students may want to ask questions about a course to instructors, but need to show instructors parts of their buggy code. For many CS classes, it is not allowed to show any part of your code to other students, even if unintentionally. Without the option to make posts visible only to instructors, they risk an AIV or their question going unanswered.

##Summary of PR Additions##

  1. The button for Anonymous posting was modified from a toggle to a visibility dropdown in both composers (for QuickReply and NewTopic).
    a. The dropdown has three options: Post Publicly (default), Post Anonymously, and Post to Instructors.
    b. These changes were applied in QUick Reply and New Topic.
    c. the selection is stored in variable visibilityMode
  2. Persists visbility mode on posts/topics: posts store visbilityMode (public | anonymous | instructors), and the previous anonymous variable (to ensure the backend stuff still works from previous edits).
  3. Introduced canonical visbility helper logic for mode normalization and read checks
    a. instructor only visibility is restricted to: post/topic author or admins
  4. Anonymous behavior is still compatible: existing anonymous masking behavior is still preserved, and internal logic now maps anoynmous mode from visibilityMode
  5. Added tests for visibility modes to cover public visibility, anonymous visibility persistence/masking, instructor-only visibility for admin/author/regular users, and instructor-only topic filtering behavior.

##Post##

Recording.2026-02-27.193434.mp4

##Quick Reply##

Recording.2026-02-27.193434.mp4

##Errors Encountered##

  1. Schema validation failure in API tests
  • Failure: anonymous existed in response but wasn’t declared in PostObject schema.
  • Fix: added anonymous to public/openapi/components/schemas/PostObject.yaml.
  1. Deleted raw post regression
  • Failure: test expected null for deleted raw post read by non-mod; code returned raw content.
  • Cause: owner-read path inadvertently allowed in api.posts.getRaw.
  • Fix: restored strict behavior so deleted raw is only available to admin/mod.
  1. Composer/preview/posting regression risk
  • Symptom: posting and preview broke in runtime.
  • Cause: compatibility break between new dropdown and legacy anonymous checkbox assumptions.
  • Fix: added compatibility fallback + hidden legacy checkbox sync in composer and quick reply scripts/templates.
  1. Local test environment noise
  • Intermittent warnings unrelated to this feature:
    sendmail-not-found
    unsupported test image format warning
  • These are pre-existing environment/tooling artifacts and not introduced by visibility logic.
  1. Issue with COveralls being down for several days

##Testing##

  • build and run via ./nodebb build and ./nodebb restart
  • run full test suite using ``npm test`
  • manual checks:
    • open quickreply and post, confirm posting as dropdown appears with default as post publically
    • create one post/topic per node: public, anonymous, instructors

- Introduced visibilityMode and anonymous fields in post creation, editing, and retrieval processes.
- Updated topic creation and retrieval to include visibility settings.
- Implemented visibility checks to enforce access control based on user roles and visibility settings.
- Enhanced API and frontend components to support visibility mode selection and display.
- Introduced 'anonymous' field with a default value of 'false' in the PostObject schema.
- This update enhances the post creation and editing processes by allowing the specification of anonymity for posts.
- Simplified the logic for handling deleted posts by removing the selfPost check for non-admin users.
- Ensured that only admin or moderator privileges can bypass visibility restrictions for deleted posts.
@568cats 568cats self-requested a review February 27, 2026 20:33

@568cats 568cats left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a description of the feature/changes made as well as a way to test the feature in the body of the PR?

- Added a hidden checkbox for anonymous posting in the quick reply component.
- Updated JavaScript logic to synchronize the checkbox state with the visibility selection.
- Enhanced visibility mode handling to account for anonymous posts in various components, ensuring consistent behavior across the application.
@pebble-fish pebble-fish changed the title Feat/instructor add option for users to make posts/replies that are only visible to instructors Feb 28, 2026
@pebble-fish pebble-fish self-assigned this Feb 28, 2026
@pebble-fish

Copy link
Copy Markdown
Author

Could you add a description of the feature/changes made as well as a way to test the feature in the body of the PR?

updated, i will add the info on how to test later

** This was written by Amy, I'm committing it for internet/device reasons

@sliang-code sliang-code left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All code are good and it might be better with some additional comments especially in new file like visibility.js.

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.

Create an Instructor-Only View Button + Update Title to Reflect Instructor Only when Toggled Anonymous Reply Private Posts

3 participants