feat: api to fetch all programs where an enterprise learner is enrolled

This commit is contained in:
muhammad-ammar
2022-03-02 12:14:57 +05:00
parent 0d9e845f1b
commit c35025fd9d
4 changed files with 261 additions and 8 deletions

View File

@@ -152,7 +152,7 @@ class ProgramProgressMeter:
will only inspect this one program, not all programs the user may be
engaged with.
"""
def __init__(self, site, user, enrollments=None, uuid=None, mobile_only=False):
def __init__(self, site, user, enrollments=None, uuid=None, mobile_only=False, include_course_entitlements=True):
self.site = site
self.user = user
self.mobile_only = mobile_only
@@ -172,8 +172,10 @@ class ProgramProgressMeter:
# We can't use dict.keys() for this because the course run ids need to be ordered
self.course_run_ids.append(enrollment_id)
self.entitlements = list(CourseEntitlement.unexpired_entitlements_for_user(self.user))
self.course_uuids = [str(entitlement.course_uuid) for entitlement in self.entitlements]
self.course_uuids = []
if include_course_entitlements:
self.entitlements = list(CourseEntitlement.unexpired_entitlements_for_user(self.user))
self.course_uuids = [str(entitlement.course_uuid) for entitlement in self.entitlements]
if uuid:
self.programs = [get_programs(uuid=uuid)]