Merge pull request #19461 from edx/bfiller/REVE-190
REVE:190 - check if user is in holdback before showing new track selection
This commit is contained in:
@@ -188,7 +188,10 @@ class ChooseModeView(View):
|
||||
"error": error,
|
||||
"responsive": True,
|
||||
"nav_hidden": True,
|
||||
"content_gating_enabled": ContentTypeGatingConfig.enabled_for_course(course_key=course_key),
|
||||
"content_gating_enabled": ContentTypeGatingConfig.enabled_for_enrollment(
|
||||
user=request.user,
|
||||
course_key=course_key
|
||||
),
|
||||
}
|
||||
context.update(
|
||||
get_experiment_user_metadata_context(
|
||||
|
||||
@@ -162,7 +162,7 @@ class TestGetBlocksQueryCounts(TestGetBlocksQueryCountsBase):
|
||||
self._get_blocks(
|
||||
course,
|
||||
expected_mongo_queries=0,
|
||||
expected_sql_queries=8 if with_storage_backing else 7,
|
||||
expected_sql_queries=9 if with_storage_backing else 8,
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
@@ -179,9 +179,9 @@ class TestGetBlocksQueryCounts(TestGetBlocksQueryCountsBase):
|
||||
clear_course_from_cache(course.id)
|
||||
|
||||
if with_storage_backing:
|
||||
num_sql_queries = 18
|
||||
num_sql_queries = 19
|
||||
else:
|
||||
num_sql_queries = 8
|
||||
num_sql_queries = 9
|
||||
|
||||
self._get_blocks(
|
||||
course,
|
||||
@@ -211,7 +211,7 @@ class TestQueryCountsWithIndividualOverrideProvider(TestGetBlocksQueryCountsBase
|
||||
self._get_blocks(
|
||||
course,
|
||||
expected_mongo_queries=0,
|
||||
expected_sql_queries=9 if with_storage_backing else 8,
|
||||
expected_sql_queries=10 if with_storage_backing else 9,
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
@@ -228,9 +228,9 @@ class TestQueryCountsWithIndividualOverrideProvider(TestGetBlocksQueryCountsBase
|
||||
clear_course_from_cache(course.id)
|
||||
|
||||
if with_storage_backing:
|
||||
num_sql_queries = 19
|
||||
num_sql_queries = 20
|
||||
else:
|
||||
num_sql_queries = 9
|
||||
num_sql_queries = 10
|
||||
|
||||
self._get_blocks(
|
||||
course,
|
||||
|
||||
@@ -436,8 +436,8 @@ class SelfPacedCourseInfoTestCase(LoginEnrollmentTestCase, SharedModuleStoreTest
|
||||
|
||||
def test_num_queries_instructor_paced(self):
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
self.fetch_course_info_with_queries(self.instructor_paced_course, 42, 3)
|
||||
self.fetch_course_info_with_queries(self.instructor_paced_course, 43, 3)
|
||||
|
||||
def test_num_queries_self_paced(self):
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
self.fetch_course_info_with_queries(self.self_paced_course, 42, 3)
|
||||
self.fetch_course_info_with_queries(self.self_paced_course, 43, 3)
|
||||
|
||||
@@ -176,10 +176,10 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
self.assertEquals(mock_block_structure_create.call_count, 1)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 33, True),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 33, False),
|
||||
(ModuleStoreEnum.Type.split, 3, 33, True),
|
||||
(ModuleStoreEnum.Type.split, 3, 33, False),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 34, True),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 34, False),
|
||||
(ModuleStoreEnum.Type.split, 3, 34, True),
|
||||
(ModuleStoreEnum.Type.split, 3, 34, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts(self, default_store, num_mongo_calls, num_sql_calls, create_multiple_subsections):
|
||||
@@ -191,8 +191,8 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
self._apply_recalculate_subsection_grade()
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 33),
|
||||
(ModuleStoreEnum.Type.split, 3, 33),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 34),
|
||||
(ModuleStoreEnum.Type.split, 3, 34),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts_dont_change_with_more_content(self, default_store, num_mongo_calls, num_sql_calls):
|
||||
@@ -237,8 +237,8 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 17),
|
||||
(ModuleStoreEnum.Type.split, 3, 17),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 18),
|
||||
(ModuleStoreEnum.Type.split, 3, 18),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_persistent_grades_not_enabled_on_course(self, default_store, num_mongo_queries, num_sql_queries):
|
||||
@@ -252,8 +252,8 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
self.assertEqual(len(PersistentSubsectionGrade.bulk_read_grades(self.user.id, self.course.id)), 0)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 34),
|
||||
(ModuleStoreEnum.Type.split, 3, 34),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 35),
|
||||
(ModuleStoreEnum.Type.split, 3, 35),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_persistent_grades_enabled_on_course(self, default_store, num_mongo_queries, num_sql_queries):
|
||||
|
||||
@@ -108,25 +108,26 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
|
||||
if user_variable_represents_correct_user and has_staff_roles(user, course_key):
|
||||
return False
|
||||
|
||||
# check if user is in holdback
|
||||
is_in_holdback = False
|
||||
if user and user.is_authenticated and (user_variable_represents_correct_user):
|
||||
try:
|
||||
holdback_value = ExperimentData.objects.get(
|
||||
user=user,
|
||||
experiment_id=EXPERIMENT_ID,
|
||||
key=EXPERIMENT_DATA_HOLDBACK_KEY,
|
||||
).value
|
||||
is_in_holdback = holdback_value == 'True'
|
||||
except ExperimentData.DoesNotExist:
|
||||
pass
|
||||
if is_in_holdback:
|
||||
return False
|
||||
|
||||
# enrollment might be None if the user isn't enrolled. In that case,
|
||||
# return enablement as if the user enrolled today
|
||||
if enrollment is None:
|
||||
return cls.enabled_for_course(course_key=course_key, target_datetime=timezone.now())
|
||||
else:
|
||||
# TODO: clean up as part of REV-100
|
||||
is_in_holdback = False
|
||||
if user and (user_variable_represents_correct_user):
|
||||
try:
|
||||
holdback_value = ExperimentData.objects.get(
|
||||
user=user,
|
||||
experiment_id=EXPERIMENT_ID,
|
||||
key=EXPERIMENT_DATA_HOLDBACK_KEY,
|
||||
).value
|
||||
is_in_holdback = holdback_value == 'True'
|
||||
except ExperimentData.DoesNotExist:
|
||||
pass
|
||||
if is_in_holdback:
|
||||
return False
|
||||
current_config = cls.current(course_key=enrollment.course_id)
|
||||
return current_config.enabled_as_of_datetime(target_datetime=enrollment.created)
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase):
|
||||
course_key = self.course_overview.id
|
||||
|
||||
query_count = 8
|
||||
if not pass_enrollment and already_enrolled:
|
||||
if not already_enrolled or not pass_enrollment and already_enrolled:
|
||||
query_count = 9
|
||||
|
||||
with self.assertNumQueries(query_count):
|
||||
|
||||
Reference in New Issue
Block a user