feat: return navigation disabled as sequence metadata (#34049)

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
This commit is contained in:
Maria Grimaldi
2024-03-12 11:21:16 -04:00
committed by GitHub
parent cd5c4c992b
commit 794c6781fa
2 changed files with 20 additions and 0 deletions

View File

@@ -376,8 +376,19 @@ class SequenceBlock(
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):
"""

View File

@@ -443,6 +443,15 @@ class SequenceBlockTestCase(XModuleXmlImportTest):
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',
))