Skip to content

Remove XModuleMixin legacy attributes from extracted blocks #125

Closed
8 of 8 issues completed
Closed

Description

@kdmccormick

The XModuleMixin in edx-platform defines legacy backwards-compatibility properties.

  • The mixin is dynamically added to all LMS XBlocks for modulestore, and CMS blocks for modulestore as well. This means that the mixin is added to all blocks in courses and legacy libraries. We need to do this because modulestore-based code uses these legacy attributes.
  • The mixin is NOT added to openedx_content. This means that the mixin is NOT added to blocks for V2 libraries. This is on purpose, so that we don't rely on the legacy attributes in learning-core-based code.

XBlocks themselves should not to define these legacy attributes (other than display_name, which is special and should be defined on every block).

We added some of those legacy attributes to WordCloud in order to get it working in Libraries V2. That will work for now. But, the right fix is to find out where the legacy attributes were being called in libraries V2, and then fix those references of the legacy attributes. For example, if Libraries V2 code is calling .location, then it should be changed to .usage_key instead. Then, these legacy attributes can be removed from WordCloud.

The same approach should be taken for any other extracted block that hits this issue.

Relevant PR: openedx/openedx-platform#37845


Steps to follow

We can following these steps while removing the XModuleMixin legacy attributes from the extracted blocks.

  • Find and replace the XModuleMixin legacy attributes with the corresponding new code shared in the mappings below
  • Remove the XModuleMixin legacy attributes from the extracted block.
  • Create a PR on xblocks-contrib and fix test case if required.
  • Test the working of the extracted block on the local setup
  • Create a relevant PR on openedx-platform changing reference of xblocks-contrib to the PR branch create above
  • Fix the test cases if required
  • Create the sandbox and do the testing of the extracted block with removed XModuleMixin legacy attributes

Here are the update mappings, we are following while working on this story.

We can simply find and replace these usages (getters) in the code keeping the order given below.

The new mappings (old -> new) are:

  • .location -> .usage_key

  • .scope_ids.usage_id -> .usage_key

  • .category -> .usage_key.block_type

  • .url_name -> .usage_key.block_id

  • .course_key -> .context_key

  • .course_id -> .context_key

  • .usage_key.context_key -> .context_key

  • .scope_ids.usage_id.context_key -> .context_key

Important references:

class ScopeIds(namedtuple('ScopeIds', 'user_id block_type def_id usage_id'))

Activity

  1. added
    epicLarge unit of work, consisting of multiple tasks
    on Dec 26, 2025
  2. moved this from 🆕 New to 📋 Backlog in Aximprovements Teamon Jan 8, 2026
  3. farhan commented on Jan 8, 2026

    @farhan
    Contributor

    Here is the WIP PR that will be completed within the scope of this story
    Relevant PR will be made on edx-platform to check the test cases status
    https://github.com/openedx/xblocks-contrib/pull/128/files

  4. removed
    epicLarge unit of work, consisting of multiple tasks
    on Jan 8, 2026
  5. farhan commented on Jan 21, 2026

    @farhan
    Contributor

    @farhan has to create test cases PR for edx-platform

  6. farhan commented on Jan 22, 2026

    @farhan
    Contributor

    Here is the test cases PR: openedx/openedx-platform#37929

  7. self-assigned this
    on Feb 11, 2026
  8. moved this from 📋 Backlog to 🔖 Ready in Aximprovements Teamon Feb 11, 2026
  9. assigned and unassigned on Feb 11, 2026
  10. 5 remaining items

  11. added
    epicLarge unit of work, consisting of multiple tasks
    on Mar 25, 2026
  12. moved this from 🏗 In progress to 🔖 Ready in Aximprovements Teamon Mar 25, 2026
  13. moved this from 🔖 Ready to 👀 In review in Aximprovements Teamon Apr 2, 2026
  14. moved this from 👀 In review to ✅ Done in Aximprovements Teamon Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

epicLarge unit of work, consisting of multiple tasks

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions