Skip to content

Conversation

@ShanaLMoore
Copy link
Contributor

@ShanaLMoore ShanaLMoore commented Jan 13, 2026

Story: [i499] Edit Functionality for Questions

This implementation does not include stimulus case study questions at this time.

Ref:

Expected Behavior Before Changes

Users had no way to edit questions once they were created.

Expected Behavior After Changes

Users can see an edit button on their own questions and admins can see an edit button on all questions (expect stimulus case study).
Users can see the data of their question populated into a modal form.
Users can edit and update their question.

Screenshots / Video

Edit functionality
Screen.Recording.2026-01-20.at.3.10.38.PM.mov
User can only edit their own questions
Screen.Recording.2026-01-20.at.3.16.48.PM.mov
Wysiwyg for essay questions Screenshot 2026-01-20 at 3 18 34 PM

Notes

This implementation does not include stimulus case study questions at this time. Users can perform an edit-like action on stimulus case study questions by exporting the question to a CSV, editing the CSV, importing the question, and deleting the old version.

laritakr and others added 4 commits January 9, 2026 17:07
Split into separate UI component to separate logic and presentation.
This commit updates the QuestionFormUI component to ensure that it
renders the appropriate form based on the question type when a user is
editing a question.

The component checks the question from the database and maps it to the
correct question type.

Ref:
- #499
@github-actions
Copy link

github-actions bot commented Jan 13, 2026

Test Results

139 tests  ±0   139 ✅ ±0   0s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit fdf8747. ± Comparison against base commit ffb1578.

♻️ This comment has been updated with latest results.

sjproctor and others added 15 commits January 15, 2026 09:59
This commit adds the functionality to display the question image on the
edit modal if the question has an associated image.

Ref:
- #499
This commit updates the fetch function to support PUT requests for
creating new questions and PATCH requests for updating existing
questions.

Ref:
- #499
This commit ensures the correct format for the matching questions is
rendered in the edit form. The correct answer is stored as an array
['match1'], but the form component expects it as a string 'match1'.

Ref:
- #499
This commit ensures the typeahead functionality works correctly for the
subject field in the edit questions form.

Ref:
- #499
This commit adds an update route and controller action for questions
to be modified.

Ref:
- #499
This commit ensures the question create and edit forms maintain a two
two column layout even when many subjects are added to the question.

Ref:
- #499
This commit removes the footer that contained a close button from the
edit question modal. There is a close button available in the header.
This ensures a more visually clean UI and reduces confusion between
close button and update button.

Ref:
- #499
This commit sets dynamic text on the button to display "Submit" when
creating a new question and "Update" when editing an existing question.

Ref:
- #499
@kirkkwang kirkkwang force-pushed the i499-edit-questions branch 2 times, most recently from 1724e04 to 848d2f6 Compare January 20, 2026 20:00
This commit will let the user edit the existing image, which is only the
alt text currently, and also let them delete the image.
@kirkkwang kirkkwang force-pushed the i499-edit-questions branch from 848d2f6 to 308e489 Compare January 20, 2026 20:33
@laritakr laritakr force-pushed the i499-edit-questions branch from d9093d8 to 9b2928f Compare January 20, 2026 22:41
This commit removes the edit button from the stimulus case study type
questions until we can refactor the question structure to make editing
more accessible.

As a workaround, users can still export the stimulus case study
questions, edit the CSV, and re-import. They would need to manually
delete the existing question.

Ref:
- #539
- #499
@sjproctor sjproctor marked this pull request as ready for review January 20, 2026 23:21
@ShanaLMoore ShanaLMoore requested a review from Copilot January 20, 2026 23:24
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 pull request adds edit functionality for questions, allowing users to edit their own questions and admins to edit all questions (excluding Stimulus Case Study type). The implementation includes a modal-based editing interface that reuses the existing question creation form, with modifications to support pre-populating data from existing questions.

Changes:

  • Added react-quill package for WYSIWYG editing of Essay and File Upload question types
  • Implemented update route and controller action for questions API
  • Created modal-based edit interface using the existing CreateQuestionForm component
  • Enhanced form components to support both create and edit modes with data pre-population
  • Added image management for existing images (update alt text, mark for deletion)

Reviewed changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
package.json Added react-quill dependency for rich text editing
config/routes.rb Added update route to questions API
app/models/question.rb Enhanced images_as_json to include image IDs for edit functionality
app/javascript/components/ui/Question/QuestionWrapper.jsx Passed subjects prop for edit modal
app/javascript/components/ui/Question/QuestionMetadata.jsx Added edit button with permission checks and edit modal integration
app/javascript/components/ui/Question/QuestionEditModal.jsx New modal component for editing questions
app/javascript/components/ui/CreateQuestionForm/index.jsx Refactored to support both create and edit modes with data initialization
app/javascript/components/ui/CreateQuestionForm/QuestionFormUI.jsx Extracted UI component to support modal rendering
app/javascript/components/ui/CreateQuestionForm/Essay.jsx Added ReactQuill for rich text editing and data prop support
app/javascript/components/ui/CreateQuestionForm/Upload.jsx Added ReactQuill for rich text editing and data prop support
app/javascript/components/ui/CreateQuestionForm/Subject.jsx Enhanced to support pre-populated subjects
app/javascript/components/ui/CreateQuestionForm/LevelDropdown.jsx Enhanced to support pre-selected level
app/javascript/components/ui/CreateQuestionForm/ImageUploader.jsx Added support for existing images with deletion marking
app/javascript/components/ui/CreateQuestionForm/AnswerSet.jsx Added initialData prop for pre-populating answers
app/javascript/components/ui/CreateQuestionForm/Bowtie.jsx Added data prop for pre-populating bowtie answers
app/javascript/components/ui/CreateQuestionForm/Categorization.jsx Added data prop for pre-populating categories
app/javascript/components/ui/CreateQuestionForm/DragAndDrop.jsx Added data prop for pre-populating drag and drop items
app/javascript/components/ui/CreateQuestionForm/Matching.jsx Added data prop for pre-populating matching pairs
app/javascript/components/ui/CreateQuestionForm/MultipleChoice.jsx Added data prop for pre-populating choices
app/javascript/components/ui/CreateQuestionForm/SelectAllThatApply.jsx Added data prop for pre-populating answer options
app/javascript/components/ui/CreateQuestionForm/StimulusCaseStudy.jsx Enhanced to support editing with data pre-population
app/javascript/components/pages/Search/index.jsx Code formatting changes and subjects prop passing
app/controllers/api/questions_controller.rb Added update action with image handling and permission validation
Comments suppressed due to low confidence (1)

app/javascript/components/ui/CreateQuestionForm/index.jsx:111

  • For Essay and File Upload question types, the handler converts data by splitting on newlines and wrapping in paragraph tags (lines 95-98, 107-110). However, when editing an existing Essay/Upload question, the data is already HTML from ReactQuill (as set in line 43). Calling .split('\n') on HTML content will break the formatting. This handler should check if the data is already HTML or use the data as-is when it's already in HTML format.
      Essay: () =>
        appendData({
          html: data
            .split('\n')
            .map((line, index) => `<p key=${index}>${line}</p>`)
            .join('')
        }),
      'Drag and Drop': () => appendData(filterValidData(data)),
      'Bow Tie': () => data && appendData(data),
      'Multiple Choice': () => appendData(filterValidData(data)),
      'Select All That Apply': () => appendData(filterValidData(data)),
      'Stimulus Case Study': () => appendData(data),
      'File Upload': () =>
        appendData({
          html: data
            .split('\n')
            .map((line, index) => `<p key=${index}>${line}</p>`)
            .join('')
        })

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

@sjproctor sjproctor merged commit 8d3144c into main Jan 21, 2026
11 checks passed
@sjproctor sjproctor deleted the i499-edit-questions branch January 21, 2026 20:07
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.

5 participants