Return the project locale on lesson JSON - #980
Conversation
Lets callers confirm which locale a lesson's project was created in.
There was a problem hiding this comment.
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.localeto the lesson JSON payload returned by the API. - Update lessons listing request spec expectations to include
localein 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.
Test coverage93.43% line coverage reported by SimpleCov. |
|
@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. |
@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 |
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. |
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.