lms.djangoapps.badges.api package#
Submodules#
lms.djangoapps.badges.api.serializers module#
Serializers for Badges
- class lms.djangoapps.badges.api.serializers.BadgeAssertionSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer for the BadgeAssertion model.
- class Meta#
Bases:
object- fields = ('badge_class', 'image_url', 'assertion_url', 'created')#
- model#
alias of
BadgeAssertion
- class lms.djangoapps.badges.api.serializers.BadgeClassSerializer(*args, **kwargs)#
Bases:
ModelSerializerSerializer for BadgeClass model.
- class Meta#
Bases:
object- fields = ('slug', 'issuing_component', 'display_name', 'course_id', 'description', 'criteria', 'image_url')#
- model#
alias of
BadgeClass
lms.djangoapps.badges.api.urls module#
URLs for badges API
lms.djangoapps.badges.api.views module#
API views for badges
- exception lms.djangoapps.badges.api.views.InvalidCourseKeyError(detail=None, code=None)#
Bases:
APIExceptionRaised the course key given isn’t valid.
- default_detail = 'The course key provided was invalid.'#
- status_code = 400#
- class lms.djangoapps.badges.api.views.UserBadgeAssertions(**kwargs)#
Bases:
ListAPIViewUse Cases
Request a list of assertions for a user, optionally constrained to a course.
Example Requests
GET /api/badges/v1/assertions/user/{username}/
Response Values
Body comprised of a list of objects with the following fields:
badge_class: The badge class the assertion was awarded for. Represented as an object with the following fields:
slug: The identifier for the badge class
issuing_component: The software component responsible for issuing this badge.
display_name: The display name of the badge.
course_id: The course key of the course this badge is scoped to, or null if it isn’t scoped to a course.
description: A description of the award and its significance.
criteria: A description of what is needed to obtain this award.
image_url: A URL to the icon image used to represent this award.
image_url: The baked assertion image derived from the badge_class icon– contains metadata about the award in its headers.
assertion_url: The URL to the OpenBadges BadgeAssertion object, for verification by compatible tools and software.
Params
slug (optional): The identifier for a particular badge class to filter by.
issuing_component (optional): The issuing component for a particular badge class to filter by (requires slug to have been specified, or this will be ignored.) If slug is provided and this is not, assumes the issuing_component should be empty.
course_id (optional): Returns assertions that were awarded as part of a particular course. If slug is provided, and this field is not specified, assumes that the target badge has an empty course_id field. ‘*’ may be used to get all badges with the specified slug, issuing_component combination across all courses.
Returns
200 on success, with a list of Badge Assertion objects.
403 if a user who does not have permission to masquerade as another user specifies a username other than their own.
404 if the specified user does not exist
- {
“count”: 7, “previous”: null, “num_pages”: 1, “results”: [
- {
- “badge_class”: {
“slug”: “special_award”, “issuing_component”: “openedx__course”, “display_name”: “Very Special Award”, “course_id”: “course-v1:edX+DemoX+Demo_Course”, “description”: “Awarded for people who did something incredibly special”, “criteria”: “Do something incredibly special.”, “image”: “http://example.com/media/badge_classes/badges/special_xdpqpBv_9FYOZwN.png”
}, “image_url”: “http://badges.example.com/media/issued/cd75b69fc1c979fcc1697c8403da2bdf.png”, “assertion_url”: “http://badges.example.com/public/assertions/07020647-e772-44dd-98b7-d13d34335ca6”
},
… ]
}
- authentication_classes = (<class 'openedx.core.lib.api.authentication.BearerAuthenticationAllowInactiveUser'>, <class 'edx_rest_framework_extensions.auth.session.authentication.SessionAuthenticationAllowInactiveUser'>)#
- filter_queryset(queryset)#
Return most recent to least recent badge.
- get_queryset()#
Get all badges for the username specified.
- permission_classes = (<class 'openedx.core.djangoapps.user_api.permissions.is_field_shared_factory.<locals>.IsFieldShared'>,)#
- serializer_class#
alias of
BadgeAssertionSerializer