Commit Graph

208 Commits

Author SHA1 Message Date
Agrendalath
9fbc263edd feat: remove block-specific handling from runtime role checks 2023-06-15 11:08:03 +02:00
Kyle McCormick
3fab0aec65 build: import XModule source SCSS directly rather than copying (#32289)
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
2023-06-14 11:30:05 -04:00
Jeremy Ristau
c7559f5697 Merge pull request #32273 from open-craft/field-data-refactor
Make Split Mongo's CachedDescriptorSystem load field-data service on demand
2023-06-13 08:05:49 -04:00
Kyle McCormick
cef8c062a2 build: stop suffixing XModule SCSS with hashes (#32288)
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
2023-06-07 09:26:08 -04:00
Ben Warzeski
2df14a8718 feat: add public video url copy interface (#32293) 2023-06-06 10:09:48 -04:00
Kyle McCormick
585b96583a build: remove prefixes from XModule resource copies (#32287)
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
2023-06-05 09:10:58 -04:00
Braden MacDonald
aa68ea1162 chore: Update with latest master 2023-05-31 16:25:35 -07:00
Braden MacDonald
d44ca41410 docs: clarify comment that I had added earlier 2023-05-31 16:14:05 -07:00
Braden MacDonald
dac1c5abe1 refactor: we don't need _unwrapped_field_data any more 2023-05-29 15:27:12 -07:00
Braden MacDonald
6dd9d2e068 fix: some tests still use old mongo and weren't passing 2023-05-29 13:50:47 -07:00
Braden MacDonald
fbaa2e5a68 fix: make the initialization more like how it was in the past 2023-05-27 15:56:02 -07:00
Braden MacDonald
018f8f2c7c fix: Apparently block.scope_ids gets mutated a lot and isn't a good key
-> 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
2023-05-26 11:16:13 -07:00
Braden MacDonald
f13263df4f fix: remove the need to patch the KVS during library import 2023-05-25 21:03:01 -07:00
Braden MacDonald
9f5f3108a0 fix: cleanups and bug fix from review 2023-05-25 16:33:40 -07:00
Agrendalath
15b511ffd1 test: fix the number of Mongo calls 2023-05-25 20:11:02 +02:00
Kyle McCormick
0f847df73a refactor: define resource paths (not contents) on XModule classes (#32286)
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
2023-05-25 13:30:39 -04:00
Fox Piacenti
aa7370c773 refactor: Duplicate and update primitives made available.
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.
2023-05-25 15:58:28 +02:00
Diana Huang
bbb1fdbdf1 fix: Fix split test event logging. (#32299)
In a refactor, this call to runtime.publish didn't
actually match the API properly, causing runtime errors
on LMS.
2023-05-24 11:51:11 -04:00
Braden MacDonald
30e7b5b92b temp: continue 2023-05-23 16:53:14 -07:00
Braden MacDonald
1c09f6c3ef temp: clarify why we don't pass field_data to constructor 2023-05-23 10:54:23 -07:00
Braden MacDonald
f05f48a156 temp: continued 2023-05-19 15:41:49 -07:00
Braden MacDonald
2924e564b0 fix: field data should be loaded on-demand, not pushed into block init 2023-05-19 13:55:25 -07:00
Edward Zarecor
2f44415eba Merge pull request #32099 from open-craft/navin/fix-video-transcripts 2023-05-18 14:29:34 -04:00
nsprenkle
1839bc01c6 feat: update text for sharing to Twitter
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
2023-05-18 13:51:51 -04:00
Leangseu Kim
f72d27c6af chore: remove studio check
chore: remove duplicate code

chore: update get_public_video_url because reverse doesn't work on cms
2023-05-18 13:08:01 -04:00
Andrey Cañon
516eff0633 Decouple XModule styles from LMS/Studio styles (attempt 3) (#32237)
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
2023-05-18 09:00:44 -04:00
Syed Ali Abbas Zaidi
d7053a6783 fix: eslint autofixable issues (#32181)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* fix: failing js test
2023-05-18 11:03:59 +05:00
Navin Karkera
a06c9b17be fix: update transcripts field in video on upload 2023-05-12 18:36:59 +05:30
Syed Ali Abbas Zaidi
adf879e8b2 Revert "fix: all auto fixable eslint issues (#31900)" (#32203)
This reverts commit 228180b1ef.
2023-05-09 13:53:54 +05:00
Syed Ali Abbas Zaidi
228180b1ef fix: all auto fixable eslint issues (#31900)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint prefer template issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue
2023-05-09 11:57:15 +05:00
Piotr Surowiec
9d9bd63926 Merge pull request #32177 from open-craft/braden/fix-warnings
Fix some warnings from usage of deprecated properties
2023-05-08 16:04:28 +02:00
Kyle McCormick
05487e9279 Revert "Decouple XModule styles from LMS/Studio styles (attempt 2) (#32188)" (#32191)
This reverts commit c34f8efc0e.
2023-05-05 15:06:32 -04:00
Andrey Cañon
c34f8efc0e Decouple XModule styles from LMS/Studio styles (attempt 2) (#32188)
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
2023-05-05 10:02:18 -04:00
Nathan Sprenkle
6307961ff6 fix: video share link fixes (#32187)
* fix: remove outdated click handler in social share

* fix: reestablish blank target of social share link

* test: update js tests
2023-05-04 16:29:47 -04:00
connorhaugh
b9be2b1e56 Revert "build: Decouple XModule styles from LMS/Studio styles (#32018)" (#32183)
This reverts commit 471ba9121b.
2023-05-04 09:59:15 -04:00
jansenk
4de07c25d0 refactor: video sharing js
test: add testing for VideoSocialSharingHandler

test: fix context tests

refactor: move most link logic to django

chore: update python test

chore: update linting
2023-05-04 09:33:16 -04:00
Andrey Cañon
471ba9121b build: Decouple XModule styles from LMS/Studio styles (#32018)
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
2023-05-04 08:21:09 -04:00
Braden MacDonald
ab21376b7d fix: use correct stacklevel for deprecation warnings, warn only on read
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)
2023-05-03 12:35:19 -07:00
Braden MacDonald
0ff65c2b9f chore: fix usage of runtime.course_id
/openedx/edx-platform/xmodule/modulestore/mongo/base.py:275: DeprecationWarning: `runtime.course_id` is deprecated. Use `context_key` instead: `block.scope_ids.usage_id.context_key`.
    metadata_inheritance_tree = self.modulestore._compute_metadata_inheritance_tree(self.course_id)
2023-05-03 12:35:19 -07:00
Nathan Sprenkle
745cda1580 feat: course overrides of video sharing settings (#32169)
* 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.
2023-05-03 13:23:34 -04:00
Syed Ali Abbas Zaidi
f1fb38ed83 fix: multi lines and spaces issues (#31885)
* fix: multi lines and spaces issues

* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: remaining quotes issues

* fix: eslint object curly newline issue

* fix: eslint object curly spacing issue

* fix: eslint brace-style issues

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint linbreak style issue

* fix: eslint space unary operator issue

* fix: eslint line around directives issue

* fix: void and typeof space unary ops issue
2023-05-03 12:22:46 +05:00
Leangseu Kim
0dc881e25a feat: course level public sharing video options
feat: add video sharing option field course field

chore: add social sharing document url

chore: add course check because library also using this
2023-05-02 14:57:25 -04:00
Agrendalath
aa85257b19 fix: use student-specific anonymous IDs in CAPA and HTML XBlocks
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.
2023-05-02 17:58:22 +02:00
Braden MacDonald
8ee1f66ffb feat: Paste Components (OLX) into any Unit in Studio (#31969)
* 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
2023-04-27 09:58:04 -07:00
Andrey Cañon
f8e2363e10 feat: move general imports to specific scss files (#32121)
This moves XModule scss imports to the specific files where they are required instead of
having a common XModule scss import list.

This is part of  https://github.com/openedx/edx-platform/issues/31624
2023-04-27 10:38:04 -04:00
Pooja Kulkarni
1950949c9e refactor: rename descriptor -> block within remaining xmodule
Co-authored-by: Agrendalath <piotr@surowiec.it>
2023-04-26 17:10:54 +02:00
Pooja Kulkarni
ce94d896cf refactor: rename descriptor -> block within xmodule/tests
Co-authored-by: Agrendalath <piotr@surowiec.it>
2023-04-26 17:10:54 +02:00
Pooja Kulkarni
537cfe4e0f refactor: rename descriptor -> block within xmodule/modulestore
Co-authored-by: Agrendalath <piotr@surowiec.it>
2023-04-26 17:10:54 +02:00
Nathan Sprenkle
df6a60b0e0 feat: video share icons (#32111)
* 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
2023-04-24 10:04:03 -04:00
Agrendalath
c74f3825e8 test: remove only_xmodules
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`.
2023-04-21 11:53:49 +02:00