Skip to content

feat: add exec ed course uuid to learner home serializer - #450

Closed
jono-booth wants to merge 1 commit into
release-ulmofrom
jb/exec-ed-course-uuid
Closed

feat: add exec ed course uuid to learner home serializer#450
jono-booth wants to merge 1 commit into
release-ulmofrom
jb/exec-ed-course-uuid

Conversation

@jono-booth

@jono-booth jono-booth commented Sep 2, 2026

Copy link
Copy Markdown

Description

Adds a courseUuid field to the Learner Home CourseRunSerializer, populated for Executive Education (GetSmarter/Titan) enrollments.

Supporting information

  • Jira: ENT-9254 — EdX-ExecEd Dashboard redirect to OLC without stopping in Titan

Planned follow-ups (not in this PR):

  1. frontend-app-learner-dashboard: extend useCardExecEdTrackingParam to append courseUuid as a course_id query param on the "Start/Resume Course" link, alongside the existing org_id. feat: add exec ed course uuid to exec ed course cards cta button frontend-app-learner-dashboard#26
  2. titan: read that param in Spree::UsersControllerDecorator#show and redirect straight to partner_olc_link(product) instead of rendering the profile page, when it matches an allocation. https://github.com/getsmarter/titan/pull/3903

Testing instructions

  1. Enroll a test user in a course with an Executive Education mode (executive-education, paid-executive-education, or unpaid-executive-education).
  2. Hit the Learner Home API (/api/learner_home/init or equivalent) and confirm the corresponding courseRun entry has a non-null courseUuid.

Covered by new/updated unit tests in lms/djangoapps/learner_home/test_serializers.py:

  • test_with_data (updated to exercise an enrollment)
  • test_course_uuid (assers courseUUID is available after enrolment)
  • test_missing_course_uuid (asserts None)

Other information

  • Depends on nothing merged elsewhere; the frontend and Titan follow-ups depend on this.
  • No database migration.
  • No new external calls for the common case — the catalog lookup only fires for Executive Education enrollments.

Copilot AI lite review requested due to automatic review settings September 2, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The serializer currently performs the catalog UUID lookup for all enrollments and the tests don’t validate the intended “ExecEd-only lookup / non-ExecEd no-call” behavior described in the PR.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a courseUuid field to the Learner Home CourseRunSerializer so Executive Education (GetSmarter/Titan) enrollments can include a catalog-backed UUID for downstream redirect/tracking use cases.

Changes:

  • Added courseUuid to CourseRunSerializer via SerializerMethodField and catalog lookup helper.
  • Updated Learner Home serializer unit tests to account for the new field.
File summaries
File Description
lms/djangoapps/learner_home/serializers.py Introduces courseUuid on CourseRunSerializer using get_course_uuid_for_course.
lms/djangoapps/learner_home/test_serializers.py Adds/updates tests around courseUuid serialization behavior.
Review details

Suppressed comments (2)

lms/djangoapps/learner_home/test_serializers.py:259

  • The new courseUuid tests don't currently verify the intended behavior from the PR description: non‑ExecEd enrollments should keep courseUuid as None and must not trigger a catalog lookup. test_missing_course_uuid should cover the non‑ExecEd no-call case (and optionally also the ExecEd missing-UUID case).
    @mock.patch("lms.djangoapps.learner_home.serializers.get_course_uuid_for_course")
    def test_missing_course_uuid(self, mock_get_course_uuid_for_course):
        # Given the catalog has no UUID for this course (e.g. no catalog integration configured)
        mock_get_course_uuid_for_course.return_value = None
        input_data = self.create_test_enrollment()
        input_context = self.create_test_context(input_data.course.id)

        # When I serialize
        output_data = CourseRunSerializer(input_data, context=input_context).data

        # Then courseUuid is None, which is allowed
        self.assertIsNone(output_data["courseUuid"])

lms/djangoapps/learner_home/test_serializers.py:240

  • test_course_uuid currently uses the default audit enrollment; if courseUuid is correctly restricted to Executive Education modes, this test will fail because no lookup should occur for audit. Create an ExecEd enrollment in this test.
    @mock.patch("lms.djangoapps.learner_home.serializers.get_course_uuid_for_course")
    def test_course_uuid(self, mock_get_course_uuid_for_course):
        # Given the catalog has a UUID for this course
        course_uuid = uuid4()
        mock_get_course_uuid_for_course.return_value = course_uuid
        input_data = self.create_test_enrollment()
        input_context = self.create_test_context(input_data.course.id)

  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +119 to +121
def get_courseUuid(self, instance):
course_uuid = get_course_uuid_for_course(instance.course_id)
return str(course_uuid) if course_uuid else None
Comment on lines +206 to 212
@mock.patch("lms.djangoapps.learner_home.serializers.get_course_uuid_for_course")
def test_with_data(self, mock_get_course_uuid_for_course):
# Mocked so courseUuid is populated, same as every other field
mock_get_course_uuid_for_course.return_value = uuid4()
input_data = self.create_test_enrollment()
input_context = self.create_test_context(input_data.course.id)

@jono-booth jono-booth closed this Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants