Ignore enrollment date for FBE when masquerading
This commit is contained in:
@@ -847,7 +847,7 @@ class CourseOverviewAccessTestCase(ModuleStoreTestCase):
|
||||
num_queries = 1
|
||||
elif user_attr_name == 'user_normal' and action == 'see_exists':
|
||||
if course_attr_name == 'course_started':
|
||||
num_queries = 6
|
||||
num_queries = 7
|
||||
else:
|
||||
# checks staff role and enrollment data
|
||||
num_queries = 2
|
||||
|
||||
@@ -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, 43, 3)
|
||||
self.fetch_course_info_with_queries(self.instructor_paced_course, 44, 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, 43, 3)
|
||||
self.fetch_course_info_with_queries(self.self_paced_course, 44, 3)
|
||||
|
||||
@@ -125,7 +125,8 @@ class ContentTypeGatingConfig(StackedConfigurationModel):
|
||||
|
||||
# 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:
|
||||
# Also, ignore enrollment creation date if the user is masquerading.
|
||||
if enrollment is None or not no_masquerade:
|
||||
return cls.enabled_for_course(course_key=course_key, target_datetime=timezone.now())
|
||||
else:
|
||||
current_config = cls.current(course_key=enrollment.course_id)
|
||||
|
||||
@@ -15,7 +15,7 @@ from course_modes.models import CourseMode
|
||||
from lms.djangoapps.courseware.access_response import AccessError
|
||||
from lms.djangoapps.courseware.access_utils import ACCESS_GRANTED
|
||||
from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link
|
||||
from lms.djangoapps.courseware.masquerade import get_course_masquerade, is_masquerading_as_student
|
||||
from lms.djangoapps.courseware.masquerade import get_course_masquerade, is_masquerading_as_specific_student
|
||||
from openedx.core.djangoapps.catalog.utils import get_course_run_details
|
||||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
|
||||
from openedx.core.djangoapps.util.user_messages import PageLevelMessages
|
||||
@@ -123,7 +123,7 @@ def register_course_expired_message(request, course):
|
||||
if not expiration_date:
|
||||
return
|
||||
|
||||
if is_masquerading_as_student(request.user, course.id) and timezone.now() > expiration_date:
|
||||
if is_masquerading_as_specific_student(request.user, course.id) and timezone.now() > expiration_date:
|
||||
upgrade_message = _('This learner does not have access to this course. '
|
||||
'Their access expired on {expiration_date}.')
|
||||
PageLevelMessages.register_warning_message(
|
||||
|
||||
@@ -129,27 +129,29 @@ class CourseDurationLimitConfig(StackedConfigurationModel):
|
||||
elif has_staff_roles(user, course_key):
|
||||
return False
|
||||
|
||||
no_masquerade = get_course_masquerade(user, course_key) is None
|
||||
is_in_holdback = False
|
||||
student_masquerade = is_masquerading_as_specific_student(user, course_key)
|
||||
# TODO: clean up as part of REV-100
|
||||
if user and user.username and (no_masquerade or student_masquerade):
|
||||
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:
|
||||
# Also, ignore enrollment creation date if the user is masquerading.
|
||||
if enrollment is None or not no_masquerade:
|
||||
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
|
||||
no_masquerade = get_course_masquerade(user, course_key) is None
|
||||
student_masquerade = is_masquerading_as_specific_student(user, course_key)
|
||||
if user and (no_masquerade or student_masquerade):
|
||||
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)
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class TestCourseDurationLimitConfig(CacheIsolationTestCase):
|
||||
course_key = self.course_overview.id
|
||||
|
||||
query_count = 8
|
||||
if not pass_enrollment and already_enrolled:
|
||||
if not pass_enrollment:
|
||||
query_count = 9
|
||||
|
||||
with self.assertNumQueries(query_count):
|
||||
|
||||
Reference in New Issue
Block a user