remove experiment code
This commit is contained in:
@@ -1064,23 +1064,6 @@ class EnrollmentTest(EnrollmentTestMixin, ModuleStoreTestCase, APITestCase, Ente
|
||||
self.assertEqual(enrollment.mode, mode)
|
||||
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')
|
||||
class EnrollmentEmbargoTest(EnrollmentTestMixin, UrlResetMixin, ModuleStoreTestCase):
|
||||
|
||||
@@ -747,16 +747,13 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
|
||||
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
|
||||
missing_attrs = []
|
||||
audit_with_order = False
|
||||
if enrollment_attributes:
|
||||
actual_attrs = [
|
||||
u"{namespace}:{name}".format(**attr)
|
||||
for attr in enrollment_attributes
|
||||
]
|
||||
missing_attrs = set(REQUIRED_ATTRIBUTES.get(mode, [])) - set(actual_attrs)
|
||||
audit_with_order = mode == 'audit' and 'order:order_number' in actual_attrs
|
||||
# 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 has_api_key_permissions and (mode_changed or active_changed):
|
||||
if mode_changed and active_changed and not is_active:
|
||||
# if the requester wanted to deactivate but specified the wrong mode, fail
|
||||
# the request (on the assumption that the requester had outdated information
|
||||
|
||||
@@ -18,7 +18,6 @@ from courseware.courses import get_current_child
|
||||
from courseware.model_data import FieldDataCache
|
||||
from courseware.module_render import get_module_for_descriptor
|
||||
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 mobile_api.utils import API_V05
|
||||
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())
|
||||
|
||||
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):
|
||||
context = super(UserCourseEnrollmentsList, self).get_serializer_context()
|
||||
context['api_version'] = self.kwargs.get('api_version')
|
||||
@@ -354,12 +315,8 @@ class UserCourseEnrollmentsList(generics.ListAPIView):
|
||||
enrollment for enrollment in same_org
|
||||
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 = (
|
||||
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
|
||||
)
|
||||
|
||||
|
||||
@@ -86,29 +86,26 @@
|
||||
|
||||
function setDialogAttributes(isPaidCourse, certNameLong,
|
||||
courseNumber, courseName, enrollmentMode, showRefundOption, courseKey) {
|
||||
// This flag is added for REV-19 experiment
|
||||
var auditRefundableCourses = (window.experimentVariables || {}).auditRefundableCourses,
|
||||
courseInExperiment = auditRefundableCourses ? auditRefundableCourses.indexOf(courseKey) > -1 : false,
|
||||
diagAttr = {};
|
||||
var diagAttr = {};
|
||||
|
||||
if (isPaidCourse || courseInExperiment) {
|
||||
if (isPaidCourse) {
|
||||
if (showRefundOption) {
|
||||
diagAttr['data-refund-info'] = gettext('You will be refunded the amount you paid.');
|
||||
} else {
|
||||
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 ' +
|
||||
'%(courseName)s (%(courseNumber)s)?');
|
||||
'{courseName} ({courseNumber})?');
|
||||
} else if (enrollmentMode !== 'verified') {
|
||||
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from %(courseName)s ' +
|
||||
'(%(courseNumber)s)?');
|
||||
diagAttr['data-track-info'] = gettext('Are you sure you want to unenroll from {courseName} ' +
|
||||
'({courseNumber})?');
|
||||
} else if (showRefundOption) {
|
||||
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.');
|
||||
} else {
|
||||
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,' +
|
||||
'so you will not receive a refund.');
|
||||
}
|
||||
@@ -158,11 +155,26 @@
|
||||
$('#track-info').empty();
|
||||
$('#refund-info').empty();
|
||||
|
||||
$('#track-info').html(interpolate(dialogMessageAttr['data-track-info'], {
|
||||
courseNumber: ['<span id="unenroll_course_number">', courseNumber, '</span>'].join(''),
|
||||
courseName: ['<span id="unenroll_course_name">', courseName, '</span>'].join(''),
|
||||
certNameLong: ['<span id="unenroll_cert_name">', certNameLong, '</span>'].join('')
|
||||
}, true));
|
||||
edx.HtmlUtils.setHtml(
|
||||
$('#track-info'),
|
||||
edx.HtmlUtils.interpolateHtml(dialogMessageAttr['data-track-info'], {
|
||||
courseNumber: edx.HtmlUtils.joinHtml(
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user