Repository navigation
Conversation
Duplicating a section or subsection in Studio copies every tag to the duplicate, including tags from competency taxonomies. The duplicate has no competency criteria, so the copied competency tag claims a link to the competency that nothing evaluates. A new XBLOCK_DUPLICATED receiver in contentstore queues the task strip_competency_tags_from_duplicate for a duplicated chapter or sequential, once the current transaction commits. The task removes the duplicate's tags from competency taxonomies and leaves its other tags. The tag copy in content_tagging is unchanged. Receivers run in the order they connect, and the removal has to run after the copy when no transaction is open, as in Studio's duplicate request. The handlers module imports the tag copy receiver, and that import connects it before the new receiver. The task keeps a competency tag that a competency criterion references, because deleting the tag would delete a mastery rule the author added to the duplicate while the task was queued. The task runs in one transaction. A database error, or a taxonomy no longer enabled for the organization, is logged with the duplicate's key and leaves the duplicate's tags as they are. A failure to queue the task is logged and does not fail the duplicate request. Related to openedx/openedx-core#808 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Thanks for the pull request, @bsparks! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Submit a signed contributor agreement (CLA)
If you've signed an agreement in the past, you may need to re-sign. Once you've signed the CLA, please allow 1 business day for it to be processed. 🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Description
Supersedes #39392. The commits are the same as on that pull request.
Implements openedx/openedx-core#808: a duplicate of a section or subsection ends up with no competency tags, and keeps every other tag.
Studio's Duplicate action sends
XBLOCK_DUPLICATEDonce for each duplicated block, andcontent_tagging.handlers.duplicate_tagscopies the source block's tags to the duplicate. A competency tag is meant to be backed by a competency criterion, and a duplicate has none, so a copied competency tag claims a link to the competency that nothing evaluates.This PR adds a second receiver of
XBLOCK_DUPLICATED,strip_competency_tags_from_duplicate_handlerincms/djangoapps/contentstore/signals/handlers.py. For a duplicatedchapterorsequentialit queues the new taskstrip_competency_tags_from_duplicatethroughtransaction.on_commit. The task reads the duplicate's tags, finds the competency taxonomies among them withselect_competency_taxonomiesandis_competency_taxonomyfromopenedx_learning.api, and for each one callscontent_tagging.api.tag_objectwith the tags to keep. It keeps only a tag that a competency criterion references, and a fresh duplicate has none.content_taggingis unchanged.Behavior
Testing
pytest cms/djangoapps/contentstore/signals/tests/test_handlers.py -k StripCompetency: the receiver queues the task on commit for a section or subsection, queues nothing for a unit or component, does not fail the commit when the task cannot be queued, and runs after the tag copy when no transaction is open.pytest cms/djangoapps/contentstore/tests/test_tasks.py -k StripCompetency: the task removes the tags of every competency taxonomy, keeps regular tags, keeps a competency tag that a criterion references, and on an error in the second removal logs it and keeps every tag.pytest cms/djangoapps/contentstore/views/tests/test_block.py -k duplicate: duplicating real blocks, including a subsection that has a competency criterion and a request made by a course author without admin rights.Manual testing
Related to openedx/openedx-core#808
🤖 Generated with Claude Code