From 51c5c24895d029a646e0ab00cce6f4b6bd942ba3 Mon Sep 17 00:00:00 2001 From: Daniel Valenzuela Date: Mon, 26 Feb 2024 23:06:13 -0300 Subject: [PATCH] feat: handle optional blocks in verticals --- CHANGELOG.rst | 4 ++++ completion/__init__.py | 2 +- completion/services.py | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ea60aa9d..bd153061 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,10 @@ Change Log Unreleased ~~~~~~~~~~ +[4.5.0] - 2024-02-26 +~~~~~~~~~~~~~~~~~~~~ +* Ignore optional blocks in non-optional verticals + [4.4.1] - 2023-10-27 ~~~~~~~~~~~~~~~~~~~~ * Fix RemovedInDjango41Warning by removing `django_app_config` diff --git a/completion/__init__.py b/completion/__init__.py index 8050a702..142bd91a 100644 --- a/completion/__init__.py +++ b/completion/__init__.py @@ -3,4 +3,4 @@ """ -__version__ = '4.4.1' +__version__ = '4.5.0' diff --git a/completion/services.py b/completion/services.py index 14174e28..b5fbd7d5 100644 --- a/completion/services.py +++ b/completion/services.py @@ -117,8 +117,14 @@ def vertical_is_complete(self, item): if not self.completion_tracking_enabled(): return None + optional_vertical = getattr(item, "optional_content", False) + # this is temporary local logic and will be removed when the whole course tree is included in completion - child_locations = [child.scope_ids.usage_id for child in self.get_completable_children(item)] + child_locations = [ + child.scope_ids.usage_id for child in self.get_completable_children(item) + # for non-optional verticals, only include non-optional children + if optional_vertical or not getattr(child, "optional_content", False) + ] completions = self.get_completions(child_locations) for child_location in child_locations: if completions[child_location] < 1.0: