Merge pull request #20238 from edx/REVMI-149

[REVMI-149] remove experiment code
This commit is contained in:
Matthew Piatetsky
2019-04-17 13:57:01 -04:00
committed by GitHub
4 changed files with 29 additions and 80 deletions

View File

@@ -1064,23 +1064,6 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
self.assertEqual(enrollment.mode, mode) self.assertEqual(enrollment.mode, mode)
self.assertEqual(enrollment.attributes.get(namespace='order', name='order_number').value, order_number) self.assertEqual(enrollment.attributes.get(namespace='order', name='order_number').value, order_number)
# Updating an enrollment should update attributes (for audit mode enrollments also)
order_number = 'EDX-3000'
enrollment_attributes = [{
'namespace': 'order',
'name': 'order_number',
'value': order_number,
}]
self.assert_enrollment_status(
as_server=True,
mode='audit',
enrollment_attributes=enrollment_attributes
)
enrollment.refresh_from_db()
self.assertTrue(enrollment.is_active)
self.assertEqual(enrollment.mode, mode)
self.assertEqual(enrollment.attributes.get(namespace='order', name='order_number').value, order_number)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms') @unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', 'Test only valid in lms')
class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestCase): class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestCase):

View File

@@ -747,16 +747,13 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
mode_changed = enrollment and mode is not None and enrollment['mode'] != mode mode_changed = enrollment and mode is not None and enrollment['mode'] != mode
active_changed = enrollment and is_active is not None and enrollment['is_active'] != is_active active_changed = enrollment and is_active is not None and enrollment['is_active'] != is_active
missing_attrs = [] missing_attrs = []
audit_with_order = False
if enrollment_attributes: if enrollment_attributes:
actual_attrs = [ actual_attrs = [
u"{namespace}:{name}".format(**attr) u"{namespace}:{name}".format(**attr)
for attr in enrollment_attributes for attr in enrollment_attributes
] ]
missing_attrs = set(REQUIRED_ATTRIBUTES.get(mode, [])) - set(actual_attrs) missing_attrs = set(REQUIRED_ATTRIBUTES.get(mode, [])) - set(actual_attrs)
audit_with_order = mode == 'audit' and 'order:order_number' in actual_attrs if has_api_key_permissions and (mode_changed or active_changed):
# Remove audit_with_order when no longer needed - implemented for REV-141
if has_api_key_permissions and (mode_changed or active_changed or audit_with_order):
if mode_changed and active_changed and not is_active: if mode_changed and active_changed and not is_active:
# if the requester wanted to deactivate but specified the wrong mode, fail # if the requester wanted to deactivate but specified the wrong mode, fail
# the request (on the assumption that the requester had outdated information # the request (on the assumption that the requester had outdated information

View File

@@ -18,7 +18,6 @@ from courseware.courses import get_current_child
from courseware.model_data import FieldDataCache from courseware.model_data import FieldDataCache
from courseware.module_render import get_module_for_descriptor from courseware.module_render import get_module_for_descriptor
from courseware.views.index import save_positions_recursively_up from courseware.views.index import save_positions_recursively_up
from experiments.models import ExperimentData, ExperimentKeyValue
from lms.djangoapps.courseware.access_utils import ACCESS_GRANTED from lms.djangoapps.courseware.access_utils import ACCESS_GRANTED
from mobile_api.utils import API_V05 from mobile_api.utils import API_V05
from openedx.features.course_duration_limits.access import check_course_expired from openedx.features.course_duration_limits.access import check_course_expired
@@ -289,44 +288,6 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
""" """
return check_org is None or (check_org.lower() == course_org.lower()) return check_org is None or (check_org.lower() == course_org.lower())
def hide_course_for_enrollment_fee_experiment(self, user, enrollment, experiment_id=9):
"""
Hide enrolled courses from mobile app as part of REV-73/REV-19
"""
course_key = enrollment.course_overview.id
try:
courses_excluded_from_mobile = ExperimentKeyValue.objects.get(
experiment_id=10,
key="mobile_app_exclusion"
).value
courses_excluded_from_mobile = json.loads(courses_excluded_from_mobile.replace('\r', '').replace('\n', ''))
if enrollment.mode == 'audit' and str(course_key) in courses_excluded_from_mobile.keys():
activationTime = dateparse.parse_datetime(courses_excluded_from_mobile[str(course_key)])
if activationTime and enrollment.created and enrollment.created > activationTime:
return True
except (ExperimentKeyValue.DoesNotExist, AttributeError):
pass
try:
ExperimentData.objects.get(
user=user,
experiment_id=experiment_id,
key='enrolled_{0}'.format(course_key),
)
except ExperimentData.DoesNotExist:
return False
try:
ExperimentData.objects.get(
user=user,
experiment_id=experiment_id,
key='paid_{0}'.format(course_key),
)
except ExperimentData.DoesNotExist:
return True
return False
def get_serializer_context(self): def get_serializer_context(self):
context = super(UserCourseEnrollmentsList, self).get_serializer_context() context = super(UserCourseEnrollmentsList, self).get_serializer_context()
context['api_version'] = self.kwargs.get('api_version') context['api_version'] = self.kwargs.get('api_version')
@@ -354,12 +315,8 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
enrollment for enrollment in same_org enrollment for enrollment in same_org
if is_mobile_available_for_user(self.request.user, enrollment.course_overview) if is_mobile_available_for_user(self.request.user, enrollment.course_overview)
) )
not_hidden_for_experiments = (
enrollment for enrollment in mobile_available
if not self.hide_course_for_enrollment_fee_experiment(self.request.user, enrollment)
)
not_duration_limited = ( not_duration_limited = (
enrollment for enrollment in not_hidden_for_experiments enrollment for enrollment in mobile_available
if check_course_expired(self.request.user, enrollment.course) == ACCESS_GRANTED if check_course_expired(self.request.user, enrollment.course) == ACCESS_GRANTED
) )

View File

@@ -86,29 +86,26 @@
function setDialogAttributes(isPaidCourse, certNameLong, function setDialogAttributes(isPaidCourse, certNameLong,
courseNumber, courseName, enrollmentMode, showRefundOption, courseKey) { courseNumber, courseName, enrollmentMode, showRefundOption, courseKey) {
// This flag is added for REV-19 experiment var diagAttr = {};
var auditRefundableCourses = (window.experimentVariables || {}).auditRefundableCourses,
courseInExperiment = auditRefundableCourses ? auditRefundableCourses.indexOf(courseKey) > -1 : false,
diagAttr = {};
if (isPaidCourse || courseInExperiment) { if (isPaidCourse) {
if (showRefundOption) { if (showRefundOption) {
diagAttr['data-refund-info'] = gettext('You will be refunded the amount you paid.'); diagAttr['data-refund-info'] = gettext('You will be refunded the amount you paid.');
} else { } else {
diagAttr['data-refund-info'] = gettext('You will not be refunded the amount you paid.'); diagAttr['data-refund-info'] = gettext('You will not be refunded the amount you paid.');
} }
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the purchased course ' + diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the purchased course ' +
'%(courseName)s (%(courseNumber)s)?'); '{courseName} ({courseNumber})?');
} else if (enrollmentMode !== 'verified') { } else if (enrollmentMode !== 'verified') {
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from %(courseName)s ' + diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from {courseName} ' +
'(%(courseNumber)s)?'); '({courseNumber})?');
} else if (showRefundOption) { } else if (showRefundOption) {
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the verified ' + diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the verified ' +
'%(certNameLong)s track of %(courseName)s (%(courseNumber)s)?'); '{certNameLong} track of {courseName} ({courseNumber})?');
diagAttr['data-refund-info'] = gettext('You will be refunded the amount you paid.'); diagAttr['data-refund-info'] = gettext('You will be refunded the amount you paid.');
} else { } else {
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the verified ' + diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from the verified ' +
'%(certNameLong)s track of %(courseName)s (%(courseNumber)s)?'); '{certNameLong} track of {courseName} ({courseNumber})?');
diagAttr['data-refund-info'] = gettext('The refund deadline for this course has passed,' + diagAttr['data-refund-info'] = gettext('The refund deadline for this course has passed,' +
'so you will not receive a refund.'); 'so you will not receive a refund.');
} }
@@ -158,11 +155,26 @@
$('#track-info').empty(); $('#track-info').empty();
$('#refund-info').empty(); $('#refund-info').empty();
$('#track-info').html(interpolate(dialogMessageAttr['data-track-info'], { edx.HtmlUtils.setHtml(
courseNumber: ['<span id="unenroll_course_number">', courseNumber, '</span>'].join(''), $('#track-info'),
courseName: ['<span id="unenroll_course_name">', courseName, '</span>'].join(''), edx.HtmlUtils.interpolateHtml(dialogMessageAttr['data-track-info'], {
certNameLong: ['<span id="unenroll_cert_name">', certNameLong, '</span>'].join('') courseNumber: edx.HtmlUtils.joinHtml(
}, true)); edx.HtmlUtils.HTML('<span id="unenroll_course_number">'),
courseNumber,
edx.HtmlUtils.HTML('</span>')
),
courseName: edx.HtmlUtils.joinHtml(
edx.HtmlUtils.HTML('<span id="unenroll_course_name">'),
courseName,
edx.HtmlUtils.HTML('</span>')
),
certNameLong: edx.HtmlUtils.joinHtml(
edx.HtmlUtils.HTML('<span id="unenroll_cert_name">'),
certNameLong,
edx.HtmlUtils.HTML('</span>')
)
}, true)
);
if ('data-refund-info' in dialogMessageAttr) { if ('data-refund-info' in dialogMessageAttr) {