lms.djangoapps.learner_recommendations package#

Submodules#

lms.djangoapps.learner_recommendations.serializers module#

Serializers for learner recommendations APIs.

class lms.djangoapps.learner_recommendations.serializers.AboutPageProductRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a cross product recommended course for the course about page

get_prospectusPath(instance)#
class lms.djangoapps.learner_recommendations.serializers.AboutPageRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Recommended courses for course about page

class lms.djangoapps.learner_recommendations.serializers.ActiveCourseRunSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for active course run for course about page recommendations API

class lms.djangoapps.learner_recommendations.serializers.AmplitudeRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Amplitude recommendations for Learner Dashboard

class lms.djangoapps.learner_recommendations.serializers.CourseImageSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for course image for course about page recommendations API

class lms.djangoapps.learner_recommendations.serializers.CourseOwnersSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for course owners for course about page recommendations API

class lms.djangoapps.learner_recommendations.serializers.CourseSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a recommended course from the recommendation engine

class lms.djangoapps.learner_recommendations.serializers.CrossProductAndAmplitudeRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Cross product recommendation courses and Amplitude recommendations for Learner Dashboard

class lms.djangoapps.learner_recommendations.serializers.CrossProductRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Cross product recommendation courses for course about page

class lms.djangoapps.learner_recommendations.serializers.DashboardRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Recommended courses for learner dashboard

class lms.djangoapps.learner_recommendations.serializers.LearnerDashboardProductRecommendationsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for product recommendations for the Learner Dashboard

get_courseRunKey(instance)#
class lms.djangoapps.learner_recommendations.serializers.RecommendationsContextSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for recommendations context

class lms.djangoapps.learner_recommendations.serializers.RecommendedCourseSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a recommended course from the recommendation engine

get_prospectusPath(instance)#

lms.djangoapps.learner_recommendations.toggles module#

Toggles for learner recommendations.

lms.djangoapps.learner_recommendations.toggles.enable_course_about_page_recommendations()#
lms.djangoapps.learner_recommendations.toggles.enable_dashboard_recommendations()#

lms.djangoapps.learner_recommendations.urls module#

Learner Recommendations URL routing configuration.

lms.djangoapps.learner_recommendations.utils module#

Additional utilities for Learner Recommendations.

class lms.djangoapps.learner_recommendations.utils.AlgoliaClient#

Bases: object

Class for instantiating an Algolia search client instance.

algolia_app_id = None#
algolia_client = None#
algolia_search_api_key = None#
classmethod get_algolia_client()#

Get Algolia client instance.

Returns the filtered course recommendations. The unfiltered course keys pass through the following filters:

  1. Remove courses that a user is already enrolled in.

  2. If user is seeing the recommendations on a course about pages, filter that course out of recommendations.

  3. Remove the courses which is restricted in user region.

Parameters:
  • user – The user for which the recommendations need to be pulled

  • unfiltered_course_keys – recommended course keys that needs to be filtered

  • recommendation_count – the maximum count of recommendations to be returned

  • user_country_code – if provided, will apply location restrictions to recommendations

  • request_course_key – if provided, will filter out that course from recommendations (used for course about page)

  • fields – if provided, collects those fields on each course being queried, otherwise collects default fields

Returns:

A list of filtered course objects.

Return type:

filtered_recommended_courses (list)

lms.djangoapps.learner_recommendations.utils.get_active_course_run(course)#

Returns an active course run based on prospectus frontend logic for what defines an active course run

lms.djangoapps.learner_recommendations.utils.get_amplitude_course_recommendations(user_id, recommendation_id)#

Get personalized recommendations from Amplitude.

Parameters:
  • user_id – The user for which the recommendations need to be pulled

  • recommendation_id – Amplitude model id

Returns:

Control group value for the user has_is_control (bool): Boolean value indicating if the control group for the user has been decided. recommended_course_keys (list): Course keys returned by Amplitude.

Return type:

is_control (bool)

lms.djangoapps.learner_recommendations.utils.get_cross_product_recommendations(course_key)#

Helper method to get associated course keys based on the key passed

lms.djangoapps.learner_recommendations.utils.is_user_enrolled_in_ut_austin_masters_program(user)#

Checks if a user is enrolled in any masters program

Parameters:

user – The user object

Returns:

True if the user is enrolled in UT Austin masters program otherwise False

lms.djangoapps.learner_recommendations.views module#

Views for Learner Recommendations.

class lms.djangoapps.learner_recommendations.views.AboutPageRecommendationsView(**kwargs)#

Bases: APIView

IMPORTANT: Please do not update or use this API. This code has been moved to edx-recommendations plugin. Please use that plugin for further code changes. This API will be removed as part of VAN-1427.

Example Request

GET api/learner_recommendations/amplitude/{course_id}/

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
get(request, course_id)#
Returns
  • Amplitude course recommendations for course about page

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
recommendations_count = 4#
class lms.djangoapps.learner_recommendations.views.CrossProductRecommendationsView(**kwargs)#

Bases: APIView

IMPORTANT: Please do not update or use this API. This code has been moved to edx_recommendations plugin. Please use that plugin for further code changes. This API will be removed as part of VAN-1427.

Example Request

GET api/learner_recommendations/cross_product/{course_id}/

get(request, course_id)#

Returns cross product recommendation courses

class lms.djangoapps.learner_recommendations.views.DashboardRecommendationsApiView(**kwargs)#

Bases: APIView

IMPORTANT: Please do not update or use this API. This code has been moved to edx-recommendations plugin. Please use that plugin for further code changes. This API will be removed as part of VAN-1427.

API to get personalized recommendations from Amplitude.

Example Request

GET /api/learner_recommendations/courses/

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
get(request)#

Retrieves course recommendations details.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.NotJwtRestrictedApplication'>)#
class lms.djangoapps.learner_recommendations.views.ProductRecommendationsView(**kwargs)#

Bases: APIView

IMPORTANT: Please do not update or use this API. This code has been moved to edx-recommendations plugin. Please use that plugin for further code changes. This API will be removed as part of VAN-1427.

Example Request

GET api/learner_recommendations/product_recommendations/ GET api/learner_recommendations/product_recommendations/{course_id}/

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
fields = ['title', 'owners', 'image', 'course_type', 'course_runs', 'location_restriction', 'marketing_url', 'advertised_course_run_uuid']#
get(request, course_id=None)#

Returns cross product and Amplitude recommendation courses if a course id is included, otherwise, returns only Amplitude recommendations

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.NotJwtRestrictedApplication'>)#
class lms.djangoapps.learner_recommendations.views.RecommendationsContextView(**kwargs)#

Bases: APIView

IMPORTANT: Please do not update or use this API. This code has been moved to edx-recommendations plugin. Please use that plugin for further code changes. This API will be removed as part of VAN-1427.

Example Request

GET /api/learner_recommendations/recommendations_context/

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
get(request)#

Returns the context needed for the recommendations experiment: - Country Code

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.NotJwtRestrictedApplication'>)#

Module contents#