Skip to content

Conversation

@adi-herwana-nus
Copy link
Contributor

Examples:
Screenshot 2026-01-17 at 04 16 26
Screenshot 2026-01-17 at 04 16 33

- separate question show view (used in rubric playground) into its own view
Copy link

Copilot AI left a 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 adds the ability to display staff-only comments for questions on the assessment view page, making internal notes visible to course staff when reviewing assessment questions.

Changes:

  • Added staffOnlyComments field to question type definitions
  • Rendered staff-only comments as an info alert below question descriptions in the assessment view
  • Created a new jbuilder view template for the questions show endpoint
  • Added a helper method to check if HTML text contains actual content

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
client/app/types/course/assessment/questions.ts Added QuestionBaseDataWithUrl interface and staffOnlyComments field to QuestionData
client/app/bundles/course/assessment/pages/AssessmentShow/Question.tsx Added UI to display staff-only comments in an Alert component
client/app/api/course/Assessment/Question/Questions.ts Updated return type of fetch method to use QuestionBaseDataWithUrl
app/views/course/question_assessments/_question_assessment.json.jbuilder Added conditional rendering of staffOnlyComments field using new helper
app/views/course/assessment/questions/show.json.jbuilder Created new view template for questions show endpoint
app/helpers/application_formatters_helper.rb Added html_text_blank? helper method
app/controllers/course/assessment/questions_controller.rb Removed explicit render call to use implicit view rendering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +108 to +112
def html_text_blank?(text)
return true if text.blank?

HTMLEntities.new.decode(ActionController::Base.helpers.strip_tags(text)).strip.blank?
end
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The new html_text_blank? helper method lacks test coverage. The file already has comprehensive tests for format_rich_text_for_csv, and a similar testing pattern should be applied here to verify behavior with nil, empty strings, HTML-only markup (e.g., <p></p>), whitespace, and HTML entities.

Copilot uses AI. Check for mistakes.
Comment on lines +201 to +210
{question.staffOnlyComments && (
<Alert className="[&_p]:m-0" icon={false} severity="info">
<Typography
dangerouslySetInnerHTML={{
__html: question.staffOnlyComments,
}}
variant="body2"
/>
</Alert>
)}
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Using dangerouslySetInnerHTML with user-generated content poses an XSS risk. While format_ckeditor_rich_text on the backend does sanitize HTML, relying solely on server-side sanitization can be risky if the sanitization logic changes or has vulnerabilities. Consider using a client-side sanitization library like DOMPurify before rendering, or verify that the backend sanitization is comprehensive and XSS-safe.

Copilot uses AI. Check for mistakes.
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.

2 participants