edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

refactor: inheritable authoring mixin callbacks for editing & duplication

Open DanielVZ96 opened this issue 2 years ago • 18 comments

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

DanielVZ96 avatar Nov 21 '23 03:11 DanielVZ96

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.

openedx-webhooks avatar Nov 21 '23 03:11 openedx-webhooks

Thanks @DanielVZ96 ! When you're ready for review, let me know.

kdmccormick avatar Nov 21 '23 04:11 kdmccormick

@kdmccormick @Agrendalath ready for review

DanielVZ96 avatar Nov 25 '23 04:11 DanielVZ96

@Agrendalath @kdmccormick thanks for the suggestions. i implemented them all.

DanielVZ96 avatar Nov 30 '23 04:11 DanielVZ96

@Agrendalath thanks for those last comments. fixed them

DanielVZ96 avatar Dec 01 '23 11:12 DanielVZ96

@kdmccormick just making sure you don't forget this :)

DanielVZ96 avatar Dec 09 '23 15:12 DanielVZ96

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!

kdmccormick avatar Dec 11 '23 15:12 kdmccormick

@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.

kdmccormick avatar Dec 11 '23 15:12 kdmccormick

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 avatar Dec 11 '23 15:12 kdmccormick

@kdmccormick hey, do you have any updates so we can move this forward?

DanielVZ96 avatar Feb 09 '24 03:02 DanielVZ96

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 avatar Feb 15 '24 20:02 kdmccormick

@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 avatar Mar 15 '24 20:03 DanielVZ96

@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 avatar Mar 19 '24 20:03 kdmccormick

@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_duplicate alone - 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_duplicate hook in a future PR if there's no remaining use case for it.
  • 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).

bradenmacdonald avatar Mar 20 '24 15:03 bradenmacdonald

@kdmccormick What's left before we can get this PR merged?

bradenmacdonald avatar Jun 07 '24 23:06 bradenmacdonald

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 avatar Jun 10 '24 15:06 kdmccormick

@kdmccormick @bradenmacdonald I think this is finally ready for one last review

DanielVZ96 avatar Jul 08 '24 10:07 DanielVZ96

@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 avatar Jul 09 '24 13:07 bradenmacdonald

@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.

kdmccormick avatar Jul 16 '24 17:07 kdmccormick

@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.

openedx-webhooks avatar Jul 25 '24 17:07 openedx-webhooks

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

edx-pipeline-bot avatar Jul 25 '24 18:07 edx-pipeline-bot

2U Release Notice: This PR has been deployed to the edX production environment.

edx-pipeline-bot avatar Jul 25 '24 19:07 edx-pipeline-bot

2U Release Notice: This PR has been deployed to the edX production environment.

edx-pipeline-bot avatar Jul 25 '24 19:07 edx-pipeline-bot