openedx.core.djangoapps.agreements package

Contents

openedx.core.djangoapps.agreements package#

Submodules#

openedx.core.djangoapps.agreements.api module#

Agreements API

openedx.core.djangoapps.agreements.api.create_integrity_signature(username, course_id)#

Create an integrity signature. If a signature already exists, do not create a new one.

Parameters:
  • username (*)

  • course_id (*)

Returns:

  • IntegritySignature object

openedx.core.djangoapps.agreements.api.create_lti_pii_signature(username, course_id, lti_tools)#

Creates an lti pii tool signature. If the signature already exist, do not create a new one.

Parameters:
  • course_key (*)

  • lti_tools (*)

  • lti_tools_hash (*)

Returns:

  • An LTIPIISignature, or None if a signature already exists.

openedx.core.djangoapps.agreements.api.create_user_agreement_record(user: User, agreement_type: str) UserAgreementRecordData#

Creates a user agreement record with current timestamp.

openedx.core.djangoapps.agreements.api.get_integrity_signature(username, course_id)#

Get an integrity signature.

Parameters:
  • username (*)

  • course_id (*)

Returns:

  • An IntegritySignature object, or None if one does not exist for the user + course combination.

openedx.core.djangoapps.agreements.api.get_integrity_signatures_for_course(course_id)#

Get all integrity signatures for a given course.

Parameters:

course_id (*)

Returns:

  • QuerySet of IntegritySignature objects (can be empty).

openedx.core.djangoapps.agreements.api.get_latest_user_agreement_record(user: User, agreement_type: str) UserAgreementRecordData#

Retrieve the user agreement record for the specified user and agreement type.

An agreement update timestamp can be provided to return a record only if it was signed after that timestamp.

openedx.core.djangoapps.agreements.api.get_lti_pii_signature(username, course_id)#

Get the lti pii signature of a user in a course.

Parameters:
  • username (*)

  • course_id (*)

Returns:

  • An LTIPIISignature object, or None if one does not exist for the user + course combination.

openedx.core.djangoapps.agreements.api.get_pii_receiving_lti_tools(course_id)#

Get a course’s LTI tools that share PII.

Parameters:

course_id (*)

Returns:

  • A List of LTI tools sharing PII.

openedx.core.djangoapps.agreements.api.get_user_agreement_records(user: User) Iterator[UserAgreementRecordData]#

Retrieves all the agreements that the specified user has acknowledged.

openedx.core.djangoapps.agreements.api.user_lti_pii_signature_needed(username, course_id)#

Determines if a user needs to acknowledge the LTI PII Agreement.

Parameters:

username (*)

Returns:

  • True if the user needs to sign a new acknowledgement.

  • False if the acknowledgements are up to date.

openedx.core.djangoapps.agreements.data module#

Public data structures for this app.

class openedx.core.djangoapps.agreements.data.LTIPIISignatureData(user: str, course_id: str, lti_tools: str, lti_tools_hash: str)#

Bases: object

Class that stores an lti pii signature

course_id: str#
lti_tools: str#
lti_tools_hash: str#
user: str#
class openedx.core.djangoapps.agreements.data.LTIToolsReceivingPIIData(lii_tools_receiving_pii: {})#

Bases: object

Class that stores data about the list of LTI tools sharing PII

lii_tools_receiving_pii: {}#
class openedx.core.djangoapps.agreements.data.UserAgreementData(type: str, name: str, summary: str, has_text: bool, url: str | None)#

Bases: object

Data for a user agreement record.

classmethod from_model(model: UserAgreement)#
has_text: bool#
name: str#
summary: str#
type: str#
url: str | None#
class openedx.core.djangoapps.agreements.data.UserAgreementRecordData(username: str, agreement_type: str, accepted_at: datetime | None = None, is_current: bool = False)#

Bases: object

Data for a single user agreement record.

accepted_at: datetime | None#
agreement_type: str#
classmethod from_model(model: UserAgreementRecord)#
is_current: bool#
username: str#

openedx.core.djangoapps.agreements.models module#

Agreements models

class openedx.core.djangoapps.agreements.models.IntegritySignature(*args, **kwargs)#

Bases: TimeStampedModel

This model represents an integrity signature for a user + course combination.

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.

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)#
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>#
user#

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.parent is a ForwardManyToOneDescriptor instance.

user_id#
class openedx.core.djangoapps.agreements.models.LTIPIISignature(*args, **kwargs)#

Bases: TimeStampedModel

This model stores a user’s acknowledgement to share PII via LTI tools in a particular course.

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.

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)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lti_tools#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lti_tools_hash#

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>#
user#

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.parent is a ForwardManyToOneDescriptor instance.

user_id#
class openedx.core.djangoapps.agreements.models.LTIPIITool(*args, **kwargs)#

Bases: TimeStampedModel

This model stores the relationship between a course and the LTI tools in the course that share PII.

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.

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)#
id#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lti_tools#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

lti_tools_hash#

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>#
class openedx.core.djangoapps.agreements.models.ProctoringPIISignature(*args, **kwargs)#

Bases: TimeStampedModel

This model stores a user’s acknowledgment to share PII via proctoring in a particular course.

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.

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)#
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>#
proctoring_provider#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user#

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.parent is a ForwardManyToOneDescriptor instance.

user_id#
class openedx.core.djangoapps.agreements.models.UserAgreement(*args, **kwargs)#

Bases: Model

This model stores agreements that the user can accept, which can gate certain platform features.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

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=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)#
get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)#
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)#
get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)#
property has_text#
history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>#
id#

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.

objects = <django.db.models.manager.Manager object>#
records#

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.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

save_without_historical_record(*args, **kwargs)#

Save the model instance without creating a historical record.

Make sure you know what you’re doing before using this method.

summary#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

text#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

type#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

updated#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

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.agreements.models.UserAgreementRecord(*args, **kwargs)#

Bases: Model

This model stores the agreements a user has accepted or acknowledged.

Each record here represents a user agreeing to the agreement type represented by agreement_type at a particular time.

exception DoesNotExist#

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned#

Bases: MultipleObjectsReturned

agreement#

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.parent is a ForwardManyToOneDescriptor instance.

agreement_id#
get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)#
get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, 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_current#
objects = <django.db.models.manager.Manager object>#
timestamp#

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user#

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.parent is a ForwardManyToOneDescriptor instance.

user_id#

openedx.core.djangoapps.agreements.serializers module#

Serializers for the Agreements app

class openedx.core.djangoapps.agreements.serializers.IntegritySignatureSerializer(*args, **kwargs)#

Bases: ModelSerializer

Serializer for the IntegritySignature model

class Meta#

Bases: object

fields = ('username', 'course_id', 'created_at')#
model#

alias of IntegritySignature

class openedx.core.djangoapps.agreements.serializers.LTIPIISignatureSerializer(*args, **kwargs)#

Bases: ModelSerializer

Serializer for LTIPIISignature model

class Meta#

Bases: object

fields = ('username', 'course_id', 'lti_tools', 'created_at')#
model#

alias of LTIPIISignature

class openedx.core.djangoapps.agreements.serializers.UserAgreementRecordSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for UserAgreementRecordData

class openedx.core.djangoapps.agreements.serializers.UserAgreementSerializer(*args, **kwargs)#

Bases: ModelSerializer

Serializer for UserAgreement model

class Meta#

Bases: object

fields = ('type', 'name', 'summary', 'has_text', 'url', 'updated')#
model#

alias of UserAgreement

read_only_fields = ('type', 'name', 'summary', 'has_text', 'url', 'updated')#

openedx.core.djangoapps.agreements.toggles module#

Toggle for lti pii acknowledgement feature.

openedx.core.djangoapps.agreements.toggles.lti_pii_acknowledgment_enabled(course_key)#

Returns a boolean if lti pii acknowledgements are enabled for a course.

openedx.core.djangoapps.agreements.urls module#

URLs for the Agreements API

openedx.core.djangoapps.agreements.views module#

Views served by the Agreements app

class openedx.core.djangoapps.agreements.views.AuthenticatedAPIView(**kwargs)#

Bases: APIView

Authenticated API View.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
class openedx.core.djangoapps.agreements.views.IntegritySignatureView(**kwargs)#

Bases: AuthenticatedAPIView

Endpoint for an Integrity Signature /integrity_signature/{course_id}

Supports:

HTTP GET: Returns an existing signed integrity agreement (by course id and user)

HTTP GET

** Scenarios ** ?username=xyz returns an existing signed integrity agreement for the given user and course

HTTP POST
  • If an integrity signature does not exist for the user + course, creates one and returns it. If one does exist, returns the existing signature.

get(request, course_id)#

In order to check whether the user has signed the integrity agreement for a given course.

Should return the following:

username (str) course_id (str) created_at (str)

If a username is not given, it should default to the requesting user (or masqueraded user). Only staff should be able to access this endpoint for other users.

post(request, course_id)#

Create an integrity signature for the requesting user and course. If a signature already exists, returns the existing signature instead of creating a new one.

/api/agreements/v1/integrity_signature/{course_id}

Example response:
{

username: “janedoe”, course_id: “org.2/course_2/Run_2”, created_at: “2021-04-23T18:25:43.511Z”

}

class openedx.core.djangoapps.agreements.views.LTIPIISignatureView(**kwargs)#

Bases: AuthenticatedAPIView

Endpoint for a LTI PII Signature /lti_pii_signature/{course_id}

HTTP POST
  • If an LTI PII signature does not exist for the user + course, creates one and returns it. If one does exist, returns the existing signature.

post(request, course_id)#

Create an LTI PII signature for the requesting user and course. If a signature already exists, returns the existing signature instead of creating a new one.

/api/agreements/v1/lti_pii_signature/{course_id}

Example response:
{

username: “janedoe”, course_id: “org.2/course_2/Run_2”, created_at: “2021-04-23T18:25:43.511Z”

}

class openedx.core.djangoapps.agreements.views.UserAgreementRecordsView(**kwargs)#

Bases: APIView

Endpoint for the user agreement records API.

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, agreement_type)#

Get a user’s acknowledgement record for this agreement type.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
post(request, agreement_type)#

Marks a user’s acknowledgement of this agreement type.

class openedx.core.djangoapps.agreements.views.UserAgreementsViewSet(**kwargs)#

Bases: GenericViewSet

Endpoint for the user agreements API.

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'>)#
basename = None#
description = None#
detail = None#
list(request)#

Get all user agreements for this agreement type.

lookup_field = 'type'#
lookup_url_kwarg = 'agreement_type'#
name = None#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
retrieve(request, agreement_type=None, **kwargs)#

Get the user agreement for this agreement type.

suffix = None#
text(request, agreement_type=None)#

Get the text of a user agreement by its type.

openedx.core.djangoapps.agreements.views.is_user_course_or_global_staff(user, course_id)#

Return whether a user is course staff for a given course, described by the course_id, or is global staff.

Module contents#