Skip to content

fix: use MFE-aware URL instead of legacy when generating block URL #36526

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

efortish
Copy link

Description

When using the Notes feature in a course with the Learning MFE enabled, clicking on a note from the Notes tab redirected users to the last visited unit rather than to the unit containing the note. This happened because the Notes component was generating URLs using the legacy format without considering whether the Learning MFE was active.

Objective

Fix the EdxNotes feature to properly navigate to note locations when the Learning MFE is enabled, ensuring that when a user clicks on a note from the Notes tab, they are directed to the correct unit containing that note rather than to the last visited unit.

Technical Approach

The issue was identified in the get_block_context function within helpers.py. This function was using a hardcoded approach to generate URLs for vertical blocks, which always produced URLs in the legacy format:

elif block.category == 'vertical':
    section = block.get_parent()
    chapter = section.get_parent()
    # Position starts from 1, that's why we add 1.
    position = get_index(str(block.location), section.children) + 1
    block_dict['url'] = reverse('courseware_position', kwargs={
        'course_id': str(course.id),
        'chapter': chapter.url_name,
        'section': section.url_name,
        'position': position,
    })

The solution was to replace the legacy URL generation logic with a call to the existing get_courseware_url function from url_helpers.py. This function already handles proper URL generation based on whether the Learning MFE is active or not:

elif block.category == 'vertical':
    # Use the MFE-aware URL generator instead of always using the legacy URL format
    block_dict['url'] = get_courseware_url(block.location)

Achievements

  • Correct navigation to notes: Users can now click on notes in the Notes tab and be taken directly to the unit containing the note, regardless of whether they're using the legacy or MFE experience.

  • Consistent user experience: The navigation behavior is now consistent between the legacy view and Learning MFE, providing a seamless experience for users.

  • Proper URL generation: The Notes component now generates URLs that are compatible with both legacy and MFE views by leveraging the platform's existing URL generation infrastructure.

Testing cases

2025-04-14.23-38-31.mp4

Related Issues

[TC_LEARNER_39] Notes tab linking not working

@openedx-webhooks
Copy link

Thanks for the pull request, @efortish!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Apr 15, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 15, 2025
@efortish efortish requested a review from mariajgrimaldi April 15, 2025 19:20
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Apr 23, 2025
@mariajgrimaldi mariajgrimaldi changed the title fix: The notes tab now generates URLs correctly for learning Mfe fix: use MFE-aware URL instead of legacy when generating block URL May 5, 2025
Copy link
Member

@mariajgrimaldi mariajgrimaldi left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution! I see this issue fixes the access of the notes from the course tab, where now it redirects to the correct unit. Now, I think previously this also redirected to the corresponding component with the annotation within the unit which is also broken right now. Can you help me confirm this? If this is the case, I think it'd be a good idea to open a follow up PR to also fix this issue. Let me know what you think!

@efortish
Copy link
Author

efortish commented May 9, 2025

Thank you for the contribution! I see this issue fixes the access of the notes from the course tab, where now it redirects to the correct unit. Now, I think previously this also redirected to the corresponding component with the annotation within the unit which is also broken right now. Can you help me confirm this? If this is the case, I think it'd be a good idea to open a follow up PR to also fix this issue. Let me know what you think!

Hello @mariajgrimaldi , thank you so much for the review, Can you please explain to me what are you referring with Now, I think previously this also redirected to the corresponding component with the annotation within the unit which is also broken right now

@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: In Eng Review
Development

Successfully merging this pull request may close these issues.

[TC_LEARNER_39] Notes tab linking not working
3 participants