Skip to content

[Tagging] Handle copying tag data when duplicating XBlocks #181

Closed

Description

@yusuf-musleh

"As a content author, when I duplicate an XBlock that has tags applied, the newly created XBlock through duplication should also have the tags carried over and applied"

Acceptance Criteria
This step implements changes needed to handle the "duplicate xblock" case, as the logic slightly differs from the copy/paste case. This comes after completed the implementation for pasting XBlocks, and adds additional changes needed.

  • In the duplicate_block function, we can add a new kwarg called “with_tags=True” that will (by default) copy over the tags from the xblock (and its children if shallow=False) that is being duplicated
  • That function calls the gather_block_attributes function, which we can pass in the new with_tags kwarg, in this case we default to False so it doesnt affect other calls to this function. If set to True, we can fetch the tags for that xblock using the get_tags_content API method, similar to Step 1 and include the results in the duplicate_metadata that is returned
  • Once the new duplicated xblock is created using store.create_item, we can then apply all the returned tags to the new xblock using tag_content_object method
  • The same steps will be repeated for the children since the duplicate_block function will be called recursively, so it handles that case if we pass in the same with_tags kwarg value.
  • Implement tests to verify this was implemented correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions