Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support static reference in LibraryContentBlock #33511

Closed
wants to merge 128 commits into from
Closed
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
d81d774
feat!: remove LibrarySourcedBlock
kdmccormick Sep 14, 2023
9eee194
feat: support V2 libraries in LibraryContentBlock (randomized only)
kdmccormick Sep 14, 2023
258216b
Merge branch 'master' into kdmccormick/library-content-v2
kdmccormick Sep 15, 2023
ef54bd6
fix: user tasks out of lms, move tasks.py
connorhaugh Sep 18, 2023
9b0b722
Merge commit 'refs/pull/33263/head' of github.com:openedx/edx-platfor…
connorhaugh Sep 18, 2023
1daf629
fix: lint
connorhaugh Sep 19, 2023
982abc7
fix: lint
connorhaugh Sep 19, 2023
0dbe410
fix: lint fix
connorhaugh Sep 19, 2023
3299cef
fix: move codeowner attribute to layer
connorhaugh Sep 19, 2023
081bfdb
feat: implement chema
connorhaugh Oct 5, 2023
109a33c
fix: remove codeowner attribute from update_children_task
kdmccormick Oct 5, 2023
4b4a34e
build: put back set_code_owner_attribute but as a regular function call
kdmccormick Oct 5, 2023
9b2f0f0
feat: add cms-only assertions to content_libraries tasks
kdmccormick Oct 5, 2023
0f730f8
Merge branch 'master' into kdmccormick/library-content-v2
kdmccormick Oct 17, 2023
fccbaa4
style: fix indentation
kdmccormick Oct 17, 2023
6dcb047
fix: add missing imports for _assert_cms
kdmccormick Oct 17, 2023
f2230db
docs: remove outdated is_v2_lib from function docstring
kdmccormick Oct 17, 2023
e25e2a3
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 18, 2023
f1370d0
test: run ./xmodule/ LibraryContentTests only in CMS
kdmccormick Oct 18, 2023
8fe86a1
test: run ./xmodule/ tests with CMS settings
kdmccormick Oct 18, 2023
71cde02
Revert "test: run ./xmodule/ LibraryContentTests only in CMS"
kdmccormick Oct 18, 2023
9f9c047
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 18, 2023
42e82ba
Merge branch 'kdmccormick/test-xmodule-with-cms' into kdmccormick/lib…
kdmccormick Oct 18, 2023
3a25800
test: run ./xmodule/ LibraryContentTests only in CMS
kdmccormick Oct 18, 2023
8ac429a
style: remove duplicate imports fomr test_lib_tools
kdmccormick Oct 18, 2023
3cf5fc3
test: fix patching in test_list_available_libraries
kdmccormick Oct 18, 2023
caecac1
test: attempt at stricter enforcement of library tools in cms only
kdmccormick Oct 18, 2023
ae73343
Merge branch 'master' into kdmccormick/library-content-v2
kdmccormick Oct 19, 2023
2241ca5
temp: fix: put library_tools back in LMS, at least for now
kdmccormick Oct 19, 2023
4379f0f
test: fix skip_unless_[lms|cms]
kdmccormick Oct 19, 2023
e911056
test: fix library_content completion test w/ settings hack
kdmccormick Oct 19, 2023
1fadf7a
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 19, 2023
0809ad4
test: update test patch for new libraries tasks location
kdmccormick Oct 19, 2023
22cb7d5
test: use string mock to satisfy importlinter
kdmccormick Oct 19, 2023
2609a43
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 19, 2023
989297a
fix: lint + add unit tests
connorhaugh Oct 23, 2023
c46f155
Merge branch 'kdmccormick/library-content-v2' into feat--Library-Cont…
connorhaugh Oct 23, 2023
1bc84d4
fix: code quality cleanup
connorhaugh Oct 23, 2023
b47ab3c
Merge branch 'feat--Library-Content-Block-Reference' of github.com:ed…
connorhaugh Oct 23, 2023
9c23889
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 23, 2023
2604f1c
fix: module resolution order for import
connorhaugh Oct 23, 2023
cc10e34
fix: reset default max_count to 1 from -1
connorhaugh Oct 23, 2023
c5bf4ac
fix: correctly pass context vars block selection
connorhaugh Oct 24, 2023
0cf735f
fix: getting status of library_content's update_children task
kdmccormick Oct 24, 2023
3dfa080
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 24, 2023
c35f265
fix: final organization of fields
connorhaugh Oct 24, 2023
535fb52
fix: squash: _are_children_updating utiltity func
kdmccormick Oct 24, 2023
2c69e81
Revert "fix: squash: _are_children_updating utiltity func"
kdmccormick Oct 24, 2023
781cdf5
Revert "fix: getting status of library_content's update_children task"
kdmccormick Oct 24, 2023
b9fc30d
fix: getting status of library_content's update_children task
kdmccormick Oct 24, 2023
c609b0b
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 26, 2023
744bce6
fix: clear candidates when changing libraries
connorhaugh Oct 26, 2023
35db46c
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Oct 27, 2023
455424e
Merge branch 'master' into kdmccormick/library-content-v2
kdmccormick Oct 30, 2023
6666243
refactor: delete unused library_tools code; rename update_children
kdmccormick Oct 31, 2023
65e9599
test: update unit tests for previous refactor commit
kdmccormick Oct 31, 2023
3d9b305
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Nov 2, 2023
e96f8c8
Merge remote-tracking branch 'upstream/master' into kdmccormick/libra…
kdmccormick Nov 3, 2023
d8baa20
fix: duplicate library_content children asynchronously (#33652)
kdmccormick Nov 6, 2023
ea7d91a
Merge branch 'kdmccormick/library-content-v2' into feat--Library-Cont…
connorhaugh Nov 6, 2023
ee0078c
fix: remove print statments + fix tests
connorhaugh Nov 7, 2023
4b81e75
Merge branch 'master' into feat--Library-Content-Block-Reference
connorhaugh Nov 27, 2023
66e5808
fix: fixes from feedback and post-merge
connorhaugh Nov 29, 2023
ec720c1
fix: lint
connorhaugh Nov 29, 2023
6dc8ad2
Merge branch 'master' into feat--Library-Content-Block-Reference
connorhaugh Nov 29, 2023
c7755c1
fix: selection fixes
connorhaugh Nov 29, 2023
c0fe94f
fix: lint
connorhaugh Nov 30, 2023
a52e8ea
fix: overlimit bug
connorhaugh Nov 30, 2023
e2acf70
fix: unit tests + cleaner code
connorhaugh Dec 1, 2023
a51cdda
fix: readd completion mode
connorhaugh Dec 1, 2023
49a47d8
Merge branch 'master' into feat--Library-Content-Block-Reference
connorhaugh Dec 4, 2023
de6d7bd
fix selection pairing
kdmccormick Dec 5, 2023
c0cbd05
fix: candidate typing
connorhaugh Dec 7, 2023
af8e392
fix: lint
connorhaugh Dec 7, 2023
b53862f
Merge branch 'master' into feat--Library-Content-Block-Reference
connorhaugh Dec 7, 2023
8507648
fix: hide shuffle, manual, candidates from editor.
connorhaugh Dec 13, 2023
2d3d222
fix: result of manual testing
connorhaugh Dec 13, 2023
d06ee3d
Merge branch 'master' into feat--Library-Content-Block-Reference
kdmccormick Dec 15, 2023
5ba4852
feat: add new library editor toggle (#33628)
connorhaugh Dec 19, 2023
93e87b5
Merge branch 'master' into feat--Library-Content-Block-Reference
kdmccormick Dec 19, 2023
575e64c
fix: manual scope typo (#33957)
rayzhou-bit Dec 20, 2023
94e11bd
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Dec 21, 2023
6edfd51
temp: feat: show the LibraryContentBlock's manual and shuffle fields
kdmccormick Dec 21, 2023
cab19a1
test: type-check library_content_block.py
kdmccormick Dec 22, 2023
162801f
test: beef up the unit tests for randomized LibraryContentBlock a bit
kdmccormick Dec 22, 2023
f5c06ef
test: run a test that wasn't running. it's failing now
kdmccormick Dec 22, 2023
675fed6
fix: pass candidates into make_selection correctly
kdmccormick Dec 23, 2023
bb0c19a
test: test shuffled & unshuffled variant of all selection tests
kdmccormick Dec 23, 2023
4bd687e
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Dec 27, 2023
579bbb7
fix: bug and pylint violations in make_selection calls
kdmccormick Dec 27, 2023
331f3d0
test: LibraryContentBlock test_invalid_block_without_replacement
kdmccormick Dec 27, 2023
30cb7de
test: complex library content selection scenario (currently failing)
kdmccormick Dec 27, 2023
d34eb3d
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Dec 27, 2023
4fc9135
test: make test output easier to read & remove breakpoint
kdmccormick Jan 2, 2024
607c856
test: don't just convert from lists to sets in tests (causes flakiness)
kdmccormick Jan 2, 2024
a9adffd
test: stabilize LCB shuffling+sampling in tests (complex is still flaky)
kdmccormick Jan 2, 2024
d179801
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 2, 2024
b86b64f
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 2, 2024
653c2e7
test: making selection tests lms-only (wip)
kdmccormick Jan 3, 2024
594551e
feat: include children info in xblock api (#33977)
rayzhou-bit Jan 3, 2024
3cd1e50
test: selection tests are working, with a hack
kdmccormick Jan 3, 2024
870a9ef
Merge branch 'feat--Library-Content-Block-Reference' of github.com:op…
kdmccormick Jan 3, 2024
4ef1ea4
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 3, 2024
f1b701a
test: continue skipping lc-sync tests in LMS
kdmccormick Jan 3, 2024
77f8caa
test: fix cms tests
kdmccormick Jan 3, 2024
b243ade
test: better var names in selection tests
kdmccormick Jan 3, 2024
d34454b
refactor: 'valid_children' -> 'available'
kdmccormick Jan 3, 2024
a1f4a6b
test: selection tests work in both manual and non-manual modes now
kdmccormick Jan 3, 2024
0f83fcf
test: attempt at making selection tests run quicker with sharedmodule…
kdmccormick Jan 3, 2024
0715538
revert: test: attempt at making selection tests run quicker with shar…
kdmccormick Jan 3, 2024
9f4af9a
test; add docstring to a test helper
kdmccormick Jan 3, 2024
935257b
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 3, 2024
072c151
test: make selection test setup more verbose but also more straightfo…
kdmccormick Jan 4, 2024
45d8d38
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 4, 2024
ff08f25
test: better names and comments for selection tests
kdmccormick Jan 4, 2024
443af4d
test: in selection tests, test more behavior with fewer cases
kdmccormick Jan 4, 2024
651227f
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 4, 2024
c3c6205
test: add cases for: no selection available, toggling manual on/off
kdmccormick Jan 4, 2024
744e139
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 4, 2024
37196cd
fix: new editor + candidates_in_course
connorhaugh Jan 5, 2024
c41e247
fix: candidates are always library block usage keys (WIP)
kdmccormick Jan 11, 2024
2add8b8
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 11, 2024
6513953
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 12, 2024
a2c5de2
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 16, 2024
b1c3d16
fix: derive_key import and usage in LCB
kdmccormick Jan 16, 2024
aa72268
fix: candidates are UsageKeys from the source library; tests still fa…
kdmccormick Jan 16, 2024
de95995
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Jan 16, 2024
3285f2e
Merge remote-tracking branch 'upstream/master' into feat--Library-Con…
kdmccormick Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cms/djangoapps/contentstore/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def test_switch_to_unknown_source_library_preserves_settings(self):
self.assertEqual(resp.status_code, 200)

lc_block = modulestore().get_item(lc_block.location)

# Source library id should be set to the new bad one...
assert lc_block.source_library_id == bad_library_id
# ...but old source library version should be preserved...
Expand Down
19 changes: 19 additions & 0 deletions cms/djangoapps/contentstore/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ def use_add_game_block():
return ENABLE_ADD_GAME_BLOCK_FLAG.is_enabled()


# .. toggle_name: new_core_editors.use_new_library_content_editor
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: This flag enables the use of the new library xblock editor
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2023-10-30
# .. toggle_target_removal_date: 2025-1-30
# .. toggle_tickets: https://github.com/openedx/edx-platform/issues/33640
# .. toggle_warning:
ENABLE_NEW_LIBRARY_CONTENT_EDITOR_FLAG = WaffleFlag('new_core_editors.use_new_library_content_editor', __name__)


def use_new_library_content_editor():
"""
Returns a boolean if new library content block editor is enabled
"""
return ENABLE_NEW_LIBRARY_CONTENT_EDITOR_FLAG.is_enabled()


# .. toggle_name: contentstore.individualize_anonymous_user_id
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
Expand Down
1 change: 1 addition & 0 deletions cms/djangoapps/contentstore/views/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def container_handler(request, usage_key_string): # pylint: disable=too-many-st
'unit': unit,
'is_unit_page': is_unit_page,
'is_collapsible': is_library_xblock,
'is_library_xblock': is_library_xblock,
'subsection': subsection,
'section': section,
'position': index,
Expand Down
15 changes: 11 additions & 4 deletions cms/static/js/views/pages/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ function($, _, Backbone, gettext, BasePage,
this.unitOutlineView.render();

}
if (this.isLibraryContentPage) {
this.selectedLibraryComponents = [];
this.storedSelectedLibraryComponents = [];
this.getSelectedLibraryComponents();
}

this.listenTo(Backbone, 'move:onXBlockMoved', this.onXBlockMoved);
},
Expand Down Expand Up @@ -369,11 +374,13 @@ function($, _, Backbone, gettext, BasePage,
var useNewTextEditor = primaryHeader.attr('use-new-editor-text'),
useNewVideoEditor = primaryHeader.attr('use-new-editor-video'),
useNewProblemEditor = primaryHeader.attr('use-new-editor-problem'),
useNewLibraryContentEditor = primaryHeader.attr('use-new-editor-library-content'),
blockType = primaryHeader.attr('data-block-type');

if((useNewTextEditor === 'True' && blockType === 'html')
|| (useNewVideoEditor === 'True' && blockType === 'video')
|| (useNewProblemEditor === 'True' && blockType === 'problem')
|| (useNewLibraryContentEditor === 'True' && blockType === 'library_content')
) {
var destinationUrl = primaryHeader.attr('authoring_MFE_base_url') + '/' + blockType + '/' + encodeURI(primaryHeader.attr('data-usage-id'));
window.location.href = destinationUrl;
Expand Down Expand Up @@ -638,12 +645,11 @@ function($, _, Backbone, gettext, BasePage,
getSelectedLibraryComponents: function() {
var self = this;
var locator = this.$el.find('.studio-xblock-wrapper').data('locator');
console.log(ModuleUtils);
$.getJSON(
ModuleUtils.getUpdateUrl(locator) + '/handler/get_block_ids',
function(data) {
self.selectedLibraryComponents = Array.from(data.source_block_ids);
self.storedSelectedLibraryComponents = Array.from(data.source_block_ids);
self.selectedLibraryComponents = Array.from(data.candidates);
self.storedSelectedLibraryComponents = Array.from(data.candidates);
}
);
},
Expand All @@ -654,7 +660,7 @@ function($, _, Backbone, gettext, BasePage,
e.preventDefault();
$.postJSON(
ModuleUtils.getUpdateUrl(locator) + '/handler/submit_studio_edits',
{values: {source_block_ids: self.storedSelectedLibraryComponents}},
{values: {candidates: self.storedSelectedLibraryComponents}},
function() {
self.selectedLibraryComponents = Array.from(self.storedSelectedLibraryComponents);
self.toggleSaveButton();
Expand All @@ -664,6 +670,7 @@ function($, _, Backbone, gettext, BasePage,

toggleLibraryComponent: function(event) {
var componentId = $(event.target).closest('.studio-xblock-wrapper').data('locator');

var storeIndex = this.storedSelectedLibraryComponents.indexOf(componentId);
if (storeIndex > -1) {
this.storedSelectedLibraryComponents.splice(storeIndex, 1);
Expand Down
8 changes: 8 additions & 0 deletions cms/templates/container.html
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,15 @@ <h3 class="sr">${_("Page Actions")}</h3>
<span class="action-button-text">${_("Preview")}</span>
</a>
</li>

% else:
% if is_library_xblock:
<li class="action-item action-save nav-item">
<a href="#" class="button button-save action-button save-button is-hidden">
<span class="action-button-text">${_("Save changes")}</span>
</a>
</li>
% endif
kdmccormick marked this conversation as resolved.
Show resolved Hide resolved
<li class="action-item action-edit nav-item">
<a href="#" class="button button-edit action-button edit-button">
<span class="icon fa fa-pencil" aria-hidden="true"></span>
Expand Down
11 changes: 10 additions & 1 deletion cms/templates/studio_xblock_wrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
from openedx.core.djangolib.js_utils import (
dump_js_escaped_json, js_escaped_string
)
from cms.djangoapps.contentstore.toggles import use_new_text_editor, use_new_problem_editor, use_new_video_editor, use_video_gallery_flow, use_tagging_taxonomy_list_page
from cms.djangoapps.contentstore.toggles import(
use_new_text_editor,
use_new_problem_editor,
use_new_video_editor,
use_new_library_content_editor,
use_video_gallery_flow,
use_tagging_taxonomy_list_page,
)
%>
<%
use_new_editor_text = use_new_text_editor()
use_new_editor_video = use_new_video_editor()
use_new_editor_problem = use_new_problem_editor()
use_new_editor_library_content = use_new_library_content_editor()
use_new_video_gallery_flow = use_video_gallery_flow()
use_tagging = use_tagging_taxonomy_list_page()
xblock_url = xblock_studio_url(xblock)
Expand Down Expand Up @@ -67,6 +75,7 @@
use-new-editor-text = ${use_new_editor_text}
use-new-editor-video = ${use_new_editor_video}
use-new-editor-problem = ${use_new_editor_problem}
use-new-editor-library-content = ${use_new_editor_library_content}
use-video-gallery-flow = ${use_new_video_gallery_flow}
authoring_MFE_base_url = ${get_editor_page_base_url(xblock.location.course_key)}
data-block-type = ${xblock.scope_ids.block_type}
Expand Down
17 changes: 15 additions & 2 deletions lms/djangoapps/course_blocks/transformers/library_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def transform_block_filters(self, usage_info, block_structure):
if library_children:
all_library_children.update(library_children)
selected = []
mode = block_structure.get_xblock_field(block_key, 'mode')
shuffle = block_structure.get_xblock_field(block_key, 'shuffle')
manual = block_structure.get_xblock_field(block_key, 'manual')
max_count = block_structure.get_xblock_field(block_key, 'max_count')
if max_count < 0:
max_count = len(library_children)
Expand All @@ -98,9 +99,21 @@ def transform_block_filters(self, usage_info, block_structure):
if usage_key in library_children:
selected.append(selected_block)

#Get "canidate" blocks which have been manually selected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#Get "canidate" blocks which have been manually selected
# Get "candidate" blocks which have been manually picked by the author

NOT "SELECTED" 😄

candidates = state_dict.get('candidates', [])

# Update selected
previous_count = len(selected)
block_keys = LibraryContentBlock.make_selection(selected, library_children, max_count, mode)
block_keys = LibraryContentBlock.make_selection(
old_selected=list(map(tuple, selected)),
kdmccormick marked this conversation as resolved.
Show resolved Hide resolved
library_children=library_children,
candidates=[
child for child in library_children if [child.block_type, child.block_id] in candidates
],
max_count=max_count,
manual=manual,
shuffle=shuffle,
)
selected = block_keys['selected']

# Save back any changes
Expand Down
1 change: 1 addition & 0 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
from openedx.core.djangolib import blockstore_cache
from openedx.core.djangolib.blockstore_cache import BundleCache
from xmodule.library_root_xblock import LibraryRoot as LibraryRootV1

from xmodule.modulestore import ModuleStoreEnum
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
Expand Down
1 change: 1 addition & 0 deletions openedx/core/djangoapps/content_libraries/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def _sync_children(
source_blocks = []
library_key = dest_block.source_library_key
filter_children = (dest_block.capa_type != ANY_CAPA_TYPE_VALUE)

library = library_api.get_v1_or_v2_library(library_key, version=library_version)
if not library:
task.status.fail(f"Requested library {library_key} not found.")
Expand Down
Loading
Loading