feat: support static reference in LibraryContentBlock - #33511
feat: support static reference in LibraryContentBlock#33511connorhaugh wants to merge 128 commits into
Conversation
Rather than implementing V2-library and static-library-reference support in a new block, we will be enhancing the existing `LibraryContentBlock` in-place. Relevant ADR PR: #33231
Co-Authored-By: Connor Haugh <chaugh@2u.com> Co-Authored-By: Eugene Dyudyunov <evgen.dyudyunov@raccoongang.com>
…m into kdmccormick/library-content-v2
...per comment in cms/djangoapps/contentstore/tasks.py.
This fixes an exception that was raised in the background whenever
the update_children_task was started:
Traceback (most recent call last):
File "/openedx/venv/lib/python3.8/site-packages/celery/utils/dispatch/signal.py", line 276, in send
response = receiver(signal=self, sender=sender, **named)
File "/openedx/venv/lib/python3.8/site-packages/user_tasks/signals.py", line 215, in start_user_task
sender.status.start()
File "/openedx/venv/lib/python3.8/site-packages/user_tasks/tasks.py", line 84, in status
name = self.generate_name(arguments_dict)
File "/openedx/edx-platform/openedx/core/djangoapps/content_libraries/tasks.py", line 274, in generate_name
key = arguments_dict['dest_block_key']
KeyError: 'dest_block_key'
Just like ./common/ and ./openedx/, the unit tests in ./xmodule/
validate behavior in both LMS and CMS. In order to fully test
./xmodule/, we need to run its tests in both contexts.
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.
This reverts commit f1370d0.
…tent-Block-Reference
|
Sandbox deployment successful. Sandbox LMS is available at https://pr-33511-139931.sandboxes.opencraft.hosting Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5856406501-tutor-config.yml |
|
Sandbox deployment successful. Sandbox LMS is available at https://pr-33511-139931.sandboxes.opencraft.hosting Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5862306046-tutor-config.yml |
kdmccormick
left a comment
There was a problem hiding this comment.
@connorhaugh Just an FYI on some recent changes I've pushed.
| self.runtime.publish(self, f"edx.librarycontentblock.content.{event_name}", event_data) | ||
| self._last_event_result_count = len(result) # pylint: disable=attribute-defined-outside-init | ||
|
|
||
| def available_children(self) -> list[tuple[str, str]]: |
There was a problem hiding this comment.
I exposed this as a public method so that unit tests can use it without duplicating the same logic.
The underlying implementation is still a static method so that make_selection can use it.
| ) | ||
|
|
||
| @classmethod | ||
| def _available_children( |
There was a problem hiding this comment.
This was previously "_get_valid_children". I renamed it "_available_children" because it struck me as more self-explanatory -- these are the children which are available for selection.
| children = [(child.block_type, child.block_id) for child in library_children] | ||
| if manual: | ||
| return [candidate for candidate in candidates if candidate in children] | ||
| else: | ||
| return children |
There was a problem hiding this comment.
This is one of the recent "bugs" I fixed, if you'd call it that.
Before, when manual==True, we would return the whole candidates list, regardless of whether all of those candidates appeared as block children.
Now, when manual=True, we return the candidates which are also children. That way, if (for some reason) child is removed but the candidate entry is not, we don't get ItemNotFound errors from modulestore. I'm not sure when that issue would happen, but it seems like a reasonable safeguard to have in place.
|
Sandbox deployment successful. Sandbox LMS is available at https://pr-33511-139931.sandboxes.opencraft.hosting Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5862781415-tutor-config.yml |
|
Sandbox deployment successful. Sandbox LMS is available at https://pr-33511-139931.sandboxes.opencraft.hosting Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5863446981-tutor-config.yml |
|
Sandbox deployment failed. Check failure logs here https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5872898626.log Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5872898626-tutor-config.yml Please check the settings and requirements and retry deployment by updating the pull request description or pushing a new commit |
|
Sandbox deployment successful. Sandbox LMS is available at https://pr-33511-139931.sandboxes.opencraft.hosting Instance Tutor config : https://axim-sandbox-build-logs-4626178240.nyc3.digitaloceanspaces.com/pr-33511-139931-51564656-5872898607-tutor-config.yml |
…tent-Block-Reference
…tent-Block-Reference
…tent-Block-Reference
|
Closing, as we will be implementing static reference on a per-component basis rather than though the LibraryContentBlock. |
Requires:
Description
This PR adds the ability for course authors to reference specific pieces of content from a content library in their course using the library xblock. It does so for v1 and v2 xblocks.
It does so by implementing the changes described in the ADR which describes the new desired schema for the block
Testing instructions
To test this PR:
Create a v1 and a v2 content library, "v1 lib" and "v2 lib." Make sure each has some problems in it.
In a unit in a course, create 2 library blocks. associate v1 lib with the first block, and v2 lib with the second.
Test Randomized content behavior: with shuffle = true and max_count = 1, save and publish the blocks.
expected: you should see 1 block at random per user per block. Try again with max_count = 2, and then max_count = -1. You should then see 2 and all blocks respectively.
Test Specific content reference behavior. With shuffle = false and manual = true, select one piece of content from the v1 and v2 libs. Republish. This content should then be displayed to the user.