diff --git a/lms/djangoapps/course_api/blocks/transformers/block_completion.py b/lms/djangoapps/course_api/blocks/transformers/block_completion.py index 38108251148da02f779e7a33e0ac745495a6ed02..65bd3738e59e183967c794b55f7eee0c4037d2cc 100644 --- a/lms/djangoapps/course_api/blocks/transformers/block_completion.py +++ b/lms/djangoapps/course_api/blocks/transformers/block_completion.py @@ -45,6 +45,17 @@ class BlockCompletionTransformer(BlockStructureTransformer): def collect(cls, block_structure): block_structure.request_xblock_fields('completion_mode') + @staticmethod + def _is_block_excluded(block_structure, block_key): + """ + Checks whether block's completion method is of `EXCLUDED` type. + """ + completion_mode = block_structure.get_xblock_field( + block_key, 'completion_mode' + ) + + return completion_mode == CompletionMode.EXCLUDED + def mark_complete(self, complete_course_blocks, latest_complete_block_key, block_key, block_structure): """ Helper function to mark a block as 'complete' as dictated by @@ -58,14 +69,13 @@ class BlockCompletionTransformer(BlockStructureTransformer): """ if block_key in complete_course_blocks: block_structure.override_xblock_field(block_key, self.COMPLETE, True) - if block_key == latest_complete_block_key: + if str(block_key) == str(latest_complete_block_key): block_structure.override_xblock_field(block_key, self.RESUME_BLOCK, True) children = block_structure.get_children(block_key) - non_discussion_children = (child_key for child_key in children - if block_structure.get_xblock_field(child_key, 'category') != 'discussion') all_children_complete = all(block_structure.get_xblock_field(child_key, self.COMPLETE) - for child_key in non_discussion_children) + for child_key in children + if not self._is_block_excluded(block_structure, child_key)) if children and all_children_complete: block_structure.override_xblock_field(block_key, self.COMPLETE, True) diff --git a/openedx/features/course_experience/tests/views/test_course_home.py b/openedx/features/course_experience/tests/views/test_course_home.py index b5850b8cd26f5bec153e29cbbc45e4e5836f73f0..3dd3247dae86a3b54ff68d9088bd5615957b3e1a 100644 --- a/openedx/features/course_experience/tests/views/test_course_home.py +++ b/openedx/features/course_experience/tests/views/test_course_home.py @@ -208,7 +208,7 @@ class TestCourseHomePage(CourseHomePageTestCase): # lint-amnesty, pylint: disab # Fetch the view and verify the query counts # TODO: decrease query count as part of REVO-28 - with self.assertNumQueries(78, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST): + with self.assertNumQueries(79, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST): with check_mongo_calls(4): url = course_home_url(self.course) self.client.get(url)