-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Support static assets when copy/pasting between courses and libraries #35668
Conversation
b23c3bb
to
e61af3e
Compare
That was me :p I don't think it will affect any in-flight work. |
Oh, weird. I thought I remembered it as part of one of his PRs. Ah well, in any case, thanks folks. 😄 |
When copying from a course and pasting into a library, would it not be fairly simple to detect paths of the pattern |
It is, but there are some weird edge cases that I didn't want to play whack-a-mole with in the absence of having a normalized form. For instance:
We need to pass a little more metadata about the asset to the frontend to do this properly, and I just didn't want to try to get that sane by tomorrow. The current setup just gets us to a place where it's no weirder than putting it into that subdirectory manually. |
@ormsbee Given all that, I'm almost wondering if we should namespace the library-imported assets as e.g. |
I guess I'm betting that if we can at least store them in a separated space, we'll have enough metadata information to rationalize this better in the future. |
OK, but is a pseudo-subfolder any more of a more "separated space" than a unique prefix like |
Yeah, it's not great, but I think it's slightly better. |
ad6d66a
to
d6695b0
Compare
@ormsbee Just in case it's confusing you too, this warning:
showed up for me, and it disappeared as soon as I resolved the other pylint violations. You should be able to ignore it. |
@ormsbee when I edit this pasted-in library component: the editor renders the altext instead of the image: could that be this PR, or a frontend-app-authoring issue? |
@kdmccormick: it should be fixed once openedx/frontend-app-authoring#1403 merges |
I was able to create a collision (on the AssetKey level, I believe) by uploading a file to a course named something like Honestly, that's the best behavior I could have hoped for, and I doubt that anyone will name a file like that, so I'm not worried about fixing it for MVP, but I do think it's one of those things that we should go back and try to address later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and verified. Code looks good. Thank you, as always, for the helpful comments.
Yeah, I mentioned this in a slack thread a couple of weeks ago, and I think the conclusion was that we could live with it for now. |
I'm giving this one a rebase @ormsbee |
The XBlockSerializerForLearningCore class existed to account for the differences in how Blockstore and later Learning Core stored OLX. This involved doing things like: * removing the url_name attribute (because it's encoded elsewhere) * special case conversion from <vertical> tags to <unit> * other handling over child definition identifiers Stripping the url_name was moved to the XBlockSerializer superclass because it was useful for copy-paste functionality. The other two are no longer relevant because Learning Core won't internally model a Unit as an XBlock, and the Learning Core XBlock Runtime doesn't support having children.
Co-authored-by: Kyle McCormick <[email protected]>
Co-authored-by: Kyle McCormick <[email protected]>
Co-authored-by: Kyle McCormick <[email protected]>
6598bc4
to
ae75ed5
Compare
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. |
1 similar comment
2U Release Notice: This PR has been deployed to the edX production environment. |
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. |
Background
Enhance copy-paste between Courses and Libraries so that it brings along static assets.
The biggest challenge is dealing with the mismatch between how Libraries store assets (per-Component) and how Courses store assets (global Files and Uploads space). To bridge this, we're going to kludge a component-local namespace in Files and Uploads by making use of the obscure feature that you can create folders there at an API level, even if no such UI exists.
What's in this PR?
Assets work when copy-pasting between library components.
Assets work when copy-pasting from a library to a course, with the convention being to put that file in a subdirectory of the form:
components/{block_type}/{block_id}/file
Example:
Note that this path does not currently show up in the UI for Files and Uploads:
Assets work when copy-pasting from a course to a library
Top level assets are put into a static folder in the Component, per Learning Core conventions:
Limitations
Roundtrips don't work properly. There's no normalized form, so directories will start nesting if you copy from library and paste into course, then copy the pasted thing and paste back into library, etc. This was deemed acceptable for Sumac.
Low level stuff
XBlockSerializerForLearningCore
has been removed, with theurl_name
stripping functionality added as an optional param toXBlockSerializer
(the other stuff was for children and "vertical" -> "unit" conversion, neither of which are relevant now.url_name
is now stripped out of anything added to the clipboard, so that we don't end up writing it inblock.xml
when it is redundant (and would be stripped out with the next write anyway).set_library_block_olx
to return the newComponentVersion.version_num
, and I'm changing it again to return the wholeComponentVersion
because I needed to grab other fields off of it. I fixed the code/tests that I saw, and I only mention this in case you started getting weird errors later while rebasing.