Skip to content

fix: preserve requirement tree ordering for program courses#3053

Merged
gumaerc merged 3 commits intomainfrom
cc/program-course-order
Mar 17, 2026
Merged

fix: preserve requirement tree ordering for program courses#3053
gumaerc merged 3 commits intomainfrom
cc/program-course-order

Conversation

@ChristopherChudzicki
Copy link
Copy Markdown
Contributor

@ChristopherChudzicki ChristopherChudzicki commented Mar 16, 2026

What are the relevant tickets?

Description (What does it do?)

Courses in ProgramEnrollmentDisplay were displayed in the order returned by the courses API rather than the order defined in the program's requirement tree (req_tree). This fix changes the logic to map over the requirement tree's course IDs and look up each course, preserving the intended ordering.

How can this be tested?

  1. Create a program with some required courses; ensure the program also has a program page with include_in_learn_catalog: true
  2. Enroll in the program (by any means, but one way is via the program product page at /programs/READABLE_ID.
  3. View /dashboard, click on the program to go to its program dashboard, and observe that the courses are in the same order as specified in django admin req_tree.
  4. Reorder the req_tree with move up / move down, refresh the program dashboard. Order should be same.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

OpenAPI Changes

Show/hide No detectable change.

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@ChristopherChudzicki ChristopherChudzicki marked this pull request as ready for review March 16, 2026 16:51
Copilot AI review requested due to automatic review settings March 16, 2026 16:51
.filter((node) => node.data.node_type === "operator")
.map((node) => {
const courseIds = extractCoursesFromNode(node)
const sectionCourses = (programCourses?.results || []).filter(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Before: use API order, filter by req_tree

Now: Use req_tree order, filter by existence in API results

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes course ordering in the program dashboard so program courses render in the same order as defined by the program requirement tree (req_tree), rather than the order returned by the courses API.

Changes:

  • Update ProgramEnrollmentDisplay to build section course lists by mapping requirement-tree course IDs to fetched courses.
  • Add a regression test to ensure the displayed course cards follow req_tree ordering.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.tsx Rebuilds section course arrays using requirement-tree ID order instead of API list order.
frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/EnrollmentDisplay.test.tsx Adds a test verifying UI course card order matches req_tree order.

You can also share your feedback on Copilot code review. Take the survey.

@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Mar 16, 2026
ChristopherChudzicki and others added 2 commits March 16, 2026 16:24
Courses in ProgramEnrollmentDisplay were shown in API return order
rather than the order defined in the program's requirement tree.

Closes mitodl/hq#10528

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Chris Chudzicki <christopher.chudzicki@gmail.com>
Copy link
Copy Markdown
Contributor

@gumaerc gumaerc left a comment

Choose a reason for hiding this comment

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

👍

@gumaerc gumaerc merged commit b6f4e1d into main Mar 17, 2026
14 checks passed
@gumaerc gumaerc deleted the cc/program-course-order branch March 17, 2026 15:13
@odlbot odlbot mentioned this pull request Mar 17, 2026
3 tasks
feoh pushed a commit that referenced this pull request Mar 20, 2026
* fix: preserve requirement tree ordering for program courses

Courses in ProgramEnrollmentDisplay were shown in API return order
rather than the order defined in the program's requirement tree.

Closes mitodl/hq#10528

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: use Map for coursesById lookup in program enrollment display

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Apply suggestions from code review

Co-authored-by: Chris Chudzicki <christopher.chudzicki@gmail.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants