-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Conversation
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:
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. |
772b234
to
01d27ee
Compare
01d27ee
to
0c6272a
Compare
There was a problem hiding this 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.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
course_key = CourseKey.from_string(course_key_string) | ||
# raise 404 if old mogo course | ||
if course_key.deprecated: | ||
raise Http404 |
There was a problem hiding this comment.
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:
- 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.
- 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.
- Nit: Just for consistency with what's already there, please use
HttpResopnseNotFound()
instead ofHttp404
.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied your recommendation
xmodule/modulestore/mixed.py
Outdated
@@ -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: |
There was a problem hiding this comment.
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.
Please let me know if (or when) this is ready for a second review. |
@ormsbee Yes, this PR is ready for a second review. All comments updated |
There was a problem hiding this 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') |
There was a problem hiding this comment.
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?
if course_key.deprecated: | ||
raise SkipTest('OldMongo Deprecation') |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
if course.id.deprecated: | ||
course_context.update({ | ||
'url': None, | ||
'lms_link': None, | ||
'rerun_link': None | ||
}) | ||
return course_context |
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@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. |
@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. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
EdX Release Notice: This PR has been deployed to the production environment. |
@0x29a: Yeah, you can make a re-run of it using the code you cited, but the original would not be editable. |
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:
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