-
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
Enable static assets in Learning Core XBlock Runtime #35660
Conversation
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.
Seems to be working well with the test content I have :)
block_version = block._runtime_requested_version # pylint: disable=protected-access | ||
if block_version == LatestVersion.DRAFT: | ||
component_version = component.versioning.draft | ||
elif block_version == LatestVersion.PUBLISHED: | ||
component_version = component.versioning.published | ||
else: | ||
component_version = component.versioning.version_num(block_version) | ||
|
||
return component_version |
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.
Do you think it makes sense to combine this with the similar logic in get_block()
?
edx-platform/openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Lines 183 to 193 in ecbedbc
if self.authored_data_mode == AuthoredDataMode.STRICTLY_PUBLISHED and version != LatestVersion.PUBLISHED: | |
raise ValidationError("This runtime only allows accessing the published version of components") | |
if version == LatestVersion.DRAFT: | |
component_version = component.versioning.draft | |
elif version == LatestVersion.PUBLISHED: | |
component_version = component.versioning.published | |
else: | |
assert isinstance(version, int) | |
component_version = component.versioning.version_num(version) | |
if component_version is None: | |
raise NoSuchUsage(usage_key) |
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.
I'm kind of on the fence about it. When I took a brief sketch at extracting out the common part here, the helper naming and indirection just seemed to add more confusion than it was worth. I don't feel strongly about it, but I'm inclined to just leave the bit of redundancy.
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.
Fine with me!
openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Outdated
Show resolved
Hide resolved
openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py
Outdated
Show resolved
Hide resolved
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.
2ba2a77
to
2e8d733
Compare
Add support for displaying static assets in the Learing Core XBlock runtime via "/static/asset-name" style substitutions in the OLX. This is currently used for new Content Library components. Static asset display is version-aware, so viewing older versions of the XBlock content via the embed view will show the appropriate assets for that version.
Per OEP-49, both api.py and data.py are allowed to be imported into other apps: https://open-edx-proposals.readthedocs.io/en/latest/best-practices/oep-0049-django-app-patterns.html#api-py
f2cad1c
to
95c4e69
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. |
Description
This enable the viewing of static assets in the Learning Core XBlock Runtime. It is version aware, so
calling the XBlock iframe with different versions will properly reflect the right assets for that
version of the Component.
Implements #35659
It does not currently support adding assets, and that must still be done via the
add_assets_to_component
management command.
Copy-paste functionality will be a separate PR.