feat: expose hide_from_toc field for course blocks in outline API (#33955)
These changes are part of the effort made to implement https://openedx.atlassian.net/wiki/spaces/OEPM/pages/3853975595/Feature+Enhancement+Proposal+Hide+Sections+from+course+outline
This commit is contained in:
committed by
GitHub
parent
fa66728a67
commit
4c0fba2063
@@ -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'
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user