refactor: inheritable authoring mixin callbacks for editing & duplication
Description
Instead of applying duplicated logic after getattr, that logic is incorporated into inheritable methods of the StudioEditable block. Should not affect other roles besides developers.
Supporting information
Resolves https://github.com/openedx/edx-platform/issues/33715
Testing instructions
Courses:
- Log into CMS and go to Any Course
- Duplicate any Section
- Make sure the Section is duplicated with all its children
Libraries:
- Navigate to the libraries tab
- Create a new library
- Try adding, editing and duplicating a text, a video, and a problem component
- Make sure all student previews are correctly displayed
Deadline
None
Thanks for the pull request, @DanielVZ96! Please note that it may take us up to several weeks or months to complete a review and merge your PR.
Feel free to add as much of the following information to the ticket as you can:
- supporting documentation
- Open edX discussion forum threads
- timeline information ("this must be merged by XX date", and why that is)
- partner information ("this is a course on edx.org")
- any other information that can help Product understand the context for the PR
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.
Please let us know once your PR is ready for our review and all tests are green.
Thanks @DanielVZ96 ! When you're ready for review, let me know.
@kdmccormick @Agrendalath ready for review
@Agrendalath @kdmccormick thanks for the suggestions. i implemented them all.
@Agrendalath thanks for those last comments. fixed them
@kdmccormick just making sure you don't forget this :)
Thanks @DanielVZ96 . Your code looks good to me.
Through no fault of your own, we're currently wading through a couple different bugs around Library Content duplication and copying (one that we believe we've fixed, and another the we haven't yet). In light of that, I'd like to hold off on merging this refactoring until both bugs are solidly resolved.
From your end, feel free to consider this "Done", and I can take care of rebasing and merging it when we're ready. Thanks for your patience!
@mphilbrick211 This PR is all set from the author side, but is blocked by some related work. I'll rebase & merge when it's unblocked.
FYI @bradenmacdonald -- this PR refactors the code that we are thinking of mirroring for copy-paste. In particular, it puts the callbacks into the class hierarchy rather than using getattr. I was going to wait until we land the copy-paste fix before merging this, but feel free to merge this first if you'd like.
@kdmccormick hey, do you have any updates so we can move this forward?
I'll come back and re-review this once https://github.com/openedx/edx-platform/pull/34066 and https://github.com/openedx/XBlock/pull/718 merge, which I think should take about a week.
@kdmccormick hey, just to be sure, one of the PRs is merged, but the other one is stale since like 3 weeks ago. do you have an updated eta?
@DanielVZ96 I just managed to merge the second one today--phew.
@bradenmacdonald Once we store the upstreams and defaults of LibraryContentBlock children, we should be able to copy-paste and duplicate LibraryContentBlocks just like any other XBlock. So, it seems like we would no longer need a studio_duplicate hook--we could just delete it after implementing the linked ADR, right?
If that sounds right to you, do you agree that this PR should leave studio_duplicate alone, but still add declarations for the editor_saved and post_editor_saved hooks?
@kdmccormick We [will] still need the XBLOCK_DUPLICATED event for duplicating the tags, since we won't be storing the tags in the OLX, but we won't need to call any method like studio_post_duplicate on the XBlock instances themselves.
I'm in favor of:
- Leaving
studio_duplicatealone - I don't think that sort of code belongs in the XBlock but rather the runtime, where it already was. - Possibly removing the
studio_post_duplicatehook in a future PR if there's no remaining use case for it. - Keep the new declarations for the
editor_savedandpost_editor_savedhooks that this PR is adding (assuming there are good use cases for them).
@kdmccormick What's left before we can get this PR merged?
Leaving studio_duplicate alone - I don't think that sort of code belongs in the XBlock but rather the runtime, where it already was.
Agreed, please revert the studio_duplicate changes from this PR. Sorry for sending you that direction @DanielVZ96 , that was poor architectural advice on my part.
Possibly removing the studio_post_duplicate hook in a future PR if there's no remaining use case for it.
I believe there will be no remaining use cases once this ADR is implemented, so it would be good to then remove the hook. I'll add that to the running list of content libraries cleanup items.
Keep the new declarations for the editor_saved and post_editor_saved hooks that this PR is adding (assuming there are good use cases for them).
Agreed. These are a nice improvement.
@kdmccormick @bradenmacdonald I think this is finally ready for one last review
@DanielVZ96 Those changes look good to me! Do we have an XBlock that's ready to use these new APIs? I just don't want to merge without a concrete use case.
@bradenmacdonald editor_saved is already used by SplitTestBlock and VideoBlock. post_editor_saved is used by the (legacy) LibraryContentBlock. This PR just formalizes the methods into the CMS XBlock inheritance hierarchy (well, kinda-- it's as formal as we can get with the XBlockMixin system).
For what it's worth, I don't see this as a public API, just a formalization of an internal edx-platform API.
@DanielVZ96 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.
2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.
2U Release Notice: This PR has been deployed to the edX production environment.
2U Release Notice: This PR has been deployed to the edX production environment.