Merge pull request #19033 from edx/hammad/WL-1798
Hammad/WL-1798 Participants not able to move on to course assignments from pre-assessment
This commit is contained in:
@@ -470,7 +470,8 @@ def get_subsection_completion_percentage(subsection_usage_key, user):
|
||||
block, 'completion_mode'
|
||||
)
|
||||
|
||||
if completion_mode not in (CompletionMode.AGGREGATOR, CompletionMode.EXCLUDED):
|
||||
if completion_mode not in (CompletionMode.AGGREGATOR, CompletionMode.EXCLUDED) \
|
||||
and not block.block_type == 'html':
|
||||
completable_blocks.append(block)
|
||||
|
||||
if not completable_blocks:
|
||||
|
||||
@@ -3,6 +3,7 @@ Tests for the gating API
|
||||
"""
|
||||
import unittest
|
||||
|
||||
from completion.models import BlockCompletion
|
||||
from mock import patch, Mock
|
||||
from ddt import ddt, data, unpack
|
||||
from django.conf import settings
|
||||
@@ -60,6 +61,13 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
display_name='untitled sequential 2'
|
||||
)
|
||||
|
||||
# create vertical
|
||||
self.vertical = ItemFactory.create(
|
||||
parent_location=self.seq1.location,
|
||||
category='vertical',
|
||||
display_name='untitled vertical 1'
|
||||
)
|
||||
|
||||
self.generic_milestone = {
|
||||
'name': 'Test generic milestone',
|
||||
'namespace': unicode(self.seq1.location),
|
||||
@@ -221,6 +229,41 @@ class TestGatingApi(ModuleStoreTestCase, MilestonesTestCaseMixin):
|
||||
gating_api.is_gate_fulfilled(self.course.id, self.seq1.location, student.id), is_gate_fulfilled
|
||||
)
|
||||
|
||||
@data(
|
||||
(1, 1, 100),
|
||||
(0, 0, 0),
|
||||
(1, 0, 100),
|
||||
(0, 1, 0),
|
||||
)
|
||||
@unpack
|
||||
def test_get_subsection_completion_percentage(self, user_problem_completion, user_html_completion,
|
||||
expected_completion_percentage):
|
||||
"""
|
||||
Test if gating_api.get_subsection_completion_percentage returns expected completion percentage
|
||||
|
||||
Note:
|
||||
html blocks are ignored in computation of completion_percentage,so it should not affect result.
|
||||
|
||||
"""
|
||||
student = UserFactory(is_staff=False)
|
||||
problem_block = ItemFactory.create(
|
||||
parent_location=self.vertical.location,
|
||||
category='problem',
|
||||
display_name='some problem'
|
||||
)
|
||||
html_block = ItemFactory.create(
|
||||
parent_location=self.vertical.location,
|
||||
category='html',
|
||||
display_name='some html block'
|
||||
)
|
||||
with patch.object(BlockCompletion, 'get_course_completions') as course_block_completions_mock:
|
||||
course_block_completions_mock.return_value = {
|
||||
problem_block.location: user_problem_completion,
|
||||
html_block.location: user_html_completion,
|
||||
}
|
||||
completion_percentage = gating_api.get_subsection_completion_percentage(self.seq1.location, student)
|
||||
self.assertEqual(completion_percentage, expected_completion_percentage)
|
||||
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
|
||||
def test_compute_is_prereq_met(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user