diff --git a/lms/djangoapps/course_api/blocks/serializers.py b/lms/djangoapps/course_api/blocks/serializers.py index ac031600a02c..666724e357af 100644 --- a/lms/djangoapps/course_api/blocks/serializers.py +++ b/lms/djangoapps/course_api/blocks/serializers.py @@ -57,6 +57,7 @@ def __init__( SupportedFieldType('has_scheduled_content'), SupportedFieldType('weight'), SupportedFieldType('show_correctness'), + SupportedFieldType('hide_from_toc'), # 'student_view_data' SupportedFieldType(StudentViewTransformer.STUDENT_VIEW_DATA, StudentViewTransformer), # 'student_view_multi_device' diff --git a/lms/djangoapps/course_home_api/outline/serializers.py b/lms/djangoapps/course_home_api/outline/serializers.py index 29b46d30e967..db6cbdf3a1ab 100644 --- a/lms/djangoapps/course_home_api/outline/serializers.py +++ b/lms/djangoapps/course_home_api/outline/serializers.py @@ -54,6 +54,7 @@ def get_blocks(self, block): # pylint: disable=missing-function-docstring 'resume_block': block.get('resume_block', False), 'type': block_type, 'has_scheduled_content': block.get('has_scheduled_content'), + 'hide_from_toc': block.get('hide_from_toc'), }, } for child in children: diff --git a/lms/djangoapps/course_home_api/outline/tests/test_view.py b/lms/djangoapps/course_home_api/outline/tests/test_view.py index f02ad646ef48..eebaf19cf65b 100644 --- a/lms/djangoapps/course_home_api/outline/tests/test_view.py +++ b/lms/djangoapps/course_home_api/outline/tests/test_view.py @@ -404,6 +404,16 @@ def test_user_has_passing_grade(self): assert response.status_code == 200 assert response.data['user_has_passing_grade'] is True + def test_hide_from_toc_field(self): + """ + Test that the hide_from_toc field is returned in the response. + """ + CourseEnrollment.enroll(self.user, self.course.id) + response = self.client.get(self.url) + assert response.status_code == 200 + for block in response.data["course_blocks"]["blocks"].values(): + assert "hide_from_toc" in block + def assert_can_enroll(self, can_enroll): response = self.client.get(self.url) assert response.status_code == 200 diff --git a/openedx/features/course_experience/utils.py b/openedx/features/course_experience/utils.py index d58b54f6139f..4675d0a974e0 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -115,6 +115,7 @@ def recurse_mark_auth_denial(block): 'completion', 'complete', 'resume_block', + 'hide_from_toc', ], allow_start_dates_in_future=allow_start_dates_in_future, )