-
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
feat: Make courseware URLs more human-readable #28174
Conversation
…to KristinAoki/TNL-8511
@KristinAoki I played around with this change on my devstack, and I'm psyched to see the short URLs working! 🔥 Your progress here is great, but I want to adjust your direction a bit so that it'll be easier for us to merge and enable this confidently. I notice that in several places, your PR swaps out unit/sequences usage keys with their hashes, in-place. For instance, it modifies the To get a feel for the impact of your current changes, you might temporarily Given that, my advice is actually to build the backend of this feature so that it doesn't actually check the value of feature flag, other than to pass the value of the flag to the frontend. In other words, see if you can make the flag frontend-only (although it's fine to keep it defined in Why? Because I believe that you can pass the new data you need to the frontend (that is: (1) block's hash and (2) whether the feature is enabled) by only adding fields to existing APIs responses, instead of modifying fields that are already in use. So, if an API has a The upsides of this approach would be:
I hope that makes sense! Let me know if it doesn't, or if you think I'm missing a critical piece here. |
############# Shorten MFE URL ########################## | ||
# .. toggle_name: enable_short_mfe_url | ||
# .. toggle_implementation: DjangoSetting | ||
# .. toggle_default: False | ||
# .. toggle_description: Flag would be used to hash block_ids and shorten the MFE url | ||
# .. toggle_use_cases: temporary | ||
# .. toggle_tickets: https://github.com/edx/edx-platform/pull/28174/ | ||
# .. toggle_creation_date: 2021-08-03 | ||
# .. toggle_target_removal_date: 2022-01-01 | ||
ENABLE_SHORT_MFE_URL = False | ||
|
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 still need the CMS setting, or can we drop this?
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 am not sure, when I didn't have it before some of the cms tests failed, but that was also before I refactored the code.
|
||
if 'blocks' in response.data: | ||
blocks = response.data['blocks'] | ||
else: | ||
blocks = response.data | ||
|
||
for block in blocks: | ||
current_block = block | ||
if isinstance(blocks, dict): | ||
current_block = blocks[block] | ||
if 'children' in current_block: | ||
new_child_ids = [get_usage_key_hash(child) for child in current_block['children']] | ||
current_block['hash_children'] = new_child_ids | ||
current_block['hash_key'] = get_usage_key_hash(current_block['id']) | ||
|
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.
does the frontend code still need the course_blocks API response to be modified to contain the hash_key, or are the changes to the sequence metadata API sufficient?
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.
It needs it for when it is calls normalizeBlocks
in api.js
@@ -3,6 +3,7 @@ | |||
""" | |||
|
|||
from django.utils.translation import ngettext | |||
from django.conf import settings |
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.
Am I correct that you're adding the hash_key
to the URLs here so that the course outline can use them in their links?
If so, you might want to leave those links unchanged for now, and leave the course_home_api as-is. The old links should be fine to stay on the outline page for now, as they'll redirect to the new ones.
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 think that is why I am adding them. Not 100%.
@@ -522,8 +536,18 @@ def get(self, request, usage_key_string, *args, **kwargs): # lint-amnesty, pyli | |||
""" | |||
Return response to a GET request. | |||
""" | |||
if settings.ENABLE_SHORT_MFE_URL: |
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.
You should be able to revert the changes to this file and rebase upon my PR
@@ -125,6 +125,15 @@ class CourseLearningSequenceData: | |||
learning sequences in Courses vs. Pathways vs. Libraries. Such an object | |||
would likely not have `visibility` as that holds course-specific concepts. | |||
""" | |||
|
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 changes to this file can be replaced with the model persistence in my PR
Your PR has finished running tests. There were no failures. |
Closing since it looks like this stalled 3 years ago. Please re-open if it's still relevant. |
Description
Describe what this pull request changes, and why. Include implications for people using this change.
Design decisions and their rationales should be documented in the repo (docstring / ADR), per
OEP-19, and can be
linked here.
This change impacts the Learner.
Before:
After:
Supporting information
Jira issue: TNL-8511
Testing instructions
Ex: http://localhost:2000/c/course-v1:edx+kris1+2021_T1/YmE3OGQwNzMyYWE2/ZmY0MzRjMTViYjBm
Deadline
August 11, 2021: Must be completed before the end of the internship
Other information
This change is dependent on Frontend-App-Learning PR-540