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. |
kdmccormick
left a comment
There was a problem hiding this comment.
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 |
kdmccormick
left a comment
There was a problem hiding this comment.
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.
| xblock, | ||
| rewrite_static_links=True, | ||
| include_ancestor_info=False, | ||
| include_child_info=False, |
There was a problem hiding this comment.
| include_child_info=False, |
unused parameter?
There was a problem hiding this comment.
Ty, I forgot to take this back out
| :param usage_key: A UsageKey | ||
| """ | ||
| with modulestore().bulk_operations(xblock.location.course_key): | ||
| category = getattr(xblock, "category", "") |
There was a problem hiding this comment.
| category = getattr(xblock, "category", "") |
unused variable?
There was a problem hiding this comment.
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) |
kdmccormick
left a comment
There was a problem hiding this comment.
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.
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-unsupported/frontend-lib-content-components#411Example:
GET
http://localhost:18010/xblock/block-v1:edX+DemoX+Demo_Course+type@library_content+block@10391c53c21b4f439c1f3aed3525be89?fields=childrenInforeturns: