Skip to content

Conversation

@feanil
Copy link
Contributor

@feanil feanil commented Mar 28, 2025

BREAKING CHANGE: The learning MFE now supports preview functionality natively and it is no longer necessary to use a different domain on the LMS to render a preview of course content. Visiting the preview domain will no longer give you a different view of the course content.

See openedx/frontend-app-learning#1455 for more details.

This PR removes the legacy functionality, a side-effect of this is that saved links (including bookmarks) to the legacy preview URLs will not redirect to the MFE preview URLs as mentions of that domain have been removed.

This PR depends on #36436 and #36430 to merge first.

@feanil feanil changed the base branch from master to feanil/remove_courseware_sock March 28, 2025 21:45
@feanil feanil force-pushed the feanil/drop_legacy_preview branch 2 times, most recently from 4f9b60b to 5ee3ecd Compare March 31, 2025 15:38
@feanil feanil changed the title feanil/drop legacy preview feat!: Remove Legacy Preview Functionality Mar 31, 2025
@feanil feanil marked this pull request as ready for review March 31, 2025 16:41
@feanil feanil requested a review from kdmccormick as a code owner March 31, 2025 16:41
@feanil feanil force-pushed the feanil/remove_courseware_sock branch from 32bd1ab to 1829eb7 Compare April 7, 2025 14:29
@feanil feanil requested review from a team as code owners April 7, 2025 14:29
@feanil feanil force-pushed the feanil/drop_legacy_preview branch from 5ee3ecd to 9215044 Compare April 7, 2025 14:31
@AhtishamShahid AhtishamShahid removed the request for review from a team April 8, 2025 06:01
Base automatically changed from feanil/remove_courseware_sock to master April 9, 2025 14:14
@feanil feanil force-pushed the feanil/drop_legacy_preview branch from 9215044 to 7a16b64 Compare April 9, 2025 16:54
@ormsbee
Copy link
Contributor

ormsbee commented Apr 10, 2025

@feanil: Just a sanity check: this will break Tutor, right? Because Tutor will expect these settings to exist? Things like this?

Copy link
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

A couple of questions and minor requests.

assert not bool(access.has_access(self.student, 'load', self.course, course_key=self.course.id))

# Student should be able to load the course even if they don't have staff access.
assert bool(access.has_access(self.student, 'load', self.course, course_key=self.course.id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this behavior change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously this test was being run with the preview domain where the student would indeed not have access. Now that the test is being run on the default domain, the student does have access again.



@set_preview_mode(True)
@patch('lms.djangoapps.courseware.views.index.CoursewareIndex._redirect_to_learning_mfe', return_value=None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment explaining why this patch exists here.

with patch('lms.djangoapps.courseware.access.in_preview_mode') as mock_preview:
mock_preview.return_value = True
for obj in modules:
assert not bool(access.has_access(self.student, 'load', obj, course_key=self.course.id))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an equivalent test to make sure that students cannot load the preview/draft state of unreleased content if they know the correct URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to add a check that a student will not have access to the unpublished content when this is not published yet.

@kdmccormick kdmccormick removed their request for review April 17, 2025 17:06
feanil added 6 commits April 24, 2025 11:43
There are a few more mentions but these are all the ones that don't need
major further followup.

BREAKING CHANGE: The learning MFE now supports preview functionality
natively and it is no longer necessary to use a different domain on the
LMS to render a preview of course content.

See openedx/frontend-app-learning#1455 for
more details.
Since we're no longer using a separate domain, that check always
returned false.  Remove it and update any places/tests where it is used.
With the removal of the preview check this function is also a no-op now
so drop calls to it and update the places where it is called to not
change other behavior.
The CoursewareIndex view is going to be removed eventually but for now
we're focusing on removing the PREVIEW_LMS_BASE setting.  With this
change, if someone tries to load the legacy courseware URL from the
preview domain it will no longer redirect them to the MFE preview.

This is not a problem that will occur for users coming from existing
studio links because those links have already been updated to go
directly to the new urls.

The only way this path could execute is if someone goes directly to the
old Preview URL that they saved off platform somewhere.  eg. If they
bookmarked it for some reason.

BREAKING CHANGE: Saved links (including bookmarks) to the legacy preview
URLs will no longer redirect to the MFE preview URLs.
This test helper was setting the preview mode for tests by changing the
hostname that was set while tests were running.  This was mostly not
being used to test preview but to run a bunch of legacy courseware tests
while defaulting to the new learning MFE for the courseware.

This commit updates various tests in the `courseware` app to not rely on
the fact that we're in preview to test legacy courseware behavior and
instead directly patches either the `_redirect_to_learning_mfe` function
or uses the `_get_legacy_courseware_url` or both to be able to have the
tests continue to test the legacy coursewary.

This will hopefully make the tests more accuarte even though hopefully
we'll just be removing many of them soon as a part of the legacy
courseware cleanup.

We're just doing the preview removal separately to reduce the number of
things that are changing at once.
With the other recent cleanup, this function is no longer being
referenced by anything so we can just drop it.
@feanil feanil force-pushed the feanil/drop_legacy_preview branch from 7a16b64 to 6e5db47 Compare April 29, 2025 19:47
Ensure that students can't get access to unpublished content.
@feanil feanil force-pushed the feanil/drop_legacy_preview branch from fdae7b8 to 4865cab Compare April 30, 2025 17:44
Copy link
Contributor Author

@feanil feanil left a comment

Choose a reason for hiding this comment

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

@ormsbee I've responded to the comments, please have another look when you have a moment.

with patch('lms.djangoapps.courseware.access.in_preview_mode') as mock_preview:
mock_preview.return_value = True
for obj in modules:
assert not bool(access.has_access(self.student, 'load', obj, course_key=self.course.id))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to add a check that a student will not have access to the unpublished content when this is not published yet.

@feanil feanil requested a review from ormsbee May 13, 2025 15:54
Comment on lines 261 to 263
print(self.store.get_branch_setting())

print(self.store.get_branch_setting())
Copy link
Contributor

Choose a reason for hiding this comment

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

Leftover debug code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely, I'll clean this up before squashing.

Copy link
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

Aside from the print statements, this looks good to squash and merge.

Also remove some errant debugging print statements.
@feanil feanil merged commit 88c7cd7 into master May 14, 2025
67 of 72 checks passed
@feanil feanil deleted the feanil/drop_legacy_preview branch May 14, 2025 12:59
@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.

@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.

@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.

Danyal-Faheem added a commit to edly-io/tutor that referenced this pull request May 22, 2025
closes overhangio#1231
The preview page has been migrated to the Learning MFE as of openedx/openedx-platform#36460
This is why we dont need to have a separate domain for the preview site anymore nor the configuration setting for the preview page in core.
DawoudSheraz pushed a commit to overhangio/tutor that referenced this pull request Jun 18, 2025
closes #1231
The preview page has been migrated to the Learning MFE as of openedx/openedx-platform#36460
This is why we dont need to have a separate domain for the preview site anymore nor the configuration setting for the preview page in core.
ahmed-arb pushed a commit to overhangio/tutor that referenced this pull request Jul 9, 2025
closes #1231
The preview page has been migrated to the Learning MFE as of openedx/openedx-platform#36460
This is why we dont need to have a separate domain for the preview site anymore nor the configuration setting for the preview page in core.
marlonkeating pushed a commit that referenced this pull request Jul 15, 2025
* feat!: Remove all trivial mentions of PREVIEW_LMS_BASE

There are a few more mentions but these are all the ones that don't need
major further followup.

BREAKING CHANGE: The learning MFE now supports preview functionality
natively and it is no longer necessary to use a different domain on the
LMS to render a preview of course content.

See openedx/frontend-app-learning#1455 for
more details.

* feat: Drop the `in_preview_mode` function.

Since we're no longer using a separate domain, that check always
returned false.  Remove it and update any places/tests where it is used.

* feat: Drop courseware_mfe_is_active function.

With the removal of the preview check this function is also a no-op now
so drop calls to it and update the places where it is called to not
change other behavior.

* feat!: Drop redirect to preview from the legacy courseware index.

The CoursewareIndex view is going to be removed eventually but for now
we're focusing on removing the PREVIEW_LMS_BASE setting.  With this
change, if someone tries to load the legacy courseware URL from the
preview domain it will no longer redirect them to the MFE preview.

This is not a problem that will occur for users coming from existing
studio links because those links have already been updated to go
directly to the new urls.

The only way this path could execute is if someone goes directly to the
old Preview URL that they saved off platform somewhere.  eg. If they
bookmarked it for some reason.

BREAKING CHANGE: Saved links (including bookmarks) to the legacy preview
URLs will no longer redirect to the MFE preview URLs.

* test: Drop the set_preview_mode test helper.

This test helper was setting the preview mode for tests by changing the
hostname that was set while tests were running.  This was mostly not
being used to test preview but to run a bunch of legacy courseware tests
while defaulting to the new learning MFE for the courseware.

This commit updates various tests in the `courseware` app to not rely on
the fact that we're in preview to test legacy courseware behavior and
instead directly patches either the `_redirect_to_learning_mfe` function
or uses the `_get_legacy_courseware_url` or both to be able to have the
tests continue to test the legacy coursewary.

This will hopefully make the tests more accuarte even though hopefully
we'll just be removing many of them soon as a part of the legacy
courseware cleanup.

We're just doing the preview removal separately to reduce the number of
things that are changing at once.

* test: Drop the `_get_urls_function`

With the other recent cleanup, this function is no longer being
referenced by anything so we can just drop it.

* test: Test student access to unpublihsed content.

Ensure that students can't get access to unpublished content.
feanil added a commit that referenced this pull request Dec 18, 2025
We haven't done anything specila for lms-xml for over a decade and we
dropped lms-preview support last year when we added preview capabality
to the new Authoring MFE.

#36460
feanil added a commit that referenced this pull request Dec 18, 2025
We haven't done anything specila for lms-xml for over a decade and we
dropped lms-preview support last year when we added preview capabality
to the new Authoring MFE.

#36460
mraman-2U pushed a commit to mraman-2U/edx-platform that referenced this pull request Dec 24, 2025
We haven't done anything specila for lms-xml for over a decade and we
dropped lms-preview support last year when we added preview capabality
to the new Authoring MFE.

openedx#36460
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