Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: duplicate tags when duplicating a tagged XBlock. #637

Conversation

pomegranited
Copy link
Member

@pomegranited pomegranited commented Feb 28, 2024

Description

Updates the TaggedBlockMixin to add a studio_post_duplicate handler which copies the tags on the source_item to the duplicated block.

More information

Closes openedx/modular-learning#181

Depends on

Private ref: FAL-3623

Testing instructions

  1. Run this branch on your devstack, and ensure you've installed the branch from feat: add get_taxonomy_by_export_id method [FC-0049] openedx/openedx-learning#164 on LMS + CMS.
  2. Enable and run the frontend-app-course-authoring MFE
  3. Set up Taxonomy/Tags data setup locally using https://github.com/open-craft/taxonomy-sample-data/
  4. Choose a unit from a course, and add several content tags from a few taxonomies.
  5. Add a block to the unit, and add several content tags to that too.
  6. Duplicate this tagged unit from the content outline using this button: image
  7. Ensure the new duplicate unit has the same tags as the source unit, and the duplicated child block also has the same tags as the source block.

Author Notes & Concerns

The implementation plan sketched out in openedx/modular-learning#181 has a flaw: When I tried storing the tag data in duplicate_metadata, eventually modulestore.create_item calls partition_fields_by_scope, which tries to call field = getattr(cls, 'tags-v1'). This errors out because tags-v1 isn't a real XBlock field.

We could fix this by refactoring TaggedBlockMixin to use a proper XBlock field for the tag data (and since we can't have a class attribute with a hyphen in it, we'd need to rename the field from tags-v1 to tags_v1).

Instead, I chose to use the XBlock studio_post_duplicate handler, as shown. A disadvantage of this approach is there's no good way to disable duplicating content tags when duplicating an XBlock; content tags will always be duplicated too.

Copy link

@yusuf-musleh yusuf-musleh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pomegranited Looks good to me, thanks for taking this over! 👍

  • I tested this: I tested duplicating units and blocks contains tags though both studio and the new mfe, and confirmed that the tags including children's tags have been duplicated
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository.

@pomegranited
Copy link
Member Author

pomegranited commented Feb 28, 2024

Hi @rpenido, I'd like to merge this into your open PR branch for openedx#34270. Is that ok with you?

Feel free to hit "Squash and Merge" when you're ready.

@rpenido rpenido merged commit f1c806f into rpenido/fal-3621-paste-tags-when-pasting-xblocks-with-tag-data Feb 29, 2024
44 checks passed
@rpenido rpenido deleted the jill/duplicate-tags branch February 29, 2024 03:53
@rpenido
Copy link
Member

rpenido commented Feb 29, 2024

Sure @pomegranited! Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants