Skip to content

Return the project locale on lesson JSON - #980

Closed
jamiebenstead wants to merge 1 commit into
mainfrom
1722-return-project-locale-on-lessons
Closed

Return the project locale on lesson JSON#980
jamiebenstead wants to merge 1 commit into
mainfrom
1722-return-project-locale-on-lessons

Conversation

@jamiebenstead

@jamiebenstead jamiebenstead commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Status

Return the project locale on lesson JSON

Adds :locale to the nested project object in _lesson.json.jbuilder, so it appears on GET /api/lessons, GET /api/lessons/:id and POST /api/lessons/batch.

Experience CS now sends project_attributes.locale when adding projects to a class, so teachers get lesson content in the language they were browsing in. Editor API already accepted and stored that value, but never returned it — so there's no way to confirm through the API which locale a lesson's project was created in.

This follows the existing pattern on this endpoint: create_batch already echoes origin_identifier back so callers can verify their request landed correctly. It also brings the nested project in line with projects#show, which already returns locale.

Response-only — no change to what gets persisted, and no behaviour change for existing consumers (additive field). No caller reads it today; this is for consistency and observability rather than to unblock the Experience CS work, which ships without it.

Lets callers confirm which locale a lesson's project was created in.
Copilot AI lite review requested due to automatic review settings August 25, 2026 12:50
@cla-bot cla-bot Bot added the cla-signed label Aug 25, 2026

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

This PR updates the Lessons API JSON representation to include the associated project’s locale, enabling clients to confirm the locale of the lesson’s backing project (work towards digital-editor-issues#1722).

Changes:

  • Add project.locale to the lesson JSON payload returned by the API.
  • Update lessons listing request spec expectations to include locale in the embedded project JSON.
  • Add batch-create request spec coverage to ensure supplied locales are persisted and returned per created project.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
spec/features/lesson/listing_lessons_spec.rb Updates expected embedded project JSON to include locale.
spec/features/lesson/creating_a_batch_of_lessons_spec.rb Adds coverage for supplying, persisting, and returning locale in batch-created lesson projects.
app/views/api/lessons/_lesson.json.jbuilder Extends embedded project fields to include :locale.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown

Test coverage

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

@raspberrypiherokubot
raspberrypiherokubot temporarily deployed to editor-api-p-1722-retur-qxtb22 August 25, 2026 12:56 Inactive
@zetter-rpf

zetter-rpf commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@jamiebenstead could you add a PR description for this?

I'm not sure where this is needed - where are we calling the lesson listing API that we will need the locale?

EDIT- this is clearer after I looked at https://github.com/RaspberryPiFoundation/experience-cs/pull/2358 and saw it being used, but it would be still good to explain that in the description.

@jamiebenstead

Copy link
Copy Markdown
Contributor Author

@jamiebenstead could you add a PR description for this?

I'm not sure where this is needed - where are we calling the lesson listing API that we will need the locale?

EDIT- this is clearer after I looked at RaspberryPiFoundation/experience-cs#2358 and saw it being used, but it would be still good to explain that in the description.

@zetter-rpf Added a description now. It seems like we don't actually need to make this change, but Claude recommends it based on the experience-cs work

@zetter-rpf

Copy link
Copy Markdown
Contributor

@zetter-rpf Added a description now. It seems like we don't actually need to make this change,

Agreed. There might be some API changes needed for https://github.com/RaspberryPiFoundation/digital-editor-issues/issues/1724, but don't think we'll need to set the Project locale.

1 similar comment
@zetter-rpf

This comment was marked as duplicate.

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.

4 participants