Commit Graph

85 Commits

Author SHA1 Message Date
Kyle McCormick
9c6e765bf6 test: run ./xmodule/ tests with CMS settings (#33534)
Currently, ./xmodule/ unit tests are only run with LMS settings. However,
./common/ and ./xmodule/ are run twice: once with LMS settings and once with
CMS settings.

Just like ./common/ and ./openedx/, the unit tests in ./xmodule/ validate
behavior in both LMS and CMS. So, order to fully test ./xmodule/, we should to
run its tests with CMS settings too.

This will enable us to better validate certain LibraryContentBlocks behaviors
being touched by https://github.com/openedx/edx-platform/pull/33263 which can't
be expressed under LMS settings.

Also in this commit:

* refactor: rename the shards to be clear whether they're running under LMS or CMS
* docs: correct comments regarding conditions under which codejail's
   test_cant_do_something_forbidden is skipped.
* test: update a unit test which was using the now-deleted library_sourced block to use
   library_content block instead.
2023-10-19 10:19:28 -04:00
IrfanUddinAhmad
e003217d51 fix: Added xblock skill tag verification waffle switch 2023-10-04 14:28:39 +05:00
Kyle McCormick
265701c01d feat!: remove library_sourced block (#33257)
Originally, we planned to add support for V2 libraries and for static
(hand-selected) library block reference via new block type: library_sourced.

We have since decided that it would be better to add those capabilities
in-place to the existing library_content block. This will ease V1->V2
library migration and make adoption of the new features easier for current
library users. It will also avoid duplication of logic between two block types,
we we fear would be error-prone. For details, see this ADR:
 https://github.com/openedx/edx-platform/pull/33231

So, we are removing the library_sourced block.
This block has existed in edx-platform for a few years now, but was not
enabled by default and never officially supported. It was only usable via the
experimental V2 content library feature. Operators who added library_sourced
blocks to their course will now see them render as `HiddenBlock` instances, i.e.:

> ERROR: "library_sourced" is an unknown component type...

This should not impact other component types in such courses and should not
impact import/export.
2023-09-15 10:04:38 -04:00
salmannawaz
648a30249a Deprecation of edx-user-state-client repo (#33218)
* chore: add code for edx-user-state-client in edx-platform
2023-09-14 18:53:37 +05:00
Sagirov Evgeniy
c5d1807c81 feat!: remove most Old Mongo functionality (#31134)
This commit leaves behind just enough Old Mongo (DraftModulestore)
functionality to allow read-only access to static assets and the
root CourseBlock. It removes:

* create/update operations
* child/parent traversal
* inheritance related code

It also removes or converts tests for this functionality.

The ability to read from the root CourseBlock was maintained for
backwards compatibility, since top-level course settings are often
stored here, and this is used by various parts of the codebase,
like displaying dashboards and re-building CourseOverview models.

Any attempt to read the contents of a course by getting the
CourseBlock's children will return an empty list (i.e. it will look
empty).

This commit does _not_ delete content on MongoDB or run any sort of
data migration or cleanup.
2023-09-06 10:01:31 -04:00
Braden MacDonald
f491f5bde8 fix: refactor MakoService to allow specifying template more explicitly (Take 2) (#33077)
* fix: refactor MakoService to allow specifying namespace per template (#33061)

* fix: instr. dashboard broken by bulk email reusing HtmlBlock studio_view

* fix: lint issue from unused import
2023-08-23 11:48:06 -07:00
Eugene Dyudyunov
4340a832f7 Add the default enrollment start date on course creation (#30954)
* fix: main page course listing

The course is visible on the main page right after creation when the feature toggle `CREATE_COURSE_WITH_DEFAULT_ENROLLMENT_START_DATE` is on.

So anonymous users can see them and access the course about page
for the courses without valid data (e.g. they will see the default
course overview)

When courses list filtering is processed it checks the `see_exists`
permission for the anonymous user.
Actually, `see_exists` means `can_load` OR `can_enroll`.

`can_load` is False in our case because the course start in the future.

But `can_enroll` returns True because the course's enrollment_start
and enrollment_end dates are blank:
```
enrollment_start = courselike.enrollment_start or datetime.min.replace(tzinfo=UTC)
enrollment_end = courselike.enrollment_end or datetime.max.replace(tzinfo=UTC)
if enrollment_start < now < enrollment_end:
    debug("Allow: in enrollment period")
    return ACCESS_GRANTED
```

Set the enrollment_start the same as a course start by default
2023-08-22 10:42:19 -04:00
bszabo
68e9a03708 Revert "fix: refactor MakoService to allow specifying namespace per template (#33061)" (#33070)
This reverts commit d60cdc2305.
2023-08-21 16:32:58 -04:00
Braden MacDonald
d60cdc2305 fix: refactor MakoService to allow specifying namespace per template (#33061) 2023-08-21 10:05:38 -07:00
Kyle McCormick
9d4163d31f build: include built-in XBlock JS directly rather than copying it (#32480)
As part of the static asset build, JS modules for most built-in XBlocks were
unnecessarily copied from the original locations (under xmodule/js and
common/static/js) to a git-ignored location (under common/static/xmodule), and
then included into the Webpack builld via
common/static/xmodule/webpack.xmodule.config.js.

With this commit, we stop copying the JS modules. Instead, we have
common/static/xmodule/webpack.xmodule.config.js just reference the original
source under xmodule/js and common/static/js.

This lets us us radically simplify the xmodule/static_content.py build script.
It also sets the stage for the next change, in which we will check
webpack.xmodule.config.js into the repository, and delete
xmodule/static_content.py entirely.

common/static/xmodule/webpack.xmodule.config.js before:

    module.exports = {
        "entry": {
            "AboutBlockDisplay": [
                "./common/static/xmodule/modules/js/000-b82f6c436159f6bc7ca2513e29e82503.js",
                "./common/static/xmodule/modules/js/001-3ed86006526f75d6c844739193a84c11.js",
                "./common/static/xmodule/modules/js/002-3918b2d4f383c04fed8227cc9f523d6e.js",
                "./common/static/xmodule/modules/js/003-b3206f2283964743c4772b9d72c67d64.js",
                "./common/static/xmodule/modules/js/004-274b8109ca3426c2a6fde9ec2c56e969.js",
                "./common/static/xmodule/modules/js/005-26caba6f71877f63a7dd4f6796109bf6.js"
            ],
            "AboutBlockEditor": [
                "./common/static/xmodule/descriptors/js/000-b82f6c436159f6bc7ca2513e29e82503.js",
                "./common/static/xmodule/descriptors/js/001-19c4723cecaa5a5a46b8566b3544e732.js"
            ],
            // etc
        }
    };

common/static/xmodule/webpack.xmodule.config.js after:

    module.exports = {
        "entry": {
            "AboutBlockDisplay": [
                "./xmodule/js/src/xmodule.js",
                "./xmodule/js/src/html/display.js",
                "./xmodule/js/src/javascript_loader.js",
                "./xmodule/js/src/collapsible.js",
                "./xmodule/js/src/html/imageModal.js",
                "./xmodule/js/common_static/js/vendor/draggabilly.js"
            ],
            "AboutBlockEditor": [
                "./xmodule/js/src/xmodule.js",
                "./xmodule/js/src/html/edit.js"
            ],
            // etc
        }
    };

Part of: https://github.com/openedx/edx-platform/issues/32481
2023-07-26 13:27:38 -04:00
Agrendalath
92b684004e refactor: reuse services and wrappers between XBlocks (fixed)
This re-applies commit 36cc415 with handling an invalid context_key in the
`PartitionService`. It can happen when rendering a `LibraryContentBlock` in
Studio because this service is initialized by the modulestore when validating
an XBlock to gather its error messages in the `studio_xblock_wrapper`.
2023-07-19 18:01:59 +02:00
Piotr Surowiec
c6bd98e51a Revert "refactor: reuse services and wrappers between XBlocks" (#32730)
This reverts commit 36cc415fc2.
2023-07-13 10:05:34 -04:00
Kyle McCormick
127c5c1ce2 fix: make built-in XBlock Sass theme-aware again
In ~Palm and earlier, all built-in XBlock Sass was included into LMS and CMS
styles before being compiled. The generated CSS was coupled together with
broader LMS/CMS CSS. This means that comprehensive themes have been able to
modify built-in XBlock appearance by setting certain Sass variables. We say that
built-in XBlock Sass was, and is expected to be, "theme-aware".

Shortly after Palm, we decoupled XBlock Sass from LMS and CMS Sass [1]. Each
built-in block's Sass is now compiled into two separate CSS targets, one for
block editing and one for block display. The CSS, now located at
`common/static/css/xmodule`, is injected into the running Webpack context with
the new `XModuleWebpackLoader`. Built-in XBlocks already used
`add_webpack_to_fragment` in order to add JS Webpack bundles to their view
fragments, so when CSS was added to Webpack, it Just Worked.

This unlocked a slieu of simplifications for static asset processing [2];
however, it accidentally made XBlock Sass theme-*unaware*, or perhaps
theme-confused, since the CSS was targeted at `common/static/css/xmodule`
regardless of the theme. The result of this is that **built-in XBlock views will
use CSS based on the Sass variables _last theme to be compiled._** Sass
variables are only used in a handful of places in XBlocks, so the bug is subtle,
but it is there for those running off of master. For example, using edX.org's
theme on master, we can see that there is a default blue underline in the Studio
sequence nav [3]. With this bugfix, it becomes the standard edX.org
greenish-black [4].

This commit makes several changes, firstly to fix the bug, and secondly to leave
ourselves with a more comprehensible asset setup in the `xmodule/` directory.

* We remove the `XModuleWebpackLoader`, thus taking built-in XBlock Sass back
  out of Webpack.

* We compile XBlock Sass not to `common/static/css/xmodule`, but to:

  * `[lms|cms]/static/css` for the default theme, and
  * `<THEME_ROOT>/[lms|cms]/static/css`, for any custom theme.

  This is where the comprehensive theming system expects to find themable
  assets. Unfortunately, this does mean that the Sass is compiled twice, both
  for LMS and CMS. We would have liked to compile it once to somewhere in the
  `common/`, but comprehensive theming does not consider `common/` assets to be
  themable.

* We split `add_webpack_to_fragment` into two more specialized functions:
  * `add_webpack_js_to_fragment` , for adding *just* JS from a Webpack bundle,
    and
  * `add_sass_to_fragment`, for adding static links to CSS compiled themable
    Sass (not Webpack). Both these functions are moved to a new module
    `xmodule/util/builtin_assets.py`, since the original module
    (`xmodule/util/xmodule_django.py`) didn't make a ton of sense.

* In an orthogonal bugfix, we merge Sass `CourseInfoBlock`, `StaticTabBlock`,
  `AboutBlock` into the `HtmlBlock` Sass files. The first three were never used,
  as their styling was handled by `HtmlBlock` (their shared parent class).

* As a refactoring, we change Webpack bundle names and Sass module names to be
  less misleading:
  * student_view, public_view, and author_view: was `<Name>BlockPreview`, is now
    `<Name>BlockDisplay`.
  * studio_view: was `<Name>BlockStudio`, is now `<Name>BlockEditor`.

* As a refactoring, we move the contents of `xmodule/static` into the existing
  `xmodule/assets` directory, and adopt its simper structure. We now have:
  *  `xmodule/assets/*.scss`: Top-level compiled Sass modules. These could be
     collapsed away in a future refactoring.
  * `xmodule/assets/<blocktype>/*`: Resources for each block, including both JS
    modules and Sass includes (underscore-prefixed so that they aren't
    compiled). This structure maps closely with what externally-defined XBlocks
    do.
  * `xmodule/js` still exists, but it will soon be folded into the
    `xmodule/assets`.

* We add a new README [4] to explain the new structure, and also update a
  docstring in `openedx/lib/xblock/utils` which had fallen out of date with
  reality.

* Side note: We avoid the term "XModule" in all of this, because that's
  (thankfully) become a much less useful/accurate way to describe these blocks.
  Instead, we say "built-in XBlocks".

Refs:
1. https://github.com/openedx/edx-platform/pull/32018
2. https://github.com/openedx/edx-platform/issues/32292
3. https://github.com/openedx/edx-platform/assets/3628148/8b44545d-0f71-4357-9385-69d6e1cca86f
4. https://github.com/openedx/edx-platform/assets/3628148/d0b7b309-b8a4-4697-920a-8a520e903e06
5. https://github.com/openedx/edx-platform/tree/master/xmodule/assets#readme

Part of: https://github.com/openedx/edx-platform/issues/32292
2023-07-06 11:58:06 -04:00
kenclary
d6b76c800e Merge pull request #32566 from open-craft/navin/youtube-transcripts-language-codes
feat: configure acceptable language codes for youtube transcripts
2023-06-30 11:10:36 -04:00
Agrendalath
36cc415fc2 refactor: reuse services and wrappers between XBlocks 2023-06-30 15:06:43 +02:00
Navin Karkera
93006b476d feat: configure acceptable language codes for youtube transcripts 2023-06-30 11:02:58 +05:30
Piotr Surowiec
0137f21627 feat: move XQueueService from the runtime to ProblemBlock
The XQueueService is used only by the ProblemBlock. Therefore, we are moving 
it out of the runtime, and into the ProblemBlock, where it's initialized only 
when it's going to be used.
2023-06-21 20:08:31 +02:00
Braden MacDonald
f13263df4f fix: remove the need to patch the KVS during library import 2023-05-25 21:03:01 -07: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
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
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
Kaustav Banerjee
d0fa2d65e3 test: fix test cases and lint issues 2023-04-21 11:53:49 +02:00
Arunmozhi
2b59265240 feat: adds VerticalBlockRenderCompleted filter hook (#31388)
* feat: adds VerticalBlockChildrenLoaded filter call

This introduces the VerticalBlockChildrenLoaded filter that is run after
all the child blocks are fetched before rendering a student or the
public view. This will allow modifying the contents of the VerticalBlock
before presenting it to the students.
2023-02-22 15:05:19 -04:00
Agrendalath
a12c003215 feat: allow using all components of LibraryContentBlock
Setting max_count to a negative value resulted in raising an unhandled
ValueError. Currently, it selects all children of the LibraryContentBlock.
2023-02-17 12:49:33 +01:00
0x29a
3a1011bed8 refactor: replace usages of XModuleMixin.system with XBlock.runtime 2023-01-30 18:15:24 +01:00
0x29a
a027f36724 refactor: rename module -> block within xmodule 2023-01-30 18:15:22 +01:00
0x29a
9d8375ff99 refactor: rename module -> block within lms/djangoapps/courseware
Also, removed unused `_has_access_xmodule` methid from `lms/djangoapps/courseware/access.py`.
2023-01-30 18:15:22 +01:00
Arunmozhi
59d8b5d286 refactor: replace displayable_blocks with child
This removes the "displayable_blocks" property and replaces all the
usages with the "child" property.
2023-01-23 14:47:47 +01:00
Arunmozhi
851eb65d53 refactor: rename get_displayable_items and displayable_items 2023-01-23 14:47:47 +01:00
Arunmozhi
d417a7561f refactor: rename ItemFactory to BlockFactory 2023-01-23 14:47:47 +01:00
0x29a
83396ffb07 refactor: convert course_module term to course_block 2022-12-19 17:48:49 +01:00
0x29a
d3fee38a37 refactor: xmodule/split_test_module.py -> xmodule/split_test_block.py 2022-12-19 17:48:49 +01:00
0x29a
dd9f6936bc refactor: xmodule/video_module -> xmodule/video_block 2022-12-19 17:48:49 +01:00
0x29a
685f1cd679 refactor: xmodule/xml_module.py -> xmodule/xml_block.py 2022-12-19 17:48:49 +01:00
0x29a
071b4ba1b4 refactor: xmodule/word_cloud_module.py -> xmodule/word_cloud_block.py 2022-12-19 17:48:49 +01:00
0x29a
70019bac04 refactor: xmodule/seq_module.py -> xmodule/seq_block.py 2022-12-19 17:48:49 +01:00
0x29a
4aac963223 refactor: xmodule/randomize_module.py -> xmodule/randomize_block.py 2022-12-19 17:48:49 +01:00
0x29a
71b835091e refactor: xmodule/poll_module.py -> xmodule/poll_block.py 2022-12-19 17:48:49 +01:00
0x29a
57383a2840 refactor: xmodule/mako_module.py -> xmodule/mako_block.py 2022-12-19 17:48:49 +01:00
0x29a
2779bd250f refactor: xmodule/lti_module.py -> xmodule/lti_block.py 2022-12-19 17:48:49 +01:00
0x29a
e3591701e3 refactor: xmodule/library_content_module.py -> xmodule/library_content_block.py 2022-12-19 17:48:49 +01:00
0x29a
007e02cd76 refactor: xmodule/html_module.py -> xmodule/html_block.py 2022-12-19 17:48:49 +01:00
0x29a
cf47f6385f refactor: xmodule/error_module.py -> xmodule/error_block.py 2022-12-19 17:48:49 +01:00
0x29a
0df1411636 refactor: xmodule/course_module.py -> xmodule/course_block.py 2022-12-19 17:48:49 +01:00
0x29a
7e33dce1ab refactor: xmodule/conditional_module.py -> xmodule/conditional_block.py 2022-12-19 17:48:49 +01:00
0x29a
4c005e86e8 refactor: xmodule/capa_module.py -> xmodule/capa_block.py 2022-12-19 17:48:49 +01:00
0x29a
7f2e68c2fd refactor: xmodule/annotatable_module.py -> xmodule/annotatable_block.py 2022-12-19 17:48:49 +01:00
bszabo
5dc8dc54e1 Merge pull request #31412 from openedx/youtube-scrape-transcripts-squashed
Youtube scrape transcripts squashed
2022-12-13 15:05:03 -05:00
Kaustav Banerjee
99cd4a4715 feat: disable allowed enrollment if enrollment closed 2022-12-13 15:49:25 +01:00