Skip to content

Staff Endorse Anytime Question Comment#500

Merged
kjassani merged 38 commits intomainfrom
karim/anytime-question-comment-endorse
Apr 8, 2026
Merged

Staff Endorse Anytime Question Comment#500
kjassani merged 38 commits intomainfrom
karim/anytime-question-comment-endorse

Conversation

@kjassani
Copy link
Copy Markdown
Collaborator

@kjassani kjassani commented Mar 24, 2026

Description

High level Summary:

  • Staff (TAs/Professors) can endorse comments on async questions via a thumbs-up button, and remove endorsements by clicking again
  • Endorsed comments display a green badge showing the endorser's role (Instructor/TA) and name
  • Endorsed comments are sorted to the top of the comment list, with time-based ordering as tiebreaker
  • Only staff can endorse; students see the badge but not the button

Backend Changes:

  • New PATCH /asyncQuestions/comment/:qid/:commentId/endorse endpoint, guarded by Role.TA and Role.PROFESSOR
  • Added endorsedById foreign key to AsyncQuestionComment entity with a migration (1773057600000-add-comment-endorsement)
  • Loaded comments.endorsedBy and comments.endorsedBy.courses relations across all async question query sites so the endorser's course role is derived correctly
  • Added AsyncQuestionCommentEndorseParams DTO to @koh/common
  • Response includes endorser info with role (derived from course membership, not global role)

Frontend Changes:

  • Endorse button (thumbs-up icon) next to commenter name, visible to staff only
  • Endorsed badge below comment body: green chip with "Endorsed by Instructor/TA (Name)"
  • Comments sort endorsed-first, then by createdAt ascending
  • New EndorserInfo type and endorseComment API method

Closes #501

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This requires a run of yarn install
  • This change requires an addition/change to the production .env variables. These changes are below:
  • This change requires developers to add new .env variables. The file and variables needed are below:
  • This change requires a database query to update old data on production. This query is below:

How Has This Been Tested?

  • 7 new integration tests for the endorse endpoint:
    • TA can endorse / un-endorse a comment
    • Student cannot endorse (403)
    • 404 for non-existent question or comment
    • Users outside the course cannot endorse
    • GET response includes endorsedBy with role when a comment is endorsed
  • Snapshots updated to reflect new endorsedBy/endorsedById fields

Mannual Testing Instructions:

Setup: Log in as TA/Professor in a course with at least one async question that has 2+ comments.

Endorse

  1. Open an async question -> see thumbs-up icon next to each comment
  2. Click thumbs-up -> green badge appears below comment: "Endorsed by TA/Instructor (YourName)"
  3. Comment moves to top of list

Un-endorse

  1. Click the green thumbs-up again -> badge disappears, comment returns to chronological position

Student view

  1. Log in as student -> no thumbs-up button visible, endorsed badge still shows
Click to expand screenshots

Demo:

Anytime.Question.Endorse.Demo.mp4

Demo Mobile:

Staff.Endorse.Anytime.Question.Demo.Mobile.mov

Professor view:
image

Professor view on Mobile:
image

Student view:
image

Student view on Mobile:
image

Checklist:

  • I have performed a code review of my own code (under the "Files Changed" tab on github) to ensure nothing is committed that shouldn't be (e.g. leftover console.logs, leftover unused logic, or anything else that was accidentally committed)
  • I have commented my code where needed
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing tests pass locally with my changes
  • Any work that this PR is dependent on has been merged into the main branch
  • Any UI changes have been checked to work on desktop, tablet, and mobile

@kjassani kjassani self-assigned this Mar 26, 2026
@kjassani kjassani changed the title Karim/anytime question comment endorse Staff Endorse Anytime Question Comment Mar 26, 2026
@kjassani kjassani marked this pull request as ready for review March 26, 2026 04:45
@kjassani kjassani requested review from AdamFipke and bhunt02 March 26, 2026 04:46
@AdamFipke
Copy link
Copy Markdown
Collaborator

I gave it a quick look over. Changes looks pretty simple so it looks pretty good I think! Though, I would like you to test how it looks on mobile (since Anytime Questions on mobile can look particularly crammed). Send screenshots too please.

And as a reminder, you can turn your browser into a mobile view by clicking this button under browser inspect
image

@kjassani
Copy link
Copy Markdown
Collaborator Author

I gave it a quick look over. Changes looks pretty simple so it looks pretty good I think! Though, I would like you to test how it looks on mobile (since Anytime Questions on mobile can look particularly crammed). Send screenshots too please.

And as a reminder, you can turn your browser into a mobile view by clicking this button under browser inspect image

Hi Adam, thanks for the review. I have updated the PR description with screenshots and a video from mobile.

Copy link
Copy Markdown
Collaborator

@AdamFipke AdamFipke left a comment

Choose a reason for hiding this comment

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

Few comments. Nothing that big.

Also super small thing. When reviewing this, I ended up reading through some old code logic that was baffling me and ended up renaming some variables to make it easier to read. That's all that commit was about.

Comment thread packages/server/src/asyncQuestion/asyncQuestion.controller.ts
Comment thread packages/server/src/asyncQuestion/asyncQuestion.controller.ts
Comment thread packages/server/src/asyncQuestion/asyncQuestion.controller.ts
@kjassani kjassani requested a review from AdamFipke April 2, 2026 22:27
Copy link
Copy Markdown
Collaborator

@AdamFipke AdamFipke left a comment

Choose a reason for hiding this comment

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

Few more comments. Only small things.

Comment thread packages/server/migration/1773057600000-add-comment-endorsement.ts Outdated
Comment thread packages/server/src/asyncQuestion/asyncQuestion.controller.ts
@kjassani kjassani requested a review from AdamFipke April 8, 2026 07:12
Copy link
Copy Markdown
Collaborator

@AdamFipke AdamFipke left a comment

Choose a reason for hiding this comment

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

should be good to merge i think

@kjassani kjassani merged commit 5042fc8 into main Apr 8, 2026
2 checks passed
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.

Staff can endorse anytime question comments

2 participants