openedx.core.djangoapps.credit package#
Subpackages#
Submodules#
openedx.core.djangoapps.credit.apps module#
Credit Application Configuration
openedx.core.djangoapps.credit.email_utils module#
This file contains utility functions which will responsible for sending emails.
- openedx.core.djangoapps.credit.email_utils.attach_image(img_dict, filename)#
Attach images in the email headers.
- openedx.core.djangoapps.credit.email_utils.file_path_finder(path)#
Return physical path of file if found.
- openedx.core.djangoapps.credit.email_utils.get_credit_provider_attribute_values(course_key, attribute_name)#
Get the course information from ecommerce and parse the data to get providers.
- Parameters:
course_key (CourseKey) – The identifier for the course.
attribute_name (String) – Name of the attribute of credit provider.
- Returns:
List of provided credit provider attribute values.
- openedx.core.djangoapps.credit.email_utils.get_credit_provider_ids_for_course(course_id)#
Get the provider ids for the course from ecommerce.
- Parameters:
course_id (str) – The identifier for the course.
- Returns:
List of provider ids.
- openedx.core.djangoapps.credit.email_utils.make_providers_strings(providers)#
Get the list of course providers and make them comma seperated string.
- Parameters:
providers – List containing the providers names
- Returns:
strings containing providers names in readable way .
- openedx.core.djangoapps.credit.email_utils.send_credit_notifications(username, course_key)#
Sends email notification to user on different phases during credit course e.g., credit eligibility, credit payment etc.
- openedx.core.djangoapps.credit.email_utils.with_inline_css(html_without_css)#
Returns html with inline css if the css file path exists else returns html with out the inline css.
openedx.core.djangoapps.credit.exceptions module#
Exceptions raised by the credit API.
- exception openedx.core.djangoapps.credit.exceptions.CreditApiBadRequest#
Bases:
ExceptionCould not complete a request to the credit API because there was a problem with the request (as opposed to an internal error).
- exception openedx.core.djangoapps.credit.exceptions.CreditProviderNotConfigured#
Bases:
CreditApiBadRequestThe requested credit provider is not configured correctly for the course.
- exception openedx.core.djangoapps.credit.exceptions.CreditRequestNotFound#
Bases:
CreditApiBadRequestThe request does not exist.
- exception openedx.core.djangoapps.credit.exceptions.InvalidCourseKey(course_key)#
Bases:
InvalidCreditRequestCourse key is invalid.
- exception openedx.core.djangoapps.credit.exceptions.InvalidCreditCourse#
Bases:
CreditApiBadRequestThe course is not configured for credit.
- exception openedx.core.djangoapps.credit.exceptions.InvalidCreditRequest(detail=None, code=None)#
Bases:
APIExceptionAPI request is invalid.
- status_code = 400#
- exception openedx.core.djangoapps.credit.exceptions.InvalidCreditRequirements#
Bases:
CreditApiBadRequestThe requirement dictionary provided has invalid format.
- exception openedx.core.djangoapps.credit.exceptions.InvalidCreditStatus#
Bases:
CreditApiBadRequestThe status is not either “approved” or “rejected”.
- exception openedx.core.djangoapps.credit.exceptions.RequestAlreadyCompleted#
Bases:
CreditApiBadRequestThe user has already submitted a request and received a response from the credit provider.
- exception openedx.core.djangoapps.credit.exceptions.UserIsNotEligible#
Bases:
CreditApiBadRequestThe user has not satisfied eligibility requirements for credit.
- exception openedx.core.djangoapps.credit.exceptions.UserNotEligibleException(course_key, username)#
Bases:
InvalidCreditRequestUser not eligible for credit for a given course.
openedx.core.djangoapps.credit.models module#
Models for Credit Eligibility for courses.
Credit courses allow students to receive university credit for successful completion of a course on EdX
- class openedx.core.djangoapps.credit.models.CreditConfig(*args, **kwargs)#
Bases:
ConfigurationModelManage credit configuration
- CACHE_KEY = 'credit.providers.api.data'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- cache_ttl#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- change_date#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- changed_by#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- changed_by_id#
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=True, **kwargs)#
- get_previous_by_change_date(*, field=<django.db.models.fields.DateTimeField: change_date>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- property is_cache_enabled#
Whether responses from the commerce API will be cached.
- class openedx.core.djangoapps.credit.models.CreditCourse(*args, **kwargs)#
Bases:
ModelModel for tracking a credit course.
- CREDIT_COURSES_CACHE_KEY = 'credit.courses.set'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course_key#
DO NOT REUSE THIS CLASS. Provided for backwards compatibility only!
A placeholder class that provides a way to set the attribute on the model.
- credit_requests#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- credit_requirements#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- eligibilities#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- enabled#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_credit_course(course_key)#
Get the credit course if exists for the given ‘course_key’.
- Parameters:
course_key (CourseKey) – The course identifier
- Raises:
DoesNotExist if no CreditCourse exists for the given course key. –
- Returns:
CreditCourse if one exists for the given course key.
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod is_credit_course(course_key)#
Check whether the course has been configured for credit.
- Parameters:
course_key (CourseKey) – Identifier of the course.
- Returns:
True iff this is a credit course.
- Return type:
bool
- objects = <django.db.models.manager.Manager object>#
- class openedx.core.djangoapps.credit.models.CreditEligibility(*args, **kwargs)#
Bases:
TimeStampedModelA record of a user’s eligibility for credit for a specific course.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- course#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- course_id#
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- deadline#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_deadline(*, field=<django.db.models.fields.DateTimeField: deadline>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_deadline(*, field=<django.db.models.fields.DateTimeField: deadline>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- classmethod get_user_eligibilities(username)#
Returns the eligibilities of given user.
- Parameters:
username (str) – Username of the user
- Returns:
CreditEligibility queryset for the user
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod is_user_eligible_for_credit(course_key, username)#
Check if the given user is eligible for the provided credit course
- Parameters:
course_key (CourseKey) – The course identifier
username (str) – The username of the user
- Returns:
Bool True if the user eligible for credit course else False
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- classmethod update_eligibility(requirements, username, course_key)#
Update the user’s credit eligibility for a course.
A user is eligible for credit when the user has satisfied all requirements for credit in the course.
- Parameters:
requirements (Queryset) – Queryset of `CreditRequirement`s to check.
username (str) – Identifier of the user being updated.
course_key (CourseKey) – Identifier of the course.
Returns: tuple
- username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.credit.models.CreditProvider(*args, **kwargs)#
Bases:
TimeStampedModelThis model represents an institution that can grant credit for a course.
Each provider is identified by unique ID (e.g., ‘ASU’). CreditProvider also includes a url where the student will be sent when he/she will try to get credit for course. Eligibility duration will be use to set duration for which credit eligible message appears on dashboard.
- CREDIT_PROVIDERS_CACHE_KEY = 'credit.providers.list'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- active#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- credit_requests#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- display_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- eligibility_email_message#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- enable_integration#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- fulfillment_instructions#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_credit_provider(provider_id)#
Retrieve a credit provider with provided ‘provider_id’.
- classmethod get_credit_providers(providers_list=None)#
Retrieve a list of all credit providers or filter on providers_list, represented as dictionaries.
- Parameters:
provider_list (list of strings or None) – contains list of ids if required results
filtered (to be)
providers. (None for all)
- Returns:
list of providers represented as dictionaries.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- provider_description#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- provider_id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- provider_status_url#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- provider_url#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- receipt_email_message#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- thumbnail_url#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.credit.models.CreditRequest(*args, **kwargs)#
Bases:
TimeStampedModelA request for credit from a particular credit provider.
When a user initiates a request for credit, a CreditRequest record will be created. Each CreditRequest is assigned a unique identifier so we can find it when the request is approved by the provider. The CreditRequest record stores the parameters to be sent at the time the request is made. If the user re-issues the request (perhaps because the user did not finish filling in forms on the credit provider’s site), the request record will be updated, but the UUID will remain the same.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- REQUEST_STATUS_APPROVED = 'approved'#
- REQUEST_STATUS_CHOICES = (('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'))#
- REQUEST_STATUS_PENDING = 'pending'#
- REQUEST_STATUS_REJECTED = 'rejected'#
- course#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- course_id#
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod credit_requests_for_user(username)#
Retrieve all credit requests for a user.
- Parameters:
username (unicode) – The username of the user.
Returns: list
Example Usage: >>> CreditRequest.credit_requests_for_user(“bob”) [
- {
“uuid”: “557168d0f7664fe59097106c67c3f847”, “timestamp”: 1434631630, “course_key”: “course-v1:HogwartsX+Potions101+1T2015”, “provider”: {
“id”: “HogwartsX”, “display_name”: “Hogwarts School of Witchcraft and Wizardry”,
}, “status”: “pending” # or “approved” or “rejected”
}
]
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- get_status_display(*, field=<django.db.models.fields.CharField: status>)#
- classmethod get_user_request_status(username, course_key)#
Returns the latest credit request of user against the given course.
- Parameters:
username (str) – The username of requesting user
course_key (CourseKey) – The course identifier
- Returns:
CreditRequest if any otherwise None
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- parameters#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- provider#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- provider_id#
- classmethod retire_user(retirement)#
Obfuscates CreditRecord instances associated with original_username. Empties the records’ parameters field and replaces username with its anonymized value, retired_username.
- status#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- uuid#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- class openedx.core.djangoapps.credit.models.CreditRequirement(*args, **kwargs)#
Bases:
TimeStampedModelThis model represents a credit requirement.
Each requirement is uniquely identified by its ‘namespace’ and ‘name’ fields. The ‘name’ field stores the unique name or location (in case of XBlock) for a requirement, which serves as the unique identifier for that requirement. The ‘display_name’ field stores the display name of the requirement. The ‘criteria’ field dictionary provides additional information, clients may need to determine whether a user has satisfied the requirement.
- CACHE_NAMESPACE = 'credit.CreditRequirement.cache.'#
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- active#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod add_or_update_course_requirement(credit_course, requirement, sort_value)#
Add requirement to a given course.
- Parameters:
credit_course (CreditCourse) – The identifier for credit course
requirement (dict) – Requirement dict to be added
- Returns:
(CreditRequirement, created) tuple
- course#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- course_id#
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- criteria#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod disable_credit_requirements(requirement_ids)#
Mark the given requirements inactive.
- Parameters:
requirement_ids (list) – List of ids
- Returns:
None
- display_name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod get_course_requirement(course_key, namespace, name)#
Get credit requirement of a given course.
- Parameters:
course_key (CourseKey) – The identifier for a course
namespace (str) – Namespace of credit course requirements
name (str) – Name of credit course requirement
- Returns:
CreditRequirement object if exists, None otherwise.
- classmethod get_course_requirements(course_key, namespace=None, name=None)#
Get credit requirements of a given course.
- Parameters:
course_key (CourseKey) – The identifier for a course
- Keyword Arguments
namespace (str): Optionally filter credit requirements by namespace. name (str): Optionally filter credit requirements by name.
- Returns:
QuerySet of CreditRequirement model
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- name#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- namespace#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- sort_value#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- statuses#
Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Parent.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()defined below.
- class openedx.core.djangoapps.credit.models.CreditRequirementStatus(*args, **kwargs)#
Bases:
TimeStampedModelThis model represents the status of each requirement.
For a particular credit requirement, a user can either: 1) Have satisfied the requirement (example: approved in-course reverification) 2) Have failed the requirement (example: denied in-course reverification) 3) Neither satisfied nor failed (example: the user hasn’t yet attempted in-course reverification).
Cases (1) and (2) are represented by having a CreditRequirementStatus with the status set to “satisfied” or “failed”, respectively.
In case (3), no CreditRequirementStatus record will exist for the requirement and user.
- exception DoesNotExist#
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned#
Bases:
MultipleObjectsReturned
- REQUIREMENT_STATUS_CHOICES = (('satisfied', 'satisfied'), ('failed', 'failed'), ('declined', 'declined'))#
- classmethod add_or_update_requirement_status(username, requirement, status='satisfied', reason=None)#
Add credit requirement status for given username.
- Parameters:
username (str) – Username of the user
requirement (CreditRequirement) – ‘CreditRequirement’ object
status (str) – Status of the requirement
reason (dict) – Reason of the status
- created#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)#
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)#
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)#
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)#
- get_status_display(*, field=<django.db.models.fields.CharField: status>)#
- classmethod get_statuses(requirements, username)#
Get credit requirement statuses of given requirement and username
- Parameters:
requirements (list of CreditRequirements) – The identifier for a requirement
username (str) – username of the user
- Returns:
Queryset ‘CreditRequirementStatus’ objects
- id#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- modified#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- objects = <django.db.models.manager.Manager object>#
- reason#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- classmethod remove_requirement_status(username, requirement)#
Remove credit requirement status for given username.
- Parameters:
username (str) – Username of the user
requirement (CreditRequirement) – ‘CreditRequirement’ object
- requirement#
Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
Child.parentis aForwardManyToOneDescriptorinstance.
- requirement_id#
- classmethod retire_user(retirement)#
Retire a user by anonymizing
- Parameters:
retirement – UserRetirementStatus of the user being retired
- status#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- username#
A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
- openedx.core.djangoapps.credit.models.default_deadline_for_credit_eligibility()#
The default deadline to use when creating a new CreditEligibility model.
- openedx.core.djangoapps.credit.models.invalidate_credit_courses_cache(sender, **kwargs)#
Invalidate the cache of credit courses.
- openedx.core.djangoapps.credit.models.invalidate_credit_requirement_cache(sender, **kwargs)#
Invalidate the cache of credit requirements.
- openedx.core.djangoapps.credit.models.invalidate_provider_cache(sender, **kwargs)#
Invalidate the cache of credit providers.
openedx.core.djangoapps.credit.routers module#
DRF routers.
- class openedx.core.djangoapps.credit.routers.SimpleRouter(trailing_slash=True, use_regex_path=True)#
Bases:
SimpleRouterSimple DRF router.
- get_lookup_regex(viewset, lookup_prefix='')#
Given a viewset, return the portion of URL regex that is used to match against a single instance. Note that lookup_prefix is not used directly inside REST rest_framework itself, but is required in order to nicely support nested router implementations, such as drf-nested-routers. alanjds/drf-nested-routers
openedx.core.djangoapps.credit.serializers module#
Credit API Serializers
- class openedx.core.djangoapps.credit.serializers.CreditCourseSerializer(*args, **kwargs)#
Bases:
ModelSerializerCreditCourse Serializer
- class Meta#
Bases:
object- exclude = ('id',)#
- model#
alias of
CreditCourse
- class openedx.core.djangoapps.credit.serializers.CreditEligibilitySerializer(*args, **kwargs)#
Bases:
ModelSerializerCreditEligibility serializer.
- class Meta#
Bases:
object- fields = ('username', 'course_key', 'deadline')#
- model#
alias of
CreditEligibility
- get_course_key(obj)#
Returns the course key associated with the course.
- class openedx.core.djangoapps.credit.serializers.CreditProviderCallbackSerializer(*args, **kwargs)#
Bases:
SerializerSerializer for input to the CreditProviderCallback view.
This is used solely for validating the input.
- validate_signature(value)#
Validate the signature and ensure the provider is setup properly.
- validate_timestamp(value)#
Ensure the request has been received in a timely manner.
- class openedx.core.djangoapps.credit.serializers.CreditProviderSerializer(*args, **kwargs)#
Bases:
ModelSerializerCreditProvider
- class Meta#
Bases:
object- fields = ('id', 'display_name', 'url', 'status_url', 'description', 'enable_integration', 'fulfillment_instructions', 'thumbnail_url')#
- model#
alias of
CreditProvider
openedx.core.djangoapps.credit.services module#
Implementation of “credit” XBlock service
- class openedx.core.djangoapps.credit.services.CreditService#
Bases:
objectCourse Credit XBlock service
- get_credit_state(user_id, course_key_or_id, return_course_info=False)#
Return all information about the user’s credit state inside of a given course.
- Parameters:
user_id (-) – The PK of the User in question
course_key (-) – The course ID (as string or CourseKey)
- Returns:
NONE (user not found or is not enrolled or is not credit course) - or - {
’enrollment_mode’: the mode that the user is enrolled in the course ‘profile_fullname’: the name that the student registered under, used for verification ‘is_credit_course’: if the course has been marked as a credit bearing course ‘credit_requirement_status’: the user’s status in fulfilling those requirements ‘course_name’: optional display name of the course ‘course_end_date’: optional end date of the course
}
- is_credit_course(course_key_or_id)#
Returns boolean if the passed in course_id (string) or course_key is a credit_course
- remove_credit_requirement_status(user_id, course_key_or_id, req_namespace, req_name)#
A simple wrapper around the method of the same name in api.eligibility.py. The only difference is that a user_id is passed in.
For more information, see documentation on this method name in api.eligibility.py
- set_credit_requirement_status(user_id, course_key_or_id, req_namespace, req_name, status='satisfied', reason=None)#
A simple wrapper around the method of the same name in api.eligibility.py. The only difference is that a user_id is passed in.
For more information, see documentation on this method name in api.eligibility.py
openedx.core.djangoapps.credit.signature module#
Calculate digital signatures for messages sent to/from credit providers, using a shared secret key.
The signature is calculated as follows:
Encode all parameters of the request (except the signature) in a string.
Encode each key/value pair as a string of the form “{key}:{value}”.
Concatenate key/value pairs in ascending alphabetical order by key.
Calculate the HMAC-SHA256 digest of the encoded request parameters, using a 32-character shared secret key.
Encode the digest in hexadecimal.
It is the responsibility of the credit provider to check the signature of messages we send them, and it is our responsibility to check the signature of messages we receive from the credit provider.
Retrieve the shared secret for a particular credit provider.
It is possible for the secret to be stored in 2 ways: 1 - a key/value pair of provider_id and secret string
{‘cool_school’: ‘123abc’}
- 2 - a key/value pair of provider_id and secret list
{‘cool_school’: [‘987zyx’, ‘123abc’]}
- openedx.core.djangoapps.credit.signature.signature(params, shared_secret)#
Calculate the digital signature for parameters using a shared secret.
- Parameters:
params (dict) – Parameters to sign. Ignores the “signature” key if present.
shared_secret (str) – The shared secret string.
- Returns:
The 32-character signature.
- Return type:
str
openedx.core.djangoapps.credit.tasks module#
This file contains celery tasks for credit course views.
openedx.core.djangoapps.credit.urls module#
URLs for the credit app.
openedx.core.djangoapps.credit.utils module#
Utilities for the credit app.
- openedx.core.djangoapps.credit.utils.get_course_blocks(course_key, category)#
Retrieve all XBlocks in the course for a particular category.
Returns only XBlocks that are published and haven’t been deleted.
openedx.core.djangoapps.credit.views module#
Views for the credit Django app.
- class openedx.core.djangoapps.credit.views.CreditCourseViewSet(**kwargs)#
Bases:
PutAsCreateMixin,UpdateModelMixin,ReadOnlyModelViewSetCreditCourse endpoints.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- basename = None#
- description = None#
- detail = None#
- dispatch(request, *args, **kwargs)#
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- get_object()#
Returns the object the view is displaying.
You may want to override this if you need to provide non-standard queryset lookups. Eg if objects are referenced using multiple keyword arguments in the url conf.
- lookup_field = 'course_key'#
- lookup_value_regex = '(?:[^/+]+(/|\\+)[^/+]+(/|\\+)[^/?]+)'#
- name = None#
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.IsAdminUser'>)#
- serializer_class#
alias of
CreditCourseSerializer
- suffix = None#
- class openedx.core.djangoapps.credit.views.CreditEligibilityView(**kwargs)#
Bases:
ListAPIViewReturns eligibility for a user-course combination.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- filter_queryset(queryset)#
Given a queryset, filter it with whichever filter backend is in use.
You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'openedx.core.lib.api.permissions.IsStaffOrOwner'>)#
- serializer_class#
alias of
CreditEligibilitySerializer
- class openedx.core.djangoapps.credit.views.CreditProviderCallbackView(**kwargs)#
Bases:
APIViewCallback used by credit providers to update credit request status.
- authentication_classes = ()#
- dispatch(request, *args, **kwargs)#
.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.
- permission_classes = ()#
- post(request, provider_id)#
POST handler.
- class openedx.core.djangoapps.credit.views.CreditProviderRequestCreateView(**kwargs)#
Bases:
APIViewCreates a credit request for the given user and course, if the user is eligible for credit.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'openedx.core.lib.api.permissions.IsStaffOrOwner'>)#
- post(request, provider_id)#
POST handler.
- class openedx.core.djangoapps.credit.views.CreditProviderViewSet(**kwargs)#
Bases:
ReadOnlyModelViewSetCredit provider endpoints.
- authentication_classes = (<class 'edx_rest_framework_extensions.auth.jwt.authentication.JwtAuthentication'>, <class 'openedx.core.lib.api.authentication.BearerAuthentication'>, <class 'rest_framework.authentication.SessionAuthentication'>)#
- basename = None#
- description = None#
- detail = None#
- filter_queryset(queryset)#
Given a queryset, filter it with whichever filter backend is in use.
You are unlikely to want to override this method, although you may need to call it either from a list view, or from a custom get_object method if you want to apply the configured filtering backend to the default queryset.
- lookup_field = 'provider_id'#
- lookup_value_regex = '[a-z,A-Z,0-9,\\-]+'#
- name = None#
- pagination_class = None#
- permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
- serializer_class#
alias of
CreditProviderSerializer
- suffix = None#