Skip to content

fix: sort sections in course-optimizer before returning result#36441

Merged
hinakhadim merged 6 commits intomasterfrom
TNL-11929/fix-section-ordering
Mar 28, 2025
Merged

fix: sort sections in course-optimizer before returning result#36441
hinakhadim merged 6 commits intomasterfrom
TNL-11929/fix-section-ordering

Conversation

@hinakhadim
Copy link
Contributor

@hinakhadim hinakhadim commented Mar 25, 2025

Description

Course Optimizer detected unusual section ordering where Section 3 appears before Section 1, which is unexpected and inconsistent with standard 'Course Outline' Ordering. This PR fixes by getting ordered section_ids and place sections in sorted manner basis on sections_ids ordering.

Useful information to include:

  • Which edX user roles will this change impact? Common user roles are "Course Author"
  • JIRA Link

Other information

Before

image

After

image


sections_map = {section['id']: section for section in data['LinkCheckOutput']['sections']}
sorted_sections = [sections_map[section_id] for section_id in sorted_section_ids if section_id in sections_map]
data['LinkCheckOutput']['sections'] = sorted_sections
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you using sorted_sections instead of directly assigning?

Copy link
Contributor

Choose a reason for hiding this comment

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

data["LinkCheckOutput"]["sections"] = [
    sections_map[section_id]
    for section_id in sorted_section_ids
    if section_id in sections_map
]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! fixed it.

Copy link
Contributor

@Faraz32123 Faraz32123 left a comment

Choose a reason for hiding this comment

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

👍

@hinakhadim hinakhadim merged commit 3834f20 into master Mar 28, 2025
49 checks passed
@hinakhadim hinakhadim deleted the TNL-11929/fix-section-ordering branch March 28, 2025 14:34
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

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.

4 participants

Comments