Merge pull request #27762 from edly-io/ERTE-5
[ERTE-5] feat: Added enterprise uuid in event context for enterprise enrolment events
This commit is contained in:
@@ -146,7 +146,7 @@ def get_enrollment(username, course_id):
|
||||
return _data_api().get_course_enrollment(username, course_id)
|
||||
|
||||
|
||||
def add_enrollment(username, course_id, mode=None, is_active=True, enrollment_attributes=None):
|
||||
def add_enrollment(username, course_id, mode=None, is_active=True, enrollment_attributes=None, enterprise_uuid=None):
|
||||
"""Enrolls a user in a course.
|
||||
|
||||
Enrolls a user in a course. If the mode is not specified, this will default to `CourseMode.DEFAULT_MODE_SLUG`.
|
||||
@@ -159,6 +159,7 @@ def add_enrollment(username, course_id, mode=None, is_active=True, enrollment_at
|
||||
is_active (boolean): Optional argument for making the new enrollment inactive. If not specified, is_active
|
||||
defaults to True.
|
||||
enrollment_attributes (list): Attributes to be set the enrollment.
|
||||
enterprise_uuid (str): Add course enterprise uuid
|
||||
|
||||
Returns:
|
||||
A serializable dictionary of the new course enrollment.
|
||||
@@ -197,7 +198,7 @@ def add_enrollment(username, course_id, mode=None, is_active=True, enrollment_at
|
||||
if mode is None:
|
||||
mode = _default_course_mode(course_id)
|
||||
validate_course_mode(course_id, mode, is_active=is_active)
|
||||
enrollment = _data_api().create_course_enrollment(username, course_id, mode, is_active)
|
||||
enrollment = _data_api().create_course_enrollment(username, course_id, mode, is_active, enterprise_uuid)
|
||||
|
||||
if enrollment_attributes is not None:
|
||||
set_enrollment_attributes(username, course_id, enrollment_attributes)
|
||||
|
||||
@@ -115,7 +115,7 @@ def get_user_enrollments(course_key):
|
||||
).order_by('created')
|
||||
|
||||
|
||||
def create_course_enrollment(username, course_id, mode, is_active):
|
||||
def create_course_enrollment(username, course_id, mode, is_active, enterprise_uuid=None):
|
||||
"""Create a new course enrollment for the given user.
|
||||
|
||||
Creates a new course enrollment for the specified user username.
|
||||
@@ -125,6 +125,7 @@ def create_course_enrollment(username, course_id, mode, is_active):
|
||||
course_id (str): The course to create the course enrollment for.
|
||||
mode (str): (Optional) The mode for the new enrollment.
|
||||
is_active (boolean): (Optional) Determines if the enrollment is active.
|
||||
enterprise_uuid (str): Add course enterprise uuid
|
||||
|
||||
Returns:
|
||||
A serializable dictionary representing the new course enrollment.
|
||||
@@ -146,7 +147,7 @@ def create_course_enrollment(username, course_id, mode, is_active):
|
||||
raise UserNotFoundError(msg) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
try:
|
||||
enrollment = CourseEnrollment.enroll(user, course_key, check_access=True)
|
||||
enrollment = CourseEnrollment.enroll(user, course_key, check_access=True, enterprise_uuid=enterprise_uuid)
|
||||
return _update_enrollment(enrollment, is_active=is_active, mode=mode)
|
||||
except NonExistentCourseError as err:
|
||||
raise CourseNotFoundError(str(err)) # lint-amnesty, pylint: disable=raise-missing-from
|
||||
|
||||
@@ -36,9 +36,9 @@ def get_course_enrollment(student_id, course_id):
|
||||
return _get_fake_enrollment(student_id, course_id)
|
||||
|
||||
|
||||
def create_course_enrollment(student_id, course_id, mode='honor', is_active=True):
|
||||
def create_course_enrollment(student_id, course_id, mode='honor', is_active=True, enterprise_uuid=None):
|
||||
"""Stubbed out Enrollment creation request. """
|
||||
return add_enrollment(student_id, course_id, mode=mode, is_active=is_active)
|
||||
return add_enrollment(student_id, course_id, mode=mode, is_active=is_active, enterprise_uuid=enterprise_uuid)
|
||||
|
||||
|
||||
def update_course_enrollment(student_id, course_id, mode=None, is_active=None):
|
||||
@@ -74,14 +74,15 @@ def _get_fake_course_info(course_id, include_expired=False):
|
||||
return course
|
||||
|
||||
|
||||
def add_enrollment(student_id, course_id, is_active=True, mode='honor'):
|
||||
def add_enrollment(student_id, course_id, is_active=True, mode='honor', enterprise_uuid=None):
|
||||
"""Append an enrollment to the enrollments array."""
|
||||
enrollment = {
|
||||
"created": datetime.datetime.now(),
|
||||
"mode": mode,
|
||||
"is_active": is_active,
|
||||
"course": _get_fake_course_info(course_id),
|
||||
"student": student_id
|
||||
"student": student_id,
|
||||
"enterprise_uuid": enterprise_uuid
|
||||
}
|
||||
_ENROLLMENTS.append(enrollment)
|
||||
return enrollment
|
||||
|
||||
@@ -800,7 +800,8 @@ class EnrollmentListView(APIView, ApiKeyPermissionMixIn):
|
||||
str(course_id),
|
||||
mode=mode,
|
||||
is_active=is_active,
|
||||
enrollment_attributes=enrollment_attributes
|
||||
enrollment_attributes=enrollment_attributes,
|
||||
enterprise_uuid=request.data.get('enterprise_uuid')
|
||||
)
|
||||
|
||||
cohort_name = request.data.get('cohort')
|
||||
|
||||
Reference in New Issue
Block a user