Skip to content

Remove XModuleMixin legacy attributes from extracted blocks #125

@kdmccormick

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'))

Metadata

Metadata

Assignees

Labels

epicLarge unit of work, consisting of multiple tasks

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions