Skip to content
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

[OldMongo FC-0004] Disable editing of Old Mongo courses in Studio #30933

Merged
merged 4 commits into from
Sep 14, 2022

Conversation

UvgenGen
Copy link
Contributor

@UvgenGen UvgenGen commented Sep 1, 2022

Description

This removes user-facing Studio edit support for Old Mongo courses (courses that have a CourseKey of the format {org}/{course}/{run}). This does not affect our normal courses, which have CourseKeys starting with "course-v1:". After this commit:

  • Old Mongo courses will continue to appear on the Studio course listing page, but are not clickable.
  • Any attempt to directly access an Old Mongo course in Studio via URL fail with a 404 error.
  • Course certificates will still be available for Old Mongo courses
  • Old Mongo courses will continue to be returned by CourseOverviews and get_course_summaries() calls.

We decided against removing Old Mongo courses from the listing entirely because that would require very expensive CourseOverviews query to filter them out. Making that query more efficient would involve a database migration to add appropriate indexing, which is something else that we are looking to avoid. In general, we want to avoid changing how CourseOverviews work, in order to minimize risk.

This is part of the Old Mongo Modulestore deprecation effort: openedx/public-engineering#62

@openedx-webhooks
Copy link

Thanks for the pull request, @UvgenGen! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 1, 2022
@UvgenGen UvgenGen force-pushed the sagirov/EDXOLDMNG-62 branch 2 times, most recently from 772b234 to 01d27ee Compare September 2, 2022 09:14
@natabene
Copy link
Contributor

natabene commented Sep 7, 2022

@UvgenGen Thank you for the contribution. @ormsbee I hear you will be reviewing, please ping TNL team when ready with your review.

@ormsbee ormsbee self-assigned this Sep 7, 2022
@UvgenGen UvgenGen changed the title [DEPR] Do not display Old Mongo courses in Studio [Fc-0004] Do not display Old Mongo courses in Studio Sep 7, 2022
@UvgenGen UvgenGen changed the title [Fc-0004] Do not display Old Mongo courses in Studio [OldMongo FC-0004] Do not display Old Mongo courses in Studio Sep 7, 2022
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.

First pass review done. Mostly asking to reduce the scope of the changes to preserve some of the metadata being returned and to avoid potential performance issues around CourseOverview.

Comment on lines 664 to 665
deprecated_course_ids = [id for id in course_overviews.values_list('id', flat=True) if id.deprecated]
course_overviews = course_overviews.exclude(id__in=deprecated_course_ids)
Copy link
Contributor

Choose a reason for hiding this comment

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

This operation will be very expensive on 2U environments that have hundreds or thousands of Old Mongo courses. Is it possible to mirror the LMS approach on the learner dashboard, where the courses still appear, but the links no longer work? That would mean leaving get_all_courses the way it is for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this like in the LMS for the learner dashboard:
image

course_key = CourseKey.from_string(course_key_string)
# raise 404 if old mogo course
if course_key.deprecated:
raise Http404
Copy link
Contributor

Choose a reason for hiding this comment

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

A few small notes/suggestions:

  1. Since we're doing a blanket 404 for all Old Mongo courses, we can do the conditional at the top, at the beginning of the try block.
  2. It's probably worth logging what the course_key is, in case we want to track down what courses people are still trying to access for some reason.
  3. Nit: Just for consistency with what's already there, please use HttpResopnseNotFound() instead of Http404.

So maybe something like:

try:
    if course_key_string:
        course_key = CourseKey.from_string(course_key_string)
        if course_key.deprecated:
            logging.error(f"User {request.user.id} tried to access Studio for Old Mongo course {course_key}.")
        raise HttpResponseNotFound()  # or maybe HttpResponseBadRequest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied your recommendation

@@ -295,6 +295,11 @@ def get_course_summaries(self, **kwargs):
log.warning(
"Modulestore %s have duplicate courses %s; skipping from result.", store, course_id
)
# Skip course if it's from old mongo modulestore.
elif course_id.deprecated:
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's continue to return the course summary for now. We should be able to grab that information from the root CourseBlock anyhow.

lms/djangoapps/course_api/tests/test_views.py Outdated Show resolved Hide resolved
@ormsbee
Copy link
Contributor

ormsbee commented Sep 9, 2022

Please let me know if (or when) this is ready for a second review.

@ormsbee ormsbee assigned UvgenGen and unassigned ormsbee Sep 11, 2022
@UvgenGen
Copy link
Contributor Author

@ormsbee Yes, this PR is ready for a second review. All comments updated

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.

Question about course summaries, UI tweak request, and test commenting.

@@ -1879,6 +1891,9 @@ def post_rerun_request(
rerun_course_data.update(destination_course_data)
destination_course_key = _get_course_id(self.store, destination_course_data)

if destination_course_key.deprecated:
raise SkipTest('OldMongo Deprecation')
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever run a test here with the destination course key as an Old Mongo course? I didn't think our system ever supported re-running an Old Mongo course as another Old Mongo course, and if we have any tests that do that, we should probably remove them.

Could you please add a comment explaining how/why this happens?

Comment on lines +2216 to +2217
if course_key.deprecated:
raise SkipTest('OldMongo Deprecation')
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please add a comment explaining how/why this happens?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Skips is added due to the return of HttpResponseNotFound in course_handler for old mongo courses. Comment added.
Skips will be removed in future PRs.

Comment on lines +801 to +807
if course.id.deprecated:
course_context.update({
'url': None,
'lms_link': None,
'rerun_link': None
})
return course_context
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is the code that results in:

189369488-1c324219-e1c8-4b93-a25b-b31a8f3aa7a5-1

That text for the last course still looks clickable. Is that because it's still making the <a> tag, but with a blank href? If so, can we not make the tag when there's no link?

FYI @jmakowski1123, @JAAkana, @jristau1984 on how this is presented to the user.

Choose a reason for hiding this comment

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

@ormsbee I may not be completely up to speed on what the end goal is for course authors, but if I'm reading this thread correctly, the Old Mongo courses are archived and only displaying in the Archived Courses tab as a means to mitigate cost, as opposed to disappearing completely. If that's the case, is the (what looks like?) a url to rerun the course also confusing for the author? Or can the course actually be rerun? Can authors access the archived content? If the answer to all of the above is no, then displaying all that text as grayed out is a better UX option I think?

Copy link
Contributor

@ormsbee ormsbee Sep 13, 2022

Choose a reason for hiding this comment

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

In general, archived courses can be viewed in Studio. I think that the Old Mongo course is the last one here (with no "Re-run Course" or "View Live" link). Old Mongo courses will not be re-runnable or viewable after this merges. The fact that they show up in this list at all is to mitigate cost and risk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated CourseOrLibraryListing and now OldMongo courses renders without <a> tag:
image

Copy link
Contributor

@ormsbee ormsbee Sep 13, 2022

Choose a reason for hiding this comment

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

@UvgenGen: Thank you for the update.

@jmakowski1123, @jristau1984, @JAAkana: Unless there are objections by tomorrow, I'm planning to merge this PR with the UI pictured above (where Old Mongo courses display like the third course in the above screenshot). We can adjust the UI later if it's important to do so (e.g. add some kind of extra messaging?). If you believe this approach will impose too much of a burden on support teams and needs to be addressed immediately, please let me know.

Again, the reason we're doing it this way is to make the smallest change possible to disable Studio access to these courses. Filtering out all Old Mongo courses at the database layer is a potentially very expensive operation (because the database tables are not properly indexed for that), and we're trying to avoid doing database migrations during this work to minimize risk. Cosmetic changes like the above where links are removed are simpler and have a much smaller chance of causing regressions elsewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

So @jristau1984 checked with Jon Fay:

Jonathan Fay [10:18 AM]
I think it’s ok for now. This page will get a redesign at some point.

Still waiting until TNL is fully staffed tomorrow before merge.

with self.store.branch_setting(branch_setting=branch):
course_summaries = self.store.get_course_summaries()
# get_course_summaries skip old mongo courses
assert len(course_summaries) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

The course summaries should still be generated for Old Mongo courses, shouldn't they? This was the basic metadata like display_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes you are right, course summaries should still be generated for Old Mongo courses. I'll update it.

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

@ormsbee
Copy link
Contributor

ormsbee commented Sep 13, 2022

@UvgenGen: Paranoid question, but this doesn't affect the display of content libraries at all, does it?

@UvgenGen
Copy link
Contributor Author

UvgenGen commented Sep 14, 2022

@UvgenGen: Paranoid question, but this doesn't affect the display of content libraries at all, does it?

@ormsbee This may affect the display of content libraries if the library reference in the context is None. But libraries should always have a link. Otherwise, it will simply not be active as for the course.
Library with the link:
image

@ormsbee ormsbee merged commit b429e55 into openedx:master Sep 14, 2022
@openedx-webhooks
Copy link

@UvgenGen 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@ormsbee ormsbee changed the title [OldMongo FC-0004] Do not display Old Mongo courses in Studio [OldMongo FC-0004] Disable editing of Old Mongo courses in Studio Sep 14, 2022
@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@0x29a
Copy link
Contributor

0x29a commented Nov 10, 2023

Hi @ormsbee and @UvgenGen, is it in theory possible to update Old Mongo course so it's editable after this change?

Update: it seems I can use the management command that has been removed here.

@ormsbee
Copy link
Contributor

ormsbee commented Nov 11, 2023

@0x29a: Yeah, you can make a re-run of it using the code you cited, but the original would not be editable.

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
Archived in project
Development

Successfully merging this pull request may close these issues.

7 participants