Skip to content

Fix XBlock studio handler silently dropping Course Editor writes #598

Done
openedx/openedx-platform
#39375

Description

@BryanttV

Description

When an XBlock studio handler (e.g. Drag and Drop, Survey) is called by a Course Editor, the changes are not persisted, yet the handler returns 200 and the UI reports success. This is silent data loss.

Current Behavior

component_handler (views/component.py:567) decides whether to persist using the legacy has_course_author_access. Editors have no legacy role (LEGACY_COURSE_ROLE_EQUIVALENCES does not include them), so update_item is skipped and only a warning is logged. The response is still 200.

Expected Behavior

Editors' changes are persisted. Callers without permission get an explicit 403 instead of a fake success.

Steps to reproduce

  1. Log in as a Course Editor.
  2. Edit a Drag and Drop (or Survey) component and save.
  3. Observe the success message, then reload and see the change was not saved.

Acceptance Criteria

  • component_handler persists with update_item when user_has_course_permission(request.user, COURSES_EDIT_COURSE_CONTENT.identifier, usage_key.course_key, LegacyAuthoringPermission.WRITE) is true.
  • When the user lacks permission and the handler changed fields, the response is 403 rather than a silent 200.
  • Editor edits to these XBlocks persist.
  • Tests are added or updated.

Proposed Solution

if user_has_course_permission(
    request.user, COURSES_EDIT_COURSE_CONTENT.identifier,
    usage_key.course_key, LegacyAuthoringPermission.WRITE,
):
    modulestore().update_item(block, request.user.id, asides=asides)

The else branch should return 403, at least when the handler actually changed fields.

Metadata

Metadata

Assignees

Labels

willow

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions