Skip to content
Snippets Groups Projects
Unverified Commit a5691b7c authored by Zia Fazal's avatar Zia Fazal Committed by GitHub
Browse files

Merge pull request #18727 from edx/ziafazal/gating-exclude-non-completable

exclude non completable blocks when calculating completion percentage
parents 1eba936a 1d4b62ad
No related branches found
No related tags found
No related merge requests found
......@@ -100,6 +100,17 @@ class TestGatedContent(MilestonesTestCaseMixin, SharedModuleStoreTestCase):
category='problem',
display_name='gating problem 1',
)
# add a discussion block to the prerequisite subsection
# this should give us ability to test gating with blocks
# which needs to be excluded from completion tracking
ItemFactory.create(
parent_location=cls.seq1.location,
category="discussion",
discussion_id="discussion 1",
discussion_category="discussion category",
discussion_target="discussion target",
)
cls.gated_prob2 = ItemFactory.create(
parent_location=cls.seq2.location,
category='problem',
......
......@@ -16,6 +16,7 @@ from milestones import api as milestones_api
from opaque_keys.edx.keys import UsageKey
from openedx.core.lib.gating.exceptions import GatingValidationError
from util import milestones_helpers
from xblock.completable import XBlockCompletionMode as CompletionMode
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
......@@ -463,10 +464,15 @@ def get_subsection_completion_percentage(subsection_usage_key, user):
try:
subsection_structure = get_course_blocks(user, subsection_usage_key)
if any(subsection_structure):
completable_blocks = [
block for block in subsection_structure
if block.block_type not in ['chapter', 'sequential', 'vertical']
]
completable_blocks = []
for block in subsection_structure:
completion_mode = subsection_structure.get_xblock_field(
block, 'completion_mode'
)
if completion_mode not in (CompletionMode.AGGREGATOR, CompletionMode.EXCLUDED):
completable_blocks.append(block)
if not completable_blocks:
return 0
subsection_completion_total = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment