create table that excludes enrollments from FBE

This commit is contained in:
Matthew Piatetsky
2019-10-29 11:29:03 -04:00
parent 5bf2a25842
commit c2774083ea
14 changed files with 84 additions and 40 deletions

View File

@@ -3,9 +3,10 @@ from __future__ import absolute_import
from experiments.models import ExperimentData
from openedx.features.course_duration_limits.config import EXPERIMENT_DATA_HOLDBACK_KEY, EXPERIMENT_ID
from student.models import FBEEnrollmentExclusion
def is_in_holdback(user):
def is_in_holdback(user, enrollment):
"""
Return true if given user is in holdback expermiment
"""
@@ -21,4 +22,8 @@ def is_in_holdback(user):
except ExperimentData.DoesNotExist:
pass
if enrollment is not None:
if FBEEnrollmentExclusion.objects.filter(enrollment=enrollment).exists():
return True
return in_holdback

View File

@@ -134,7 +134,7 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
return False
# check if user is in holdback
if user_variable_represents_correct_user and is_in_holdback(user):
if user_variable_represents_correct_user and is_in_holdback(user, enrollment):
return False
if not correct_modes_for_fbe(course_key, enrollment, user):

View File

@@ -78,9 +78,9 @@ class TestContentTypeGatingConfig(CacheIsolationTestCase):
user = self.user
course_key = self.course_overview.id
query_count = 7
if not already_enrolled or not pass_enrollment and already_enrolled:
query_count = 8
query_count = 8
if not already_enrolled and pass_enrollment or not pass_enrollment and already_enrolled:
query_count = 9
with self.assertNumQueries(query_count):
enabled = ContentTypeGatingConfig.enabled_for_enrollment(

View File

@@ -128,7 +128,7 @@ class CourseDurationLimitConfig(StackedConfigurationModel):
student_masquerade = is_masquerading_as_specific_student(user, course_key)
# check if user is in holdback
if (no_masquerade or student_masquerade) and is_in_holdback(user):
if (no_masquerade or student_masquerade) and is_in_holdback(user, enrollment):
return False
not_student_masquerade = is_masquerading and not student_masquerade

View File

@@ -84,9 +84,9 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase):
user = self.user
course_key = self.course_overview.id
query_count = 7
if pass_enrollment and already_enrolled:
query_count = 6
query_count = 8
if pass_enrollment and already_enrolled or not pass_enrollment and not already_enrolled:
query_count = 7
with self.assertNumQueries(query_count):
enabled = CourseDurationLimitConfig.enabled_for_enrollment(

View File

@@ -220,7 +220,7 @@ class TestCourseHomePage(CourseHomePageTestCase):
# Fetch the view and verify the query counts
# TODO: decrease query count as part of REVO-28
with self.assertNumQueries(97, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with self.assertNumQueries(106, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with check_mongo_calls(4):
url = course_home_url(self.course)
self.client.get(url)

View File

@@ -134,7 +134,7 @@ class TestCourseUpdatesPage(SharedModuleStoreTestCase):
# Fetch the view and verify that the query counts haven't changed
# TODO: decrease query count as part of REVO-28
with self.assertNumQueries(56, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with self.assertNumQueries(59, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with check_mongo_calls(4):
url = course_updates_url(self.course)
self.client.get(url)