The `xmodule_assets` command copies SCSS source files from
xmodule/css to common/static/xmodule/scss, renaming them
to `{MD5_HASH}.scss` in order to "remove duplicates".
The copied files are then included into the generated
SCSS entrypoint files (eg AnnotatableBlockStudio.scss).
The "de-deplication" is completely unnecessary: there are
only a couple dozen SCSS files, and none of them are duplicates.
This copying process is confusing, it complicates our
build process, and it makes our SCSS harder to understand.
So, in the generated SCSS entrypoint files, we
stop importing the *copied* SCSS sources, and just
import the *original* SCSS sources instead.
For example, common/static/xmodule/descriptors/scss/AboutBlockStudio.scss
is changed from:
.xmodule_edit.xmodule_AboutBlock {
@import "9bdcda00f046f78be79aca7791e1d4fb.scss";
@import "a10fc3e0fd6aca63426a89e75fe69c31.scss";
}
to:
.xmodule_edit.xmodule_AboutBlock {
@import "editor/edit.scss";
@import "html/edit.scss";
}
In order to make the `@import` lines work, we add xmodule/css to the list
of lookup dirs for XModule SCSS compilation. We also remove the
copying logic from `xmodule_assets`, as it is no longer needed.
Part of: https://github.com/openedx/edx-platform/issues/32292
Similar to https://github.com/openedx/edx-platform/pull/32287,
this change removes another unnecessary step from the
`xmodule_assets` script. The script, which generates XModule
SCSS "entrypoint" files (synthesizing one or more "source" SCSS
resources), was appending MD5 hashes to each SCSS entrypoint filename:
common/static/xmodule/descriptors/scss:
AboutBlockStudio.768623f4d8d73dfb637fc94583adb990.scss
...
WordCloudBlockStudio.d41d8cd98f00b204e9800998ecf8427e.scss
common/static/xmodule/modules/scss:
AboutBlockPreview.05a6cbd5c10100a245fa2cbf151b9770.scss
...
WordCloudBlockPreview.7b899a56a70d29c58cf14b7e1888a0ec.scss
It's unclear why these MD5 hashes needed to be appended.
A comment in xmodule/static_content.py hints that it might have
something to do with de-duplication, but that doesn't make any sense,
because each XModule has exactly two SCSS entrypoint files (one for
studio_view and one for other student/author_views) and none of those
entrypoint files can possibly be shared between XModules.
Soon, as part of deleting the `xmodule_assets` script,
we would like to just check these SCSS files into version control
rather than generating them. In order to do that, we will need to
drop the hashes. This commit does that.
The new output looks like this:
common/static/xmodule/descriptors:
AboutBlockStudio.scss
...
WordCloudBlockStudio.scss
common/static/xmodule/modules:
AboutBlockPreview.scss
...
WordCloudBlockPreview.scss
Part of: https://github.com/openedx/edx-platform/issues/32292
The `xmodule_assets` command copies SCSS files from
xmodule/css to common/static/xmodule/{modules|descriptors}/scss.
It renames the files to the format:
_{INDEX}-{HASH}.scss
where an XModule's first SCSS resource will have INDEX==0,
the next will have INDEX==1, ...and that's it because no
XModule has more than two SCSS resources.
The output looks like this:
common/static/xmodule/descriptors/scss:
_000-808fcbb4c5109c5156ae3c0c9729c8be.scss
...
_001-a10fc3e0fd6aca63426a89e75fe69c31.scss
common/static/xmodule/modules/scss:
_000-1ad2f05db822d3176affd203d70319c0.scss
...
_001-482ebc752ab6e41946651ceb0f3e7f55.scss
These indexes serve no purpose. Reading the comments
and git-blame in xmodule/static_content.py, one can glean
that the indexes might have been intended to enforce
dependency relationships between the assets, but
this is unnecessary, because the ordering of the copied
SCSS is *already preserved* by the order which they're
included into the `{BLOCK_NAME}{Studio|Preivew}.{HASH}.scss`
SCSS entrypoint files. I have to assume that this is an
unnecessary relic from the time when the XModule system
was more heavily utilized, rather than just a legacy corner
of the XBlock framework as it is today.
So, we remove the indexes, which lets us simplify the logic
of xmodule/static_content.py. This is a minor refactoring, but it'll
make it easier for the next steps on our way to deleting
xmodule/static_content.py entirely. The new output looks like this:
common/static/xmodule/descriptors/scss:
_808fcbb4c5109c5156ae3c0c9729c8be.scss
...
_d41921b4c5d45188759ef3d04fd9a78a.scss
common/static/xmodule/modules/scss:
_1ad2f05db822d3176affd203d70319c0.scss
...
_b80300e1a5f290f6a850e35874068427.scss
Part of: https://github.com/openedx/edx-platform/issues/32292
-> bind_for_student() and friends change the user_id
-> DraftVersioningModuleStore.update_item() mutates .location which mutates scope_ids.def_id and scope_ids.usage_id in a way that seems totally wrong
For the XBlocks types that use legacy XModule-style assets (specifically, those that
inherit from `HTMLSnippet`), this is small refactor that brings them a bit closer to being like
standard XBlocks.
Given these class attributes:
class SomeXModuleLikeBlock(..., HTMLSnippet, ...):
...
studio_view_css = { ... }
preview_view_css = { ... }
studio_view_js = { ... }
preview_view_js = { ... }
...
we make it so their values are *paths to the resources*
rather than *the actual content of the resources*.
This is a no-op change, but it'll enable future XModule
asset refactorings which require us to operate on asset
paths rather than contents.
Part of: https://github.com/openedx/edx-platform/issues/32292
This 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_block function was modified to have a shallow keyword
to avoid copying children, and the update_from_source function was added to
make it easy to copy attributes over from one block to another. These functions
can be used alongside copy_from_template in 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.
Updated logic to include organization info, when available. Also
refactored away some no-longer-relevant code and pulled Twitter handle
from config.
style: add missing newline
fix: fix outdated signature in test
refactor: make organization optional arg
Required to fix some tests
style: fix pylint issues
chore: organization is a dict change the accessor + linting
This basically changes how the xmodule static files are
generated and consumed in order to separate the Xblock
styles from general style files. Includes:
* build: decople XModule style assets by using a custom webpack loader
* build: move scss imports to its specific file
* build: fix: add system dirs to theme lookup paths. (fixes attempt 1)
* build: fix: use bootstrap variables instead of lms variables (fixes attempt 2)
This is an amendment to #32188,
which itself was an amendment to #32018.
Addressing the issue https://github.com/openedx/edx-platform/issues/31624
This basically changes how the xmodule static files are
generated and consumed in order to separate the Xblock
styles from general style files. Includes:
* build: decople XModule style assets by using a custom webpack loader
* build: move scss imports to its specific file
* build: fix: add system dirs to theme lookup paths.
This is an amendment to #32018
Addressing the issue #31624
test: add testing for VideoSocialSharingHandler
test: fix context tests
refactor: move most link logic to django
chore: update python test
chore: update linting
This basically changes how the xmodule static files are
generated and consumed in order to separate the Xblock
styles from general style files. Includes:
* build: decople XModule style assets by using a custom webpack loader
* build: move scss imports to its specific file
Addressing the issue https://github.com/openedx/edx-platform/issues/31624
Writing to the deprecated props is just to enable backwards compatibility (for now), so shouldn't be a warning.
Reading from them is the problematic thing that we need to warn about and fix.
Also, the stacklevel was wrong, resulting in unhelpful warnings like this:
/openedx/edx-platform/xmodule/x_module.py:1486: DeprecationWarning: `runtime.course_id` is deprecated. Use `context_key` instead: `runtime.scope_ids.usage_id.context_key`.
block = self.load_item(usage_id, for_parent=for_parent)
/openedx/venv/lib/python3.8/site-packages/django/test/utils.py:387: DeprecationWarning: runtime.anonymous_student_id is deprecated. Please use the user service instead.
return func(*args, **kwargs)
/opt/pyenv/versions/3.8.12/lib/python3.8/unittest/case.py:633: DeprecationWarning: runtime.anonymous_student_id is deprecated. Please use the user service instead.
method()
/opt/pyenv/versions/3.8.12/lib/python3.8/unittest/case.py:633: DeprecationWarning: runtime.cache is deprecated. Please use the cache service instead.
method()
/openedx/venv/lib/python3.8/site-packages/django/test/utils.py:387: DeprecationWarning: runtime.can_execute_unsafe_code is deprecated. Please use the sandbox service instead.
return func(*args, **kwargs)
* refactor: public sharing enabled toggle
Cherry-picked from https://github.com/openedx/edx-platform/pull/32150
* feat: course video share setting on video block
Adds awareness of course.video_sharing_options setting to video XBlock.
This can override whether or not sharing is enabled for a video or fall
back to per-video settings
* test: course video share setting on video block
Adds awareness of course.video_sharing_options setting to video XBlock.
This can override whether or not sharing is enabled for a video or fall
back to per-video settings
* test: course video share setting on preview page
Extends checking for course override of video share settings to public
video preview page.
After changes from #31472, the user service of a "leaf" XBlock gets overridden
with the one created for its parent (SequenceBlock). Therefore, the
`requires_per_student_anonymous_id` is ignored in these XBlocks. The
subsequent renders of an XBlock (e.g., when requesting the solution) use
the student-specific IDs.
This removes choosing the proper ID (course-specific or student-specific) from
the runtime initialization. Instead, both IDs are passed to the user service.
There are only two XBlocks that relied on the
`requires_per_student_anonymous_id` - `ProblemBlock` and `HtmlBlock`. They
now request the "deprecated" (student-specific) user ID directly from the user
service.
* feat: Implement paste button
* chore: improve docs and add tests for python API
* fix: drive-by fix to use a better API for comparing XML
* feat: track which XBlock something was copied from
* feat: add tests
* feat: enable import linter so content_staging's public API is respected
* fix: error seen when trying to paste drag-and-drop-v2 blocks
* fix: use strip_text=True consistently for XML comparisons
* refactor: rename get_user_clipboard_status to get_user_clipboard
* feat: Better error reporting when pasting in Studio
* chore: convert new test suite to pytest assertions
* refactor: push READY status check into the API per review suggestion
* fix: use strip_text=True consistently for XML comparisons
* fix: store "copied_from_block" as a string to avoid Reference field issues
* fix: minor lint error
* refactor: move data types to data.py per OEP-49
* feat: replace video share links with icons
* feat: add download / share icons to video block
* feat: consistent styling for transcript links
* feat: change order of download/share for videos
This function was only used by tests. It was breaking tests from the `xmodule`
package on the devstack because the dist.key of its entry_points is `open-edx`.