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>
This commit is contained in:
Kyle McCormick
2023-11-20 10:58:10 -05:00
committed by GitHub
parent c53cf9f1c3
commit e800ae7622
33 changed files with 1597 additions and 573 deletions

View File

@@ -217,8 +217,15 @@ class CompletionServiceTestCase(CompletionWaffleTestMixin, SharedModuleStoreTest
# Library Content Block needs its children to be completed.
self.assertFalse(self.completion_service.can_mark_block_complete_on_view(library_content_block))
library_content_block.refresh_children()
lib_vertical = self.store.get_item(lib_vertical.location)
# Dirty hack:
# sync_from_library isn't *supposed* to work inside LMS, but this test case was written
# before we made that rule. So, we need to trick this part of test case into thinking that it's
# running inside CMS instead of LMS. Please don't copy-paste this trick to any other LMS tests :)
# Long-term solution: https://github.com/openedx/edx-platform/issues/33545
with override_settings(ROOT_URLCONF="cms.urls"):
library_content_block.sync_from_library()
lib_vertical = self.store.get_item(lib_vertical.location)
self._bind_course_block(lib_vertical)
# We need to refetch the library_content_block to retrieve the
# fresh version from the call to get_item for lib_vertical