-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: include children info in xblock api #33977
feat: include children info in xblock api #33977
Conversation
For others reading this: You mean are its children. The "selected" word here means something else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't be hard-coding special cases for the library_content block, or any other XBlock type, unless it's absolutely necessary. Is there a way you can get this API to return the data you need that doesn't involve an if LibraryContentBlock
conditional?
@kdmccormick I was looking at a |
The way to do it would be to actually include the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple small requests, then this should be good to go.
I haven't manually tested yet and there are no unit tests, so I trust you have manually tested it.
@@ -824,14 +834,16 @@ def get_block_info( | |||
xblock, | |||
rewrite_static_links=True, | |||
include_ancestor_info=False, | |||
include_child_info=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include_child_info=False, |
unused parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ty, I forgot to take this back out
): | ||
""" | ||
metadata, data, id representation of a leaf block fetcher. | ||
:param usage_key: A UsageKey | ||
""" | ||
with modulestore().bulk_operations(xblock.location.course_key): | ||
category = getattr(xblock, "category", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category = getattr(xblock, "category", "") |
unused variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to remove this as well
elif "childrenInfo" in fields: | ||
xblock = get_xblock(usage_key, request.user) | ||
children_info = _create_xblock_child_info( | ||
xblock, | ||
course_outline=None, | ||
graders=None, | ||
include_children_predicate=ALWAYS, | ||
is_concise=True | ||
) | ||
return JsonResponse(children_info) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better, thanks 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. My only request is that when you squash & merge, please beef up your commit message a bit.
This change will send child info when the xblock api is called. This allows the Library Content Editor Block to see the blocks that are selected for it.
What is the URL of this API? Does the new info require a new query param? Where is the corresponding frontend PR? Those are the sort of questions another dev would be thinking when they read your commit.
594551e
into
feat--Library-Content-Block-Reference
This change will send children info for when the xblock api is called with
/xblock/{blockId}?fields=childrenInfo
. This was created to allow the Library Content Editor Block to access the blocks of its selected library. The frontend PR can be found here: openedx/frontend-lib-content-components#411Example:
GET
http://localhost:18010/xblock/block-v1:edX+DemoX+Demo_Course+type@library_content+block@10391c53c21b4f439c1f3aed3525be89?fields=childrenInfo
returns: