Skip to content

Support instruction steps - #953

Draft
zetter-rpf wants to merge 2 commits into
mainfrom
instruction-steps
Draft

Support instruction steps#953
zetter-rpf wants to merge 2 commits into
mainfrom
instruction-steps

Conversation

@zetter-rpf

@zetter-rpf zetter-rpf commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Status

What's changed?

  • Added support for instructions to contain multiple steps
  • Simplified how we were preventing students from updating instructions

The new instructions will be in a format such as:

[
  {markdown_content: 'step 1'},
  {markdown_content: 'step 2'},
]

This change is backwards compatible with our existing instructions since sole strings are allowed in the JSONB column.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test coverage

92.18% line coverage reported by SimpleCov.
Run: https://github.com/RaspberryPiFoundation/editor-api/actions/runs/31181894189

@zetter-rpf zetter-rpf changed the title Instruction steps Support instruction steps Aug 7, 2026
@zetter-rpf
zetter-rpf marked this pull request as ready for review August 7, 2026 10:08
Copilot AI review requested due to automatic review settings August 7, 2026 10:08
@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-instructio-tqy3iv August 7, 2026 10:10 Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for storing project instructions as multi-step content (JSON) while adjusting update behavior so student attempts to change instructions are ignored rather than rejected. This fits into the Rails REST API layer (controllers + Jbuilder) and the Project::Update domain operation.

Changes:

  • Convert projects.instructions from text to jsonb to support either a plain markdown string or an array of instruction steps.
  • Update request handling so students cannot submit instructions via strong params (making instruction updates a no-op for students).
  • Extend request specs to cover reading/writing the instruction-steps format and update unit specs for the new Project::Update signature.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/requests/projects/update_spec.rb Adds coverage for saving/returning instruction steps; updates student behavior expectation to “ignore” instruction changes.
spec/requests/projects/show_spec.rb Adds coverage for returning instruction steps when stored as an array.
spec/concepts/project/update_spec.rb Updates unit specs for Project::Update signature change; removes student/teacher branching in operation tests.
spec/concepts/project/update_invalid_spec.rb Updates unit spec call signature for Project::Update.
spec/concepts/project/update_delete_components_spec.rb Updates unit spec call signature for Project::Update.
spec/concepts/project/update_default_component_spec.rb Updates unit spec call signature for Project::Update.
lib/concepts/project/operations/update.rb Removes current_user-based validation and always assigns :instructions if present in update_hash.
db/schema.rb Reflects projects.instructions as jsonb.
db/migrate/20260807120000_change_projects_instructions_to_jsonb.rb Migration to convert instructions from text to jsonb (and back).
config/locales/en.yml Removes now-unused “student_update_instructions” translation.
app/controllers/api/projects/remixes_controller.rb Permits instruction-step shape in remix request params.
app/controllers/api/projects_controller.rb Moves instruction-update prevention for students into strong params; refactors permitted attributes list.

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

Comment thread db/migrate/20260807120000_change_projects_instructions_to_jsonb.rb Outdated
Previously project instructions could only be a single markdown
string, with no way to break guidance into discrete, orderable
steps.

This change adds an instruction_steps jsonb column and stores the
new array-of-steps format there, leaving the existing instructions
text column untouched - it never needs to change type, so there is
no risk of a running server caching a stale column type against it.
Project#instructions reads instruction_steps when present and falls
back to the legacy text column otherwise; the controller permits
either a plain string or an array of {markdown_content} steps under
the same instructions param, so no other call site needs to know
about the split.

Existing rows keep instruction_steps nil until a project is saved
through the new format - no backfill needed.
Previously Project::Update compared old and new instructions to
detect and reject a student trying to change them, needing a
current_user argument and a JSON-normalising comparison just to
tell Parameters and plain Ruby values apart.

This change drops :instructions from the permitted params entirely
when the current user is a student, so their attempt is filtered
out the same way Rails treats any other unpermitted param. The
request now succeeds with the change silently ignored, instead of
returning a 422. Project::Update no longer needs to know who the
current user is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants