From 198103635cfdf8ba205a47e057dc29b826877f8d Mon Sep 17 00:00:00 2001 From: Muhammad Adeel Tajamul <77053848+muhammadadeeltajamul@users.noreply.github.com> Date: Fri, 24 Mar 2023 08:05:45 +0500 Subject: [PATCH] fix: remove discussion xblocks from unit children (#31964) --- lms/djangoapps/course_api/blocks/utils.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lms/djangoapps/course_api/blocks/utils.py b/lms/djangoapps/course_api/blocks/utils.py index 7950f0a0be..3a9fea117c 100644 --- a/lms/djangoapps/course_api/blocks/utils.py +++ b/lms/djangoapps/course_api/blocks/utils.py @@ -28,12 +28,13 @@ def filter_discussion_xblocks_from_response(response, course_key): # Removing reference of discussion xblocks from unit # These references needs to be removed because they no longer exist for _, block_data in filtered_blocks.items(): - descendants = block_data.get('descendants', []) - if descendants: - descendants = [ - descendant for descendant in descendants - if descendant not in discussion_xblocks - ] - block_data['descendants'] = descendants + for key in ['descendants', 'children']: + descendants = block_data.get(key, []) + if descendants: + descendants = [ + descendant for descendant in descendants + if descendant not in discussion_xblocks + ] + block_data[key] = descendants response.data['blocks'] = filtered_blocks return response