diff --git a/lms/djangoapps/course_api/blocks/serializers.py b/lms/djangoapps/course_api/blocks/serializers.py index ac031600a0..666724e357 100644 --- a/lms/djangoapps/course_api/blocks/serializers.py +++ b/lms/djangoapps/course_api/blocks/serializers.py @@ -57,6 +57,7 @@ SUPPORTED_FIELDS = [ 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 29b46d30e9..db6cbdf3a1 100644 --- a/lms/djangoapps/course_home_api/outline/serializers.py +++ b/lms/djangoapps/course_home_api/outline/serializers.py @@ -54,6 +54,7 @@ class CourseBlockSerializer(serializers.Serializer): '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 f02ad646ef..eebaf19cf6 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 @@ class OutlineTabTestViews(BaseCourseHomeTests): 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 d58b54f613..4675d0a974 100644 --- a/openedx/features/course_experience/utils.py +++ b/openedx/features/course_experience/utils.py @@ -115,6 +115,7 @@ def get_course_outline_block_tree(request, course_id, user=None, allow_start_dat 'completion', 'complete', 'resume_block', + 'hide_from_toc', ], allow_start_dates_in_future=allow_start_dates_in_future, )