refactor: Duplicate and update primitives made available.#32058
refactor: Duplicate and update primitives made available.#32058Agrendalath merged 1 commit intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @Kelketek! 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:
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. |
dbbfaf9 to
0e76962
Compare
a8d72ce to
37c788a
Compare
|
@Agrendalath This is ready for another look. |
37c788a to
cb2dfe8
Compare
Agrendalath
left a comment
There was a problem hiding this comment.
👍
- I tested this: checked that duplicating the blocks is still working; checked that this plugin can use new functions
- I read through the code
- I checked for accessibility issues: n/a
- Includes documentation: n/a
- I made sure any change in configuration variables is reflected in the corresponding client's
configuration-securerepository: n/a
a42344c to
98ed1cd
Compare
|
@bradenmacdonald This is ready for you. |
|
@bradenmacdonald Forgot Piotr was a CC and can move this forward-- but heads up on the changes in any case. |
bradenmacdonald
left a comment
There was a problem hiding this comment.
From what I can see, a lot of the diff is just moving some things to separate functions.
So is this what's actually changed?
- Added
shallowtoduplicate_block - Turned
duplicate_blockfrom internal method to public API (should perhaps be moved out of views then?) - Added a new
update_from_sourcepython API, but it's not used by the platform
These functions can be used alongside copy_from_template
So there are three functions, duplicate_block, update_from_source, and copy_from_template. Can you give an example of how you're planning to use them? I feel like it may be a little unclear the differences between them and when/how to decide which to use, so I'd like to see that made clearer within the code/docstrings. I'm also wondering if we need three separate high level APIs when it seems like it's all aiming to do one thing: copy blocks into a destination and update them if they already exist there.
without requiring them to be within any particular container (other than a library or course root)
I was a little confused at first because I thought you meant "without requiring the source block to be in any particular container like a library". But I see you mean "without requiring them to be placed into a library content block or any other "special" parent container".
So my question is: how does the currently available API require the use of a particular container for the destination, and how does this PR remove that requirement?
There was a problem hiding this comment.
Can you please document all these arguments? It doesn't say what shallow or is_child do, nor the purpose of dest_usage_key.
There was a problem hiding this comment.
If this is a python API that you intend to use from other python code and which doesn't itself provide a REST API, it doesn't belong in views/. It should be in api.py or similar. (And maybe it should be in the modulestore code somewhere instead of contentstore? Not really sure on that.) I know the existing code in this file doesn't follow such conventions very clearly, but we can at least not make it worse. OEP-49 for reference.
98ed1cd to
2a7e275
Compare
|
@bradenmacdonald I've addressed a few of your notes and responded to some comments. I've added more to the docstrings to make it clearer when they're to be used. The remaining issue is a much larger one and I'm not sure how to approach it. That issue being 'moving these functions into their own API module', which sounds simple, but there is already an Another alternative would be to place it in the modulestore package. There is not currently an api package in the modulestore, and this seems like an odd place to start-- especially since we didn't make one as part of BD-13. However, it is an option. Another potential option might be to turn these functions into function that live on the modulestore itself, but, oddly enough, there's already a I don't know that any approach is going to be perfect, but I wanted to see if you had any other ideas. Otherwise I'll probably try just moving the functions out of the views to another module, even if it's not named |
|
@Kelketek You're right, this is an older part of the code that's definitely not following the conventions I'm referring to, so it's difficult to integrate with it in that way. I'm actually fine with what you're doing here, though I think that putting it into any file outside of What's important is that it's clear who will be using this method. As it is, if it looks like a helper method in |
2a7e275 to
97a386c
Compare
|
@bradenmacdonald OK-- I think this is ready now. Assuming we don't want to remove the tests for asides, that is-- and it sounds like maybe we don't, since now more than one group is using them and there appears to be no interest in deprecating them. |
97a386c to
d406752
Compare
|
@bradenmacdonald Thanks-- I've rebased this and updated the docstrings you mentioned. |
|
@bradenmacdonald @Agrendalath Now that this is approved, is there anything left to do on my end or can one of you merge this in? |
|
@Kelketek 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
Description
This pull request makes a couple of changes to the xblock handler in the CMS. These changes add a handful of utility functions and modify the existing ones to make reuse of existing blocks easier. With these changes, it is possible to copy an entire section from one course to another, and then later refresh that section, and all of its children, without destroying the blocks next to it.
The existing
_duplicate_blockfunction was modified to have ashallowkeyword to avoid copying children, and theupdate_from_sourcefunction was added to make it easy to copy attributes over from one block to another. These functions can be used alongsidecopy_from_templatein the modulestore to copy over blocks and their children without requiring them to be within any particular container (other than a library or course root)-- thus allowing library-like inclusion without the library content block. This is especially useful for cases like copying sections rather than unit content.The actual code for copying sections into new courses is not included, as the UX for such a feature is not yet decided, but prototypical Django admin functionality is being built in a separate Django app repository.
From the perspective of the user, this PR should change nothing. From the perspective of the developer, it should make things much easier.
Testing instructions
The unit tests should prove this is working correctly and doesn't impact existing functionality. However a companion Django app is being developed which leverages these features and can be made available to test as well.
Deadline
None
Misc
Internal/private-ref: BB-7295