134 Commits

Author SHA1 Message Date
Kyle McCormick
c70bfe980a build!: Switch to openedx-core (renamed from openedx-learning) (#38011)
build!: Switch to openedx-core (renamed from openedx-learning)

Instead of installing openedx-learning==0.32.0, we install openedx-core==0.34.1.
We update various class names, function names, docstrings, and comments to
represent the rename:

* We say "openedx-core" when referring to the whole repo or PyPI project
  * or occasionally "Open edX Core" if we want it to look nice in the docs.
* We say "openedx_content" to refer to the Content API within openedx-core,
   which is actually the thing we have been calling "Learning Core" all along.
  * In snake-case code, it's `*_openedx_content_*`.
  * In camel-case code, it's `*OpenedXContent*`

For consistency's sake we avoid anything else like oex_core, OeXCore,
OpenEdXCore, OexContent, openedx-content, OpenEdxContent, etc.
There should be no more references to learning_core, learning-core, Learning Core,
Learning-Core, LC, openedx-learning, openedx_learning, etc.

BREAKING CHANGE: for openedx-learning/openedx-core developers:
You may need to uninstall openedx-learning and re-install openedx-core
from your venv. If running tutor, you may need to un-mount openedx-learning,
rename the directory to openedx-core, re-mount it, and re-build.
The code APIs themselves are fully backwards-compatible.

Part of: https://github.com/openedx/openedx-core/issues/470
2026-02-18 22:38:25 +00:00
Navin Karkera
8ca70db552 refactor: xblock api upstream info and course details api (#37971)
- Returns top parent key instead of boolean in upstream info api
- Adds edited_on raw time in course outline api
- Adds has_changes to course details api
2026-02-09 23:09:06 +00:00
Chris Chávez
a032955243 feat: New states for library info icon in components in Unit page (#37735)
- Adds `upstream_name` to the `UpstreamLink` dataclass.
- Add new states to library info icon in components in Unit page
2025-12-16 19:18:24 +00:00
Navin Karkera
f2f0d87e9e fix: mark container as ready to sync if any child block is deleted
Before this fix, if only a component is deleted, then its parent blocks
were not marked as ready to sync.
2025-11-05 10:36:44 +05:30
Navin Karkera
2db3183958 feat: replace is_modified with downstream_customized field in upstream entity api and models (#37563)
This helps the caller to differentiate between the kind of local edits the downstream has and use it accordingly.
2025-10-29 22:22:01 +00:00
Navin Karkera
744cc87ffb feat: follow migrated legacy library content block (#37405)
* feat: show item bank ui for migrated legacy library content

* feat: migrate legacy content block to item bank block on view in studio

* fix: duplicate and copy issues

* refactor: migration location and add tests

* fix: lint issues

* fix: item bank and library content children view add button functionality

Newly added blocks from library in children view page of item bank block
and migrated library content block were not displayed automatically.

* fix: lint issues

* fix: lint issues

* feat: only migrate if same version of library is migrated

* refactor: migrate block on request

* fix: component reload on migration

* fix: tests

* refactor: comments and message wordings

* refactor: update alert text

* docs: add context

* fix: component links not being created on migrating legacy blocks

* fix: api docs and types

* refactor: use inheritance and specific parent method call

* fix: imports

* fix: api typing

* fix: upstream_version check

* refactor: rename variables

* refactor: parsing entity keys to usage_keys
2025-10-20 11:20:37 +05:30
Chris Chávez
7e1a17a707 feat: Multiple updates to handle children upstream info [FC-0097] (#37433)
* Which edX user roles will this change impact? "Developer"".
* Added `upstream_ready_to_sync_children_info` in `ContainerChildrenSerializer`
* Now, the `ContainerChildrenView` can return the `upstream_ready_to_sync_children_info`
* Update the child info in `UpstreamLink._check_children_ready_to_sync`
2025-10-15 19:16:51 -05:00
Navin Karkera
09e86e24b2 refactor!: use String field instead of Dict field to store top_level_downstream_parent_key (#37448)
* refactor!: use String field instead of Dict field to store top_level_downstream_parent_key

Since this is a new field no production instance should have this field
yet. Developers need to delete their old courses as this change will
raise error in all course pages.

* chore: add `top_level_parent` field in ComponentLink and ContainerLink admin

* refactor: use ":" as separator

* refactor: block key parsing and tests
2025-10-09 22:03:23 +05:30
Kyle McCormick
8b6a94bc8d fix: Only update downstream_customized for upstream-linked blocks (#37412)
We only need to track field customizations for upstream-linked (i.e.,
library-linked) blocks. Thd downstream_customized field is irrelevant for other
blocks. It would just add a ton of noise to the OLX.

Additionally, we now clear downstream_customized when severing an upstream
link.

Fixes: https://github.com/openedx/edx-platform/issues/37411
2025-10-06 11:33:25 -04:00
Navin Karkera
5d9fc2442f refactor: course container children api [FC-0097] (#37375)
* feat: course container children view

* refactor: rename

* refactor: include children info in upstream info of container children

* fix: tests

* fix: test

* refactor: children check
2025-09-24 11:27:31 +05:30
Navin Karkera
a11086ffac feat: allow editing imported text blocks (#37124)
* feat: allow editing html block imported from upstream

The modified field is left untouched in future sync while storing the
upstream values in hidden fields to allow authors to revert to upstream
version at any point.

* fix: sync downstream_customized field for copy-pasted modified block

* test: add more tests

* fix: lint issues

* test: copy paste

* feat: skip sync if html data is modified

* feat: update upstream fields only when modified

* refactor: use version_synced field to skip sync

* feat: edit title inplace for library source components

* fixup! feat: edit title inplace for library source components

* fix: edit title button style

* fix: test case

* fix: lint issue

* refactor: don't show different icon for modified upstream blocks

* Revert "refactor: use version_synced field to skip sync"

This reverts commit 8b784fff2f49b43702c952e7f955bd4048e8cc69.

* feat: only skip sync for modified blocks if updated as part of container

* refactor: update sync behaviour when synced individually and as part of parent

* feat: include ready to sync children info in downstream link get api

* test: fix failing tests

* fix: lint issues

* feat: new tests and update api to allow overriding modified fields in sync

* test: api changes

* refactor: edit options should be visible for individual imports

* docs: update api docs

* chore: remove old comments
2025-09-17 14:50:24 +05:30
Navin Karkera
eb5ba0f87d fix: exception while trying to check sync status of deleted upstream (#37298)
Use `Upstream.try_get_for_block` instead of `Upstream.get_for_block` which raises `BadUpstream` if upstream block is deleted.
2025-08-28 17:43:06 +00:00
Rômulo Penido
8085bf6be4 feat: Add unlinkable to xblock actions and update top_level_parent_key on unlink [FC-0097] (#37215)
- Adds the `unlinkable` action to the XBlock object sent to the frontend
- Updates the `top_level_parent_key` reference when unlinking containers. If you unlink a Section with Subsections and Units, this updates the `top_level_parent_key` for the Subsections to `None` (they are the top level now), and the `top_level_parent_key` for the Units to the corresponding parent Subsection.
2025-08-28 16:30:17 +00:00
Chris Chávez
fa3dcc5482 feat: Add the top-level parent logic to the ready_to_sync value in the UpstreamLink (#37217)
- Updates `UpstreamLink.ready_to_sync` with the top-level parent logic: In a container, `ready_to_sync` is `True` if the container or any children have changes.
- Updates `decline_sync` to decline children recursively.
2025-08-21 16:34:58 -05:00
Chris Chávez
ec72dc7998 feat: Add top-level parent logic to Upstream/Dowstream links [FC-0097] (#37076)
- Adds the `top_level_parent_usage_key` to the `EntityLinkBase`
- This field is used to save the top-level parent of a component or container when it is imported into a course. Example: A unit with components imported into a course. The unit is the top-level parent of the components.
- Updates the `DownstreamListView` to return the top-level parents instead of downstream child, if this parent exists.
- Each time containers with children were synchronized, a new downstream block was created for each child instead of updating the existing one. This occurred because the `upstream_key` was incorrectly validated as an `Opaquekey` against a list of key strings. This was fixed by converting the `upstream_key` to a string before the verification. (see 34cd5a4781 and 29647831dc)
- Which edX user roles will this change impact?  "Course Author", "Developer".
2025-08-14 17:36:30 +00:00
Devasia Joseph
e2ce7debf2 fix: refactor code based on pep-8 guideline 2025-08-08 14:04:26 +05:00
Devasia Joseph
466aaad85d feat: Enhance course optimizer to detect previous run links and expand scanning scope 2025-08-08 14:04:26 +05:00
Devasia Joseph
b665f30378 fix: fixed lint errors 2025-07-10 17:37:25 +05:30
Devasia Joseph
f330e49aaf feat: Added disable/enable discussion endpoint to swagger 2025-07-10 17:05:42 +05:30
Raymond Zhou
33f239d8fc fix: use correct studio resource url call (#37000) 2025-07-09 11:30:22 -04:00
Jillian
5b3caa93e2 feat: store content.child_usage_keys in Container search document [FC-0083] (#36528)
* feat: store content.child_usage_keys in Container search document
  Stores the draft children + published children (if applicable)

Related fixes:
* fix: lib_api.get_container does not take a "user" arg
* refactor: fetch_customizable_fields_from_container does not need a "user" arg
* refactor: moves tags_count into LibraryItem
   because anything that appears in a library may be tagged.
* refactor: remove get_container_from_key from public API
   API users must use get_container and ContainerMetadata.
* refactor: made set_library_item_collections take an entity_key string instead of
  a PublishableEntity instance, so we don't need to fetch a Container object to call it.
* refactor: changed ContainerLink.update_or_create to take the container PK
  instead of a Container object, since this is enough.
  Added container_pk to ContainerMetadata to support this.
2025-05-02 10:47:25 +09:30
Navin Karkera
1cd73d1b96 feat: support for syncing units from libraries to courses (#36553)
* feat: library unit sync
* feat: create component link only for component xblocks
* feat: container link model
* feat: update downstream api views
* feat: delete extra components in container on sync (not working)
* fix: duplicate definitions of LibraryXBlockMetadata
* test: add a new integration test suite for syncing
* feat: partially implement container+child syncing
* fix: blockserializer wasn't always serializing all HTML block fields
* feat: handle reorder, addition and deletion of components in sync

Updates children components of unit in course based on upstream unit,
deletes removed component, adds new ones and updates order as per
upstream.

* feat: return unit upstreamInfo and disallow edits to units in courses that are sourced from a library (#773)
* feat: Add upstream_info to unit
* feat: disallow edits to units in courses that are sourced from a library (#774)

---------

Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>

* docs: capitalization of XBlock

Co-authored-by: David Ormsbee <dave@axim.org>

* refactor: (minor) change python property name to reflect type better

* fix: lots of "Tried to inspect a missing...upstream link" warnings

when viewing a unit in Studio

* docs: mention potential REST API for future refactor

* fix: check if upstream actually exists before making unit read-only

* chore: fix camel-case var

* fix: test failure when mocked XBlock doesn't have UpstreamSyncMixin

---------

Co-authored-by: Braden MacDonald <braden@opencraft.com>
Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
Co-authored-by: Jillian Vogel <jill@opencraft.com>
Co-authored-by: Rômulo Penido <romulo.penido@gmail.com>
Co-authored-by: Braden MacDonald <mail@bradenm.com>
Co-authored-by: David Ormsbee <dave@axim.org>
2025-04-24 11:41:47 -07:00
Chris Chávez
b6489e718c feat: Video editor supports transcripts [FC-0076] (#36058)
* Add error handler on save video to avoid creating sjson
* Support transcripts without edx_video_id in definition_to_xml
* When copying a video from a library to a course: Create a new edx_video_id
* Save transcripts as static assets in a video in a library when adding a new transcript.
* Delete transcripts as static assets in a video in a library when deleting transcripts.
* Support download transcript in a video in a library.
* Support replace transcript in a video in a library.
* Support updating transcripts in video in a library.
* Refactor the code of downloading YouTube transcripts to enable this feature in libraries.
* Support copy from a library to a course and a course to a library.
2025-02-21 13:33:13 -05:00
Daniel Valenzuela
36c16d6952 fix: static assets used in problem bank and library content block (#36173)
Static assets were not being copied into the course when using library content via Problem Bank or "Add Library Content" workflows.
2025-02-07 10:30:05 -08:00
Jillian
3847cec503 feat: add and switch to downstream-only fields [FC-0076] (#36158)
Adds the concept of "downstream-only" fields to the XBlock upstream sync logic.

Downstream-only fields are customizable fields set only on the downstream XBlock -- we don't keep track of the upstream field value anywhere on the downstream XBlock. Changes made to these fields in the upstream block are ignored, and if the link to the upstream block is severed, the downstream changes are preserved (not reset back to defaults, like the upstream-tracked customizable fields are).

The fields chosen as "downstream-only" are those related to scoring and grading.

The `max_attempts` field was previously a customizable field that tracked the upstream value. However, because it is scoring-related, it has been converted to a "downstream-only" field.

This change impacts course authors' use of library content in their courses.
2025-01-27 15:37:53 +00:00
Navin Karkera
e2a9a37d68 feat: show alert while editing v2 library content [FC-0062] (#35700)
Adds warning alert in edit modal for library v2 content in both legacy and new
MFE editors. For the Libraries Relaunch Beta.

Part of: https://github.com/openedx/frontend-app-authoring/issues/1340

Co-authored-by: Chris Chávez <xnpiochv@gmail.com>
2024-10-23 16:03:26 +00:00
Chris Chávez
9e14566f90 feat: Copy tags when sync library [FC-0062] (#35596)
* feat: Copy tags when sync library

* feat: Avoid delete object tag if is copied

* chore: Bump version of openedx-learning to 0.16.0

* test: Tests for copy paste library blocks

* feat: Sync tags when sync upstream
2024-10-21 15:24:46 +00:00
Braden MacDonald
83827a3dc2 feat: Confirmation modal to preview and accept v2 library updates (#35669) 2024-10-18 12:21:16 -07:00
Kyle McCormick
795d039581 feat: Upstream Sync with Content Library Blocks (#34925)
This introdues the idea of "upstream" and "downstream" content,
where downstreams (like course components) can pull content updates from
upstreams (like learning core-backed content library blocks). This
supports the upcoming Content Libraries Relaunch Beta for Sumac.
New features include:

* A new XBlockMixin: UpstreamSyncMixin.
* A new CMS Python API: cms.lib.xblock.upstream_sync
* A new CMS JSON API: /api/contentstore/v2/downstreams
* A temporary, very basic UI for syncing from Content Library blocks

Implements:
https://github.com/kdmccormick/edx-platform/blob/kdmccormick/upstream-proto/docs/decisions/0020-upstream-block.rst

Co-authored-by: Braden MacDonald <braden@opencraft.com>
2024-10-17 16:02:26 +00:00
Daniel Valenzuela
78b691b56a refactor: inheritable authoring mixin callbacks for editing & duplication (#33756) 2024-07-25 10:30:37 -07:00
Maria Grimaldi
33b8137763 refactor: rename minimum partition ID constant to be more generic (#34529)
Rename MINIMUM_STATIC_PARTITION_ID to MINIMUM_UNUSED_PARTITION_ID
so it's not confusing when used to generate IDs for static or dynamic
partitions.
2024-05-20 14:38:58 -04:00
Jillian
7ad225658f feat: don't use OLX for tags when copying/duplicating blocks (#34386) 2024-04-02 09:59:57 -07:00
Kristin Aoki
9f734a7a5e feat: update youtube transcript fetch to allow all languages (#34436)
* feat: allow all languages

* feat: add youtube transcript import functions as drf
2024-03-29 08:28:18 -04:00
Rômulo Penido
cb6801dbfd feat: paste tags when pasting xblocks with tag data (#34270) 2024-03-08 12:03:43 -08:00
Yusuf Musleh
6e0bc66a77 feat: Serialize tag data in OLX for blocks (#34145) 2024-02-14 10:30:23 -08:00
Kyle McCormick
e800ae7622 feat: provisionally support V2 libraries in LibraryContentBlock (randomized only) (#33263)
Refactors and reworks the LibraryContentBlock so that its
sync-from-library operations are asynchronous and work with
V2 content libraries. This also required us to make
library_content block duplication asynchronous, as that
involves syncing from the source library.

For the sake of clarity, this PR includes two major method renames:

* update_children(...) -> sync_from_library(...)
* refresh_library(...) -> sync_from_library(upgrade_to_latest=True, ...)

an an XBlock HTTP handler rename:

  /refresh_children -> /upgrade_and_sync

There are still a couple issues with import or duplication
of library_content blocks referencing V2 libraries other than
latest. These will be resolved in an upcoming PR.

Part of: https://openedx.atlassian.net/wiki/spaces/COMM/pages/3820617729/Spec+Memo+Content+Library+Authoring+Experience+V2
Follow-up work: https://github.com/openedx/edx-platform/issues/33640

Co-authored-by: Connor Haugh <chaugh@2u.com>
Co-authored-by: Eugene Dyudyunov <evgen.dyudyunov@raccoongang.com>
2023-11-20 15:58:10 +00:00
bszabo
5d6e925c83 feat: TNL-11173 Authoring API is v0 for now (#33644)
* feat: TNL-11173 authoring API offered as v0, not v1

* docs: correct swaggerfile for authoring api

---------

Co-authored-by: Bernard Szabo <bszabo@edx.org>
Co-authored-by: Jesper Hodge <jhodge@outlook.de>
2023-11-03 11:49:35 -04:00
Jesper Hodge
f197f9e61e add swagger for CMS API via drf-spectacular (#33282)
This adds two new urls: `<studio-base>/cms-api/ui` and `<studio-base>/cms-api/schema` with swagger ui and swaggerfile only for the new CMS API using drf-spectacular
2023-09-19 21:06:40 +00: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
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
German
3f20c75043 feat: [ACADEMIC-16209] Unit summary settings (#32855)
* feat: [ACADEMIC-16209] Unit summary settings

[https://jira.2u.com/browse/ACADEMIC-16209](https://jira.2u.com/browse/ACADEMIC-16209)

1. Add unit xpert unit summaries settings behind flag `summaryhook_summaries_configuration` added [here](https://github.com/edx/ai-aside/pull/45/files)
2. Only show the checkbox when the value is a `boolean` otherwise the feature is considerer `disabled` by the flag.
3. Update block handler to update this value via `api` exposed [here](https://github.com/edx/ai-aside/pull/43)
4. Create `AiAsideSummary` configuration class to provide access to the `ai_aside.api` endpoints.
2023-08-21 14:55:22 -03:00
Braden MacDonald
d60cdc2305 fix: refactor MakoService to allow specifying namespace per template (#33061) 2023-08-21 10:05:38 -07:00
Diego Velasquez
e92e0e263b chore: remove warnings for assertNotRegexpMatches method (#32753)
Co-authored-by: Diego Velásquez <diego@emptor.io>
2023-07-27 15:37:24 +05: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
Arunmozhi
d417a7561f refactor: rename ItemFactory to BlockFactory 2023-01-23 14:47:47 +01:00
Sagirov Eugeniy
f3de63058c test: tests for removing support for children in Old Mongo
* updated test_authoring_mixin.py
* updated test_xblock_utils.py
* updated TestOnboardingView tests (update default course key)
* updated UsersDefaultRole tests
2023-01-17 14:54:14 -05:00
0x29a
4c005e86e8 refactor: xmodule/capa_module.py -> xmodule/capa_block.py 2022-12-19 17:48:49 +01:00
Kyle McCormick
9f380b9ccd refactor: import common/lib/ modules from canonical locations (#30533)
Unfortunately, some code in edx-platform is imported
relative to sub-projects instead of the repository root.
The only three remaining instances of this are:
* common/lib/xmodule/xmodule (imported as just 'xmodule')
* common/lib/capa/capa (imported as just 'capa')
* openedx/core/lib/xblock_builtin/xblock_discussion
  (imported as just 'xblock_discussion')

For more details on the situation, see:
https://openedx.atlassian.net/browse/BOM-2579
(public, but requires Atlassian account creation).

We would like to get to a point where all edx-platform
import paths match their folder paths, relative to the repo
root. For now, though, all common/lib/capa and common/lib/xmodule
code should be imported as just `from capa` and `from xmodule`,
respectively. Importing using the full `common.lib.xmodule.xmodule...`
path will often work, but it instantiates a second instance of all
modules imported this way, which in the past has led to very
difficult-to-diagnose bugs.  It also confuses tooling such as
import-linter, which we are trying to add to edx-platform
(see https://openedx.atlassian.net/browse/BOM-2576)
2022-06-06 09:54:16 -04:00
Michael Terry
cb1bb7fa64 test: switch default test store to the split store
It's long past time that the default test modulestore was Split,
instead of Old Mongo. This commit switches the default store and
fixes some tests that now fail:
- Tests that didn't expect MFE to be enabled (because we don't
  enable MFE for Old Mongo) - opt out of MFE for those
- Tests that hardcoded old key string formats
- Lots of other random little differences

In many places, I didn't spend much time trying to figure out how to
properly fix the test, and instead just set the modulestore to Old
Mongo.

For those tests that I didn't spend time investigating, I've set
the modulestore to TEST_DATA_MONGO_AMNESTY_MODULESTORE - search for
that string to find further work.
2022-02-04 14:32:50 -05:00