lms.djangoapps.learner_home package

Contents

lms.djangoapps.learner_home package#

Subpackages#

Submodules#

lms.djangoapps.learner_home.serializers module#

Serializers for Learner Home

class lms.djangoapps.learner_home.serializers.AvailableEntitlementSessionSerializer(*args, **kwargs)#

Bases: Serializer

An available entitlement session

class lms.djangoapps.learner_home.serializers.CertificateSerializer(*args, **kwargs)#

Bases: Serializer

Certificate availability info

get_availableDate(enrollment)#

Available date changes based off of Certificate display behavior

get_certPreviewUrl(enrollment)#

Cert preview URL comes from certificate info

get_cert_info(enrollment)#

Utility to grab certificate info for this enrollment or empty object

get_isDownloadable(enrollment)#

Cert is considered downloadable based on certificate status

get_isEarned(enrollment)#

Cert is considered earned based on certificate status

get_isRestricted(enrollment)#

Cert is considered restricted based on certificate status

requires_context = True#
class lms.djangoapps.learner_home.serializers.CourseProviderSerializer(*args, **kwargs)#

Bases: Serializer

Info about a course provider (institution/business) from a CourseOverview

class lms.djangoapps.learner_home.serializers.CourseRunSerializer(*args, **kwargs)#

Bases: Serializer

Information about a course run. Derived from the CourseEnrollment with required context: - “resume_course_urls” (dict) with a matching course_id key - “ecommerce_payment_page” (url) root to the ecommerce page - “course_mode_info” (dict) keyed by course ID, with sub info:

  • “verified_sku” (uid, optional) if the course has an upgrade identifier

  • “days_for_upsell” (int, optional) days before audit student loses access

get_homeUrl(instance)#
get_isArchived(instance)#
get_isStarted(instance)#
get_progressUrl(instance)#
get_resumeUrl(instance)#
get_unenrollUrl(instance)#
get_upgradeUrl(instance)#

If the enrollment mode has a verified upgrade through ecommerce, return the link

requires_context = True#
to_representation(instance)#

Serialize the courserun instance to be able to update the values before the API finishes rendering.

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

Bases: Serializer

Course header information, derived from a CourseOverview

get_socialShareUrl(instance)#
requires_context = True#
class lms.djangoapps.learner_home.serializers.CoursewareAccessSerializer(*args, **kwargs)#

Bases: Serializer

Info determining whether a user should be able to view course material. Mirrors logic in “show_courseware_links_for” from old dashboard.py

get_hasUnmetPrerequisites(enrollment)#

Whether or not a course has unmet prerequisites

get_isStaff(enrollment)#

Determine whether a user has staff access to this course

get_isTooEarly(enrollment)#

Determine if the course is open to a learner (course has started or user has early beta access)

requires_context = True#
class lms.djangoapps.learner_home.serializers.CreditSerializer(*args, **kwargs)#

Bases: Serializer

Credit status information

class lms.djangoapps.learner_home.serializers.EmailConfirmationSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for email confirmation banner resources

class lms.djangoapps.learner_home.serializers.EnrollmentSerializer(*args, **kwargs)#

Bases: Serializer

Info about this particular enrollment. Derived from a CourseEnrollment with added context: - “audit_access_deadlines” (dict): when audit access expires for user. - “ecommerce_payment_page” (url): ecommerce page, used to determine if we can upgrade. - “course_mode_info” (dict): keyed by course ID with the following values:

  • “show_upsell” (bool): whether or not we offer an upsell for this course.

  • “verified_sku” (uuid): ID for the verified mode for upgrade.

  • “show_courseware_link”: keyed by course ID with added metadata.

  • “show_email_settings_for” (dict): keyed by course ID with a boolean whether we

    show email settings.

get_accessExpirationDate(instance)#
get_canUpgrade(enrollment)#

Determine if a user can upgrade this enrollment to verified track

get_hasOptedOutOfEmail(enrollment)#
get_hasStarted(enrollment)#

Determined based on whether there’s a ‘resume’ link on the course

get_isAudit(enrollment)#
get_isAuditAccessExpired(enrollment)#

Mirrors logic in “check_course_expired” but using pre-fetched expiration date

get_isEmailEnabled(enrollment)#
get_isVerified(enrollment)#
requires_context = True#
to_representation(instance)#

Serialize the enrollment instance to be able to update the values before the API finishes rendering.

class lms.djangoapps.learner_home.serializers.EnterpriseDashboardSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for individual enterprise dashboard data

get_url(instance)#
class lms.djangoapps.learner_home.serializers.EntitlementSerializer(*args, **kwargs)#

Bases: Serializer

Entitlement info

get_availableSessions(instance)#
get_changeDeadline(instance)#
get_expirationDate(instance)#
get_isExpired(instance)#
get_isFulfilled(instance)#
requires_context = True#
class lms.djangoapps.learner_home.serializers.GradeDataSerializer(*args, **kwargs)#

Bases: Serializer

Info about grades for this enrollment

get_isPassing(enrollment)#
requires_context = True#
class lms.djangoapps.learner_home.serializers.LearnerDashboardSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for all info required to render the Learner Dashboard

get_courses(instance)#

Get a list of course cards by serializing enrollments and entitlements into a single list.

requires_context = True#
class lms.djangoapps.learner_home.serializers.LearnerEnrollmentSerializer(*args, **kwargs)#

Bases: Serializer

Info for displaying an enrollment on the learner dashboard. Derived from a CourseEnrollment with added context.

get_credit(instance)#

Pull credit statuses from context

get_entitlement(instance)#

If this enrollment is the fulfillment of an entitlement, include information about the entitlement

get_programs(instance)#

If this enrollment is part of a program, include information about the program and related programs

requires_context = True#
class lms.djangoapps.learner_home.serializers.LiteralField(*args, **kwargs)#

Bases: Field

Custom Field for use with fields that will always intentionally serialize to the same static value.

get_attribute(_)#

Given the outgoing object instance, return the primitive value that should be used for this field.

to_representation(_)#

Transform the outgoing native value into primitive data.

class lms.djangoapps.learner_home.serializers.PlatformSettingsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for platform-level info, emails, and URLs

class lms.djangoapps.learner_home.serializers.ProgramsSerializer(*args, **kwargs)#

Bases: Serializer

Programs information

class lms.djangoapps.learner_home.serializers.RelatedProgramSerializer(*args, **kwargs)#

Bases: Serializer

Related programs information

get_logoImgSrc(instance)#
get_numberOfCourses(instance)#
get_programUrl(instance)#
get_provider(instance)#
class lms.djangoapps.learner_home.serializers.SocialMediaSiteSettingsSerializer(*args, **kwargs)#

Bases: Serializer

Social media sharing config for a particular website

class lms.djangoapps.learner_home.serializers.SocialShareSettingsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for social media sharing config

class lms.djangoapps.learner_home.serializers.SuggestedCourseSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for a suggested course from recommendation engine

class lms.djangoapps.learner_home.serializers.UnfulfilledEntitlementSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for an unfulfilled entitlement. This should have the same keys as the LearnerEnrollmentSerializer. We are flattening the two lists into one “course card” list and so should be the same shape.

STATIC_ENTITLEMENT_ENROLLMENT_DATA = {'accessExpirationDate': None, 'canUpgrade': False, 'coursewareAccess': {'hasUnmetPrerequisites': False, 'isStaff': False, 'isTooEarly': False}, 'hasOptedOutOfEmail': False, 'hasStarted': False, 'isAudit': False, 'isAuditAccessExpired': False, 'isEmailEnabled': False, 'isEnrolled': False, 'isVerified': False, 'lastEnrolled': None, 'mode': None}#
get_course(instance)#

Serialize course info from a course overview

get_courseProvider(instance)#

Serialize course provider info from a course overview

get_programs(instance)#

If this entitlement is part of a program, include information about the program and related programs

requires_context = True#

lms.djangoapps.learner_home.test_serializers module#

lms.djangoapps.learner_home.test_utils module#

lms.djangoapps.learner_home.test_views module#

lms.djangoapps.learner_home.test_waffle module#

lms.djangoapps.learner_home.urls module#

Learner Home URL routing configuration

lms.djangoapps.learner_home.utils module#

Additional utilities for Learner Home

lms.djangoapps.learner_home.utils.course_progress_url(course_key) str#

Returns the course progress page’s URL for the current user.

Parameters:

course_key – The course key for which the home url is being requested.

Returns:

The course progress page URL.

lms.djangoapps.learner_home.utils.get_masquerade_user(request)#

Determine if the user is masquerading

Returns: - masquerade_user if allowed and masquerade user found - None if not masquerading

Raises: - PermissionDenied if user is not staff - NotFound if masquerade user does not exist

lms.djangoapps.learner_home.views module#

Views for Learner Home

class lms.djangoapps.learner_home.views.InitializeView(**kwargs)#

Bases: APIView

List of courses a user is enrolled in or entitled to

authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
get(request, *args, **kwargs)#

Get masquerade user and proxy to init request

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'edx_rest_framework_extensions.permissions.NotJwtRestrictedApplication'>)#
lms.djangoapps.learner_home.views.check_course_access(user, course_enrollments)#

Wrapper for checks surrounding user ability to view courseware

Returns: {
<course_enrollment.id>: {

“has_unmet_prerequisites”: True/False, “is_too_early_to_view”: True/False, “user_has_staff_access”: True/False

}

}

lms.djangoapps.learner_home.views.get_audit_access_deadlines(user, course_enrollments)#

Get audit access deadlines for each course enrollment

Returns: - Dict {course_id: <datetime or None>}

lms.djangoapps.learner_home.views.get_cert_statuses(user, course_enrollments)#

Get cert status by course for user enrollments

lms.djangoapps.learner_home.views.get_course_overviews_for_pseudo_sessions(unfulfilled_entitlement_pseudo_sessions)#

Get course overviews for entitlement pseudo sessions. This is required for serializing course providers for entitlements.

Returns: dict of course overviews, keyed by CourseKey

lms.djangoapps.learner_home.views.get_course_programs(user, course_enrollments, site)#

Get programs related to the courses the user is enrolled in.

Returns: {
str(<course_id>): {

“programs”: [list of programs]

}

}

lms.djangoapps.learner_home.views.get_course_share_urls(course_enrollments)#

Get course URLs for sharing on social media

lms.djangoapps.learner_home.views.get_credit_statuses(user, course_enrollments)#

Wrapper for getting credit statuses. Credit statuses are already in a format we can use so this is largely for profiling / testing.

Returns (only for courses with credit options) - Dict {course_id: <credit_status>}

lms.djangoapps.learner_home.views.get_ecommerce_payment_page(user)#

Determine the ecommerce payment page URL if enabled for this user

lms.djangoapps.learner_home.views.get_email_settings_info(user, course_enrollments)#

Given a user and enrollments, determine which courses allow bulk email (show_email_settings_for) and which the learner has opted out from (optouts)

lms.djangoapps.learner_home.views.get_enrollments(user, org_allow_list, org_block_list, course_limit=None)#

Get enrollments and enrollment course modes for user

lms.djangoapps.learner_home.views.get_enterprise_customer(user, request, is_masquerading)#

If we are not masquerading, try to load the enterprise learner from session data, falling back to the db. If we are masquerading, don’t read or write to/from session data, go directly to db.

lms.djangoapps.learner_home.views.get_entitlements(user, org_allow_list, org_block_list)#

Get entitlements for the user

lms.djangoapps.learner_home.views.get_org_block_and_allow_lists()#

Proxy for get_org_black_and_whitelist_for_site to allow for modification / profiling

lms.djangoapps.learner_home.views.get_platform_settings()#

Get settings used for platform level connections: emails, url routes, etc.

lms.djangoapps.learner_home.views.get_resume_urls_for_course_enrollments(user, course_enrollments)#

Modeled off of get_resume_urls_for_enrollments but removes check for actual presence of block in course structure for better performance.

lms.djangoapps.learner_home.views.get_social_share_settings()#

Config around social media sharing campaigns

lms.djangoapps.learner_home.views.get_suggested_courses()#

Currently just returns general recommendations from settings

lms.djangoapps.learner_home.views.get_user_account_confirmation_info(user)#

Determine if a user needs to verify their account and related URL info

lms.djangoapps.learner_home.views.get_user_grade_passing_statuses(course_enrollments)#

Get “passing” status for user in each course

Returns: - Dict {course_id: <boolean (True = Passing grade, False = Failing grade)>}

lms.djangoapps.learner_home.views.serialize_learner_home_data(data, context)#

Wrapper for serialization so we can profile

lms.djangoapps.learner_home.waffle module#

Configuration for features of Learner Home

lms.djangoapps.learner_home.waffle.learner_home_mfe_enabled()#

Determine if Learner Home MFE is enabled, replacing student_dashboard

Module contents#