Commit Graph

24 Commits

Author SHA1 Message Date
Braden MacDonald
1ac6de2ec0 chore: libraries - remove usage of deprecated key types / params (#36563) 2025-04-21 18:47:29 -07:00
Chris Chávez
0bd0e6f4ca refactor: Update get block OLX view to support versions [FC-0062] (#35932)
* Deprecate `get_block_draft_olx`
* Deprecate get olx view in content libraries
* Create `get_block_olx` in xblock API with support of versions
* Create get olx view in xblock
2024-12-05 18:49:23 +00:00
Braden MacDonald
e2d6765637 feat: expand support for versioned URLs in v2 XBlock runtime (#35676)
* fix: problem block could not be used with versioned handler URls

* refactor: simplify REST API handling of usage keys

* feat: add more version awareness and update tests

* fix: make the preview changes modal bigger as requested

* refactor: parse version at the urlconf layer too
2024-10-21 09:14:17 -07:00
Braden MacDonald
4ca522152f feat: Allow specifying a version when loading a v2 XBlock (#35626) 2024-10-16 08:43:20 -07:00
Braden MacDonald
5b809673b6 refactor: get rid of XBlockRuntimeSystem for v2 libraries (#35624) 2024-10-11 17:23:32 +00:00
Braden MacDonald
7316111b35 fix: Improve v2 library block permissions checks for read-only authors (#35598) 2024-10-08 10:22:41 -07:00
David Ormsbee
be03938377 refactor: update to use Learning Core's new public API
This also bumps our openedx-learning dependency to 0.10.0 (the first
version with the new openedx_learning.api package).
2024-05-21 16:05:56 -04:00
Braden MacDonald
f663739510 feat: Index Studio content using Meilisearch [experimental] (#34310) 2024-03-22 10:08:31 -07:00
David Ormsbee
86f1e5e8aa feat!: Switch v2 libraries to Learning Core data models (#34066)
This moves the Content Libraries V2 backend from Blockstore [1] over to
Learning Core [2] For high-level overview and rationale of this move, see
the Blockstore DEPR [3]. There are several follow-up tasks [4], most notably
adding support for static assets in libraries.

BREAKING CHANGE: Existing V2 libraries, backed by Blockstore, will stop
working. They will continue to be listed in Studio, but their content
will be unavailable. They need to be deleted (via Django admin) or manually
migrated to Learning Core. We do not expect production sites to be in
this situation, as the feature has never left "experimental" status.

[1] https://github.com/openedx-unsupported/blockstore
[2] https://github.com/openedx/openedx-learning/
[3] https://github.com/openedx/public-engineering/issues/238
[4] https://github.com/openedx/edx-platform/issues/34283
2024-02-22 16:38:05 +00:00
Braden MacDonald
626f11f608 test: Import linter: optionally enforce usage of a package's public API (#31903)
* test: warn about dependencies from cms->openedx->lms and vice versa

* test: warn about importing from package's internal implementation code

* chore: Update some imports to use public APIs only

* chore: Update 'bookmarks' app to have stricter public API

* fix: we are sharing 'adapters' from olx_rest_api to content_staging
2023-04-20 11:34:51 -07:00
Jillian
9f5c78e81e revert: temp: let XBlock API users optionally use LabXchange block types (#31315)
when fetching block metadata and rendering blocks while maintaining the
original usage IDs/OLX.

Reverts ef8f841ac2
2023-01-11 11:19:58 -08:00
Jillian Vogel
ef8f841ac2 temp: let XBlock API users optionally use LabXchange block types
when fetching block metadata and rendering blocks while maintaining the
original usage IDs/OLX.

This change is marked temporary because LabXchange need it during the
transition to a custom runtime, but it's not really useful to anyone
else. We will revert this change with a future PR.
2022-01-20 10:35:59 +10:30
M. Zulqarnain
43008723be feat: New codemods on OpenedX 3 (#28778) 2021-10-22 13:55:51 +05:00
Usama Sadiq
25b275bca4 refactor: Ran pyupgrade on openedx/core/djangoapps
Ran pyupgrade on openedx/core/djangoapps/{xblock, xmodule_django, zendesk_proxy}
2021-04-07 18:57:52 +05:00
Jawayria
250c94dc6a BOM-2331: Applied pylint-amnesty to waffle_utils, xblock, xmodule_django, zendesk_proxy, __init__.py 2021-02-04 17:49:15 +05:00
David Ormsbee
d1da021d77 Merge pull request #23469 from open-craft/blockstore-race-condition
Cache Blockstore XBlock field data per thread, not per-process
2020-04-30 11:33:43 -04:00
Braden MacDonald
cb58873879 Cache Blockstore XBlock field data per thread, not per-process
The cache in the previous version of this code was unwittingly being
shared among all threads, and an occasional race condition would result
in the .children field of some XBlocks containing duplicate entries.

I tried to find other ways to keep the existing cache design and let it
be shared among all the threads (which would be more efficient), but I
couldn't find any clean way of doing it (and even then, this code was
not written with the intention of being used in a multi-threaded way).
So to keep the fix simple, I made the block data cache thread-local
instead of process-local. That eliminated the bug.

Technical details:

The big challenge with this code in the first place was due to the
parse_xml API of XBlocks, which instantiates the XBlock instance and
_then_ sets field data on it and returns it, as there is no mechanism
available to distinguish that from the case of instantiating an XBlock
(using previously loaded/cached field data) and then deliberately
changing its field values. In particular, parse_xml sets the 'children'
field just by calling self.children.append(...) but never explicitly
initializes self.children to [] first, so it's necessary for the field
data store to have a mechanism for setting self.children = [] when
parsing begins, but it's hard to know "when parsing begins" in general.

This is made more challenging since the BlockstoreFieldData design ties
field data changes to the XBlock instance itself (using a weakkey), but
it's impossible to get a reference to the XBlock instance before calling
parse_xml, and since the BlockstoreFieldData design uses a pass-through
approach where fields that aren't being actively changed are read from
the cache; since it doesn't know when children is being initialized vs.
being modified, it would sometimes pass-through and start one thread's
changes with the final result from another thread.

Anyhow, the bottom line is that avoiding unintentional multithreading
here solves the problem.

If we want the field data cache to be shared among threads, it might as
well be rewritten to use memcached and shared among all processes too.
That would be a very good performance boost but would take up a lot more
memory in memcached. Also the rewrite may be challenging due to the
aforementioned nuances of the XBlock parse_xml / construct_xblock /
add_node_as_child APIs. Perhaps modifying the runtime to use a
completely separate fielddata implementation for parsing vs. loading a
parsed+cached XBlock would do it.
2020-04-28 12:01:44 -07:00
Samuel Walladge
9f6b3a873f Make more metadata available via the new runtime's generic XBlock API
Without this PR, there is no [reasonable] way to get the following data
for any XBlocks in the new runtime; now there is :)

* index_dictionary: data about the block content, for search indexing
* student_view_data: data-only equivalent of student_view, for use in
  custom UIs/mobile
* children: list of child IDs
* editable_children: list of child IDs in the same bundle (use case:
  when showing an OLX editor you want to allow editing the OLX of
  children in the same bundle but not linked children)
2020-04-17 13:09:59 -07:00
Braden MacDonald
af6cab86c3 Enforce permissions for content libraries, add REST API to edit perms 2020-03-02 18:17:46 -08:00
Feanil Patel
9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00
Braden MacDonald
f31dc19887 Support anonymous users in the Blockstore-based XBlock runtime
Implementation details:
* Anonymous users are assigned a unique ID (like 
  `anon42c08f9996194e2a9339`) which gets stored in the django session.
  `block.scope_ids.user_id` and `block.runtime.anonymous_student_id`
  will both return this value.
* User state for anonymous users is stored in the django cache and
  automatically expires as the cache gets pruned. Because user state is
  stored, anonymous users can use interactive blocks like capa problems.
* There is no mechanism for upgrading to a registered account and
  keeping user state since the user state store for anonymous users
  (EphemeralKeyValueStore) is completely different than the one for
  registered users (DjangoKeyValueStore/"CSM"), and has no "list all
  keys" functionality.
* "User State Summary" field values are shared among [recently active]
  anonymous users but are not shared with registered users.
* Anonymous users can only access the `public_view` of XBlocks, not the
  regular `student_view`.
2019-12-19 16:12:24 -08:00
Braden MacDonald
1382bf8720 Save user state for Blockstore XBlocks in CSM, clean up CSM a bit (#21630)
This commit introduces the changes needed for XBlocks in Blockstore to save
their user state into CSM. Before this commit, all student state for Blockstore
blocks was ephemeral (in-process dict store).

Notes:

* The main risk factor of this PR is that it adds non-course keys to the
  course_id field in CSM. If any code (like analytics?) reads course keys
  directly out of CSM and doesn't have graceful handling for key types it
  doesn't recognize, it could cause an issue. With the included changes to
  opaque-keys, calling CourseKey.from_string(...) on these values will raise
  InvalidKeyError since they're not CourseKeys. (But calling
  LearningContextKey.from_string(...) will work for both course and library
  keys.)
* This commit introduces a slight regression for the Studio view of XBlocks in
  Blockstore content libraries: their state is now lost from request to request.
  I have a follow up PR to give them a proper studio-appropriate state store,
  but I want to review it separately so it doesn't hold up this PR and we can
  test this PR on its own.
2019-09-18 10:27:46 -04:00
Braden MacDonald
ec97387d3e Move new Blockstore key types to external opaque-keys library. 2019-09-13 09:56:44 -07:00
Braden MacDonald
d3f6ed09d8 Learning Contexts, New XBlock Runtime, Blockstore API Client + Content Libraries
https://github.com/edx/edx-platform/pull/20645

This introduces:
* A new XBlock runtime that can read and write XBlocks that are persisted using
  Blockstore instead of Modulestore. The new runtime is currently isolated so
  that it can be tested without risk to the current courseware/runtime.
* Content Libraries v2, which store XBlocks in Blockstore not modulestore
* An API Client for Blockstore
* "Learning Context" plugin API. A learning context is a more abstract concept
  than a course; it's a collection of XBlocks that serves some learning purpose.
2019-08-30 10:31:15 -07:00