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

feat: filter courses by user language by default #33647

Merged

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Nov 2, 2023

Description

Adds a waffle switch to filter courses by selected site language by default

Useful information to include:

  • Which edX user roles will this change impact? Learner

Private-ref: BB-8091

Testing instructions

  • Setup master devstack and checkout this PR
  • Add below snippet to lms/envs/private.py
FEATURES['ENABLE_COURSE_DISCOVERY'] = True
  • Start lms and cms using make {lms,cms}-up

  • Add courseware.discovery_default_language_filter waffle switch in django admin.

  • Add a new course or update language of any existing course to some other language.

  • Go to http://localhost:18000/courses

  • If you have never set your language via account settings, you should see all the courses without any filters applied.

  • Now change your language by going to Account page.
    image

image

@navinkarkera navinkarkera self-assigned this Nov 2, 2023
@openedx-webhooks
Copy link

openedx-webhooks commented Nov 2, 2023

Thanks for the pull request, @navinkarkera! 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 Nov 2, 2023
@navinkarkera navinkarkera marked this pull request as ready for review November 2, 2023 09:36
@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from 0adc71b to c86d908 Compare November 2, 2023 09:37
@open-craft-grove
Copy link

Sandbox deploy request received. Deployment will start soon.

@open-craft-grove
Copy link

Sandbox deployment started.

@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from c86d908 to 6c71c68 Compare November 2, 2023 10:04
@open-craft-grove
Copy link

Sandbox update request received. Deployment will start soon.

@open-craft-grove
Copy link

Sandbox deployment successful.

Sandbox LMS is available at pr-33647-139931.staging.do.opencraft.hosting
Sandbox Studio is available at studio.pr-33647-139931.staging.do.opencraft.hosting

@open-craft-grove
Copy link

Sandbox deployment started.

@open-craft-grove
Copy link

Sandbox deployment successful.

Sandbox LMS is available at pr-33647-139931.staging.do.opencraft.hosting
Sandbox Studio is available at studio.pr-33647-139931.staging.do.opencraft.hosting

@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from 6c71c68 to 4f23108 Compare November 3, 2023 06:22
@tecoholic
Copy link
Contributor

tecoholic commented Nov 10, 2023

@navinkarkera 👍

  • I tested this: Verified that the discovery page filters courses automatically based on the user's language.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

NOTE:

@navinkarkera
Copy link
Contributor Author

While feature flag contains the documentation about the flag, maybe there somewhere else this should be documented? eg., https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/feature_flags/feature_flag_index.html

openedx/edx-documentation#2210

@open-craft-grove
Copy link

Sandbox update request received. Deployment will start soon.

@mphilbrick211
Copy link

Hi @navinkarkera! Is this ready for review?

@navinkarkera
Copy link
Contributor Author

@mphilbrick211 Thanks for checking. Yes it is ready.

@mphilbrick211 mphilbrick211 added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Nov 20, 2023
@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch 2 times, most recently from 81335fa to eca9398 Compare November 29, 2023 06:36
@pomegranited
Copy link
Contributor

Hi @mphilbrick211 @navinkarkera may I review/merge this as CC?

@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from 13ad42f to 9a2f9da Compare January 25, 2024 05:28
@navinkarkera
Copy link
Contributor Author

@pomegranited That would be super helpful. Thanks!

@pomegranited
Copy link
Contributor

Sure thing @navinkarkera , could you direct me to the ticket?

@navinkarkera
Copy link
Contributor Author

@pomegranited BB-8091. Added the ticket info to description as well.

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

@navinkarkera This code is working exactly as described, thank you for such great testing instructions!

But I have some questions about the feature flag, and a request for a better test. Please let me know if you have any questions or concerns.

expect($('.courses-listing .course-title')).toContainHtml('edX Demonstration Course');
expect($('.active-filter').length).toBe(1);
expect($('.active-filter .query')).toContainHtml("English");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Since there's only ever one course in the returned list, this test doesn't actually verify that the filter was applied.
Could you add another course that uses a different language so we can see that this filter actually applies?

Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that when my preferred language doesn't match any of my course's languages that I see header text like this:

We couldn't find any results for ""

which I think students may find confusing, because the text is confusing, and because the student didn't actually perform an explicit search.

An easy way around this would be to avoid showing that header if there's no search text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there's only ever one course in the returned list, this test doesn't actually verify that the filter was applied.
Could you add another course that uses a different language so we can see that this filter actually applies?

@pomegranited Actually the test should not be about checking API response as it is mocked above by AjaxHelpers.respondWithJson(requests, JSON_RESPONSE);. So I modified to check the request body as it should include language filter automatically when default filter is enabled.

An easy way around this would be to avoid showing that header if there's no search text.

Makes sense. Done 👍

@@ -275,6 +275,7 @@ def courses(request):
"""
courses_list = []
course_discovery_meanings = getattr(settings, 'COURSE_DISCOVERY_MEANINGS', {})
set_default_filter = settings.FEATURES.get('ENABLE_COURSE_DISCOVERY_DEFAULT_LANGUAGE_FILTER')
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 implementation reason why you chose to add a new settings.FEATURES flag instead of one of the toggles available from edx-toggles like SettingToggle or WaffleFlag?

It's my understanding from Feature Flags and Settings on edx-platform and OEP-17 that we should be using these edx-toggles now, and that FEATURES flags are deprecated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pomegranited No specific reason for using feature flags, except for maybe the relationship with ENABLE_COURSE_DISCOVERY feature flag. After reading the the OEP, I think we can using WaffleSwitch here.

@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from 9a2f9da to ed3664a Compare February 5, 2024 11:42
Copy link
Contributor

@pomegranited pomegranited 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 addressing my comments @navinkarkera :) I'll merge this tomorrow if there are no objections.

Could you update the PR description to reflect the use of a Waffle Switch instead of a feature flag to enable this feature? And will need an update to openedx/edx-documentation#2210 too.

  • I tested this on my devstack using the excellent testing instructions in the PR.
  • I read through the code
  • I checked for accessibility issues by using my keyboard to navigate the Courses list
  • Includes documentation on the new switch
  • User-facing strings are extracted for translation N/A

lms/djangoapps/courseware/toggles.py Outdated Show resolved Hide resolved
@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from 1ef9b38 to c3eb382 Compare February 6, 2024 11:10
@navinkarkera
Copy link
Contributor Author

@pomegranited We probably don't need openedx/edx-documentation#2210 as it will be automatically documented here.

Adds a feature flag to filter courses by users preferred language by default

test: add test
@navinkarkera navinkarkera force-pushed the navin/filter-courses-by-language branch from c3eb382 to f1d79ca Compare February 6, 2024 12:21
@pomegranited
Copy link
Contributor

@navinkarkera Perfect, thank you for fixing that nit and updating your PR description.

We probably don't need openedx/edx-documentation#2210 as it will be automatically documented here.

Sweet! Feel free to close that then.

Merging this now :)

@pomegranited pomegranited merged commit 4a46ae9 into openedx:master Feb 6, 2024
46 checks passed
@pomegranited pomegranited deleted the navin/filter-courses-by-language branch February 6, 2024 22:23
@openedx-webhooks
Copy link

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

@itsjeyd itsjeyd added core contributor PR author is a Core Contributor (who may or may not have write access to this repo). and removed waiting for eng review PR is ready for review. Review and merge it, or suggest changes. labels Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core contributor PR author is a Core Contributor (who may or may not have write access to this repo). 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.

8 participants