Skip to content

Commit

Permalink
feat: return navigation disabled as sequence metadata (#34049)
Browse files Browse the repository at this point in the history
Return navigation disabled as sequence metadata when Hide From TOC
is enabled, so the student cannot navigate to another sequences in
the course outline.
https://openedx.atlassian.net/wiki/spaces/OEPM/pages/3853975595/Feature+Enhancement+Proposal+Hide+Sections+from+course+outline
  • Loading branch information
mariajgrimaldi authored Mar 12, 2024
1 parent cd5c4c9 commit 794c678
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions xmodule/seq_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,19 @@ def get_metadata(self, view=STUDENT_VIEW, context=None):
meta['display_name'] = self.display_name_with_default
meta['format'] = getattr(self, 'format', '')
meta['is_hidden_after_due'] = is_hidden_after_due
meta['navigation_disabled'] = self.is_sequence_navigation_disabled()
return meta

def is_sequence_navigation_disabled(self):
"""
Returns whether the navigation to other sequences is disabled.
As of today, this is used to disable the navigation to other sequences when the
current sequence is configured as Hide from Table of Contents. But it can be
extended to other use cases in the future.
"""
return getattr(self, "hide_from_toc", False)

@classmethod
def verify_current_content_visibility(cls, date, hide_after_date):
"""
Expand Down
9 changes: 9 additions & 0 deletions xmodule/tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ def test_get_metadata(self):
assert metadata['tag'] == 'sequential'
assert metadata['display_name'] == self.sequence_3_1.display_name_with_default

def test_get_metadata_navigation_disabled(self):
"""Test that the sequence metadata is returned correctly when navigation is disabled"""
self.sequence_3_1.hide_from_toc = True
metadata = self.sequence_3_1.get_metadata()
assert len(metadata['items']) == 3
assert metadata['tag'] == 'sequential'
assert metadata['display_name'] == self.sequence_3_1.display_name_with_default
assert metadata['navigation_disabled'] is True

@override_settings(FIELD_OVERRIDE_PROVIDERS=(
'openedx.features.content_type_gating.field_override.ContentTypeGatingFieldOverride',
))
Expand Down

0 comments on commit 794c678

Please sign in to comment.