Skip to content

Fix ordering of modules in UAI dashboard #2232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2025

Conversation

gumaerc
Copy link
Contributor

@gumaerc gumaerc commented May 7, 2025

What are the relevant tickets?

https://github.com/mitodl/hq/issues/7255

Description (What does it do?)

This PR adds a transform function for properly sorting the modules listed in the UAI dashboard, sorting them by Enrolled, Completed, and then the rest sorted by the order defined within the Program.

Screenshots (if appropriate):

image
image

How can this be tested?

  • Ensure that you have a Posthog project configured and have run the basic setup for mit-learn
  • Enable both the enrollment-dashboard and mitlearn-organization-dashboard feature flags
  • Visit the dashboard at http://open.odl.local:8062/dashboard (or wherever your site is hosted), logging in if necessary
  • The "My Learning" dashboard should be unchanged by this PR
  • Click either "Organization X" or Organization Y" to open the UAI dashboard
  • Ensure that the order matches what's described in the issue: first Enrolled courses, then Completed courses, then the order matching the one defined in the program

@gumaerc gumaerc added the Needs Review An open Pull Request that is ready for review label May 7, 2025
Copy link

github-actions bot commented May 7, 2025

OpenAPI Changes

Show/hide No detectable change.


export { mitx as enrollment, programs, courses }
const setupProgramsAndCourses = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Request: IMO a better spot for this would be frontends/main/src/app-pages/DashboardPage/CoursewareDisplay/test-utils.ts. (Or a sinilka

Factory files should be data-creators, not API mockers.

Also, I think it would be good to add a docstring describing what test scenario it sets up:

/**
 *  blah blah
 */
const setupProgramsAndCourses = () => {}

Copy link
Contributor

@ChristopherChudzicki ChristopherChudzicki left a comment

Choose a reason for hiding this comment

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

Makes sense 👍 , but two small requests.

if (!aCompleted && bCompleted) {
return 1
}
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

Request: The goal here is to keep original order, right? If yes, just return 0.

From MDN:

compareFn(a, b) return value sort order
> 0 sort a after b, e.g., [b, a]
< 0 sort a before b, e.g., [a, b]
=== 0 keep original order of a and b

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description

Also... copy pasting from MDN gave me legit markdown. That's cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason I thought in our conversation about this that we had thought the proper order wasn't being returned from the API, but this wouldn't be the way to deal with that anyway. Good suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that the API does return a meaningful order, it's just that we want to use that order as a fallback only.

Copy link

github-actions bot commented May 8, 2025

OpenAPI Changes

Show/hide No detectable change.

Copy link

github-actions bot commented May 8, 2025

OpenAPI Changes

Show/hide No detectable change.

@gumaerc
Copy link
Contributor Author

gumaerc commented May 8, 2025

@ChristopherChudzicki Thanks, it's ready for another look.

@gumaerc gumaerc merged commit 4c8d68d into main May 9, 2025
13 checks passed
@gumaerc gumaerc deleted the cg/uai-dashboard-ordering-title-links branch May 9, 2025 19:14
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.

2 participants