lms.djangoapps.instructor.views package

Contents

lms.djangoapps.instructor.views package#

Submodules#

lms.djangoapps.instructor.views.api module#

Instructor Dashboard API views

JSON views which the instructor dashboard requests.

Many of these GETs may become PUTs in the future.

class lms.djangoapps.instructor.views.api.AddUsersToCohorts(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View method that accepts an uploaded file (using key “uploaded-file”) containing cohort assignments for users. This method spawns a celery task to do the assignments, and a CSV file with results is provided via data downloads.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.assign_to_cohorts'#
post(request, course_id)#
This method spawns a celery task to do the assignments, and a CSV file with results

is provided via data downloads.

class lms.djangoapps.instructor.views.api.BulkBetaModifyAccess(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Enroll or unenroll users in beta testing program.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enroll_beta'#
post(request, course_id)#

Query parameters: - identifiers is string containing a list of emails and/or usernames separated by

anything split_input_list can handle.

  • action is one of [‘add’, ‘remove’]

serializer_class#

alias of ModifyAccessSerializer

class lms.djangoapps.instructor.views.api.CalculateGradesCsvView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Initiates a Celery task to calculate grades CSV. AlreadyRunningError is raised if the course’s grades are already being updated.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiates a Celery task to calculate grades CSV.

class lms.djangoapps.instructor.views.api.CertificateExceptionView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Add/Remove students to/from the certificate allowlist.

delete(request, course_id)#

Remove certificate exception for a student.

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.

http_method_names = ['post', 'delete']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.certificate_exception_view'#
post(request, course_id)#

Add certificate exception for a student.

serializer_class#

alias of CertificateSerializer

class lms.djangoapps.instructor.views.api.CertificateInvalidationView(**kwargs)#

Bases: APIView

Invalidate/Re-Validate students to/from certificate.

Parameters:
  • request – HttpRequest object

  • course_id – course identifier of the course for whom to add/remove certificates exception.

Returns:

JsonResponse object with success/error message or certificate invalidation data.

delete(request, course_id)#

Invalidate/Re-Validate students to/from certificate.

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.

http_method_names = ['post', 'delete']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.certificate_invalidation_view'#
post(request, course_id)#

Invalidate/Re-Validate students to/from certificate.

serializer_class#

alias of CertificateSerializer

class lms.djangoapps.instructor.views.api.CertificateTask(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API endpoint for handling certificate-related administrative tasks for a given course.

Supported actions: - “toggle”: Enable or disable self-generated certificates. - “generate”: Initiate certificate generation for all enrolled students. - “regenerate”: Regenerate certificates based on selected certificate statuses.

URL pattern:

POST /courses/{course_id}/instructor/api/certificates/{action}/

The action path parameter determines the task to perform. The request must be authenticated and the user must have the appropriate permission for the action.

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 = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.views.api.HasCertificateActionPermission'>]#
post(request, course_id, action=None)#

Handles POST requests for certificate actions.

Depending on the action parameter, different tasks are performed:

Args:

request (HttpRequest): The HTTP request object. course_id (str): The ID of the course on which to perform the action. action (str, optional): The certificate task to perform. Must be one of:

  • “toggle”: Enable or disable certificates for the course. No additional

    parameters are required.

  • “generate”: Generate certificates for eligible learners. No additional

    parameters are required.

  • “regenerate”: Regenerate certificates for learners. Requires an additional

    parameter in the request body:

    • statuses (list of str): List of certificate statuses to regenerate

      (e.g., [“downloaded”, “issued”]).

Returns:

A DRF Response object containing a success message or error details. If the action is invalid, returns HTTP 400 with an error message.

Return type:

Response

Example request body for regenerate action:
{

“statuses”: [“downloaded”, “issued”]

}

class lms.djangoapps.instructor.views.api.ChangeDueDate(**kwargs)#

Bases: APIView

Grants a due date extension to a student for a particular unit.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Grants a due date extension to a student for a particular unit.

params:

url (str): The URL related to the block that needs the due date update. due_datetime (str): The new due date and time for the block. student (str): The email or username of the student whose access is being modified.

serializer_class#

alias of BlockDueDateSerializer

class lms.djangoapps.instructor.views.api.CohortCSV(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

Submit a CSV file to assign users to cohorts

Example Requests:

POST /api/cohorts/v1/courses/{course_id}/users/

Response Values
  • Empty as this is executed asynchronously.

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'>)#
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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'rest_framework.permissions.IsAdminUser'>)#
post(request, course_key_string)#

View method that accepts an uploaded file (using key “uploaded-file”) containing cohort assignments for users. This method spawns a celery task to do the assignments, and a CSV file with results is provided via data downloads.

class lms.djangoapps.instructor.views.api.ExportOra2DataView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Pushes a Celery task which will aggregate ora2 responses for a course into a .csv

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiates a task to export Open Response Assessment (ORA) data for a course.

Parameters:
  • request – The HTTP request object

  • course_id – The ID of the course for which to export ORA data

Returns:

A JSON response containing the status message indicating the task has been initiated

Return type:

Response

class lms.djangoapps.instructor.views.api.ExportOra2SubmissionFilesView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Pushes a Celery task which will download and compress all submission files (texts, attachments) into a zip archive.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiates a task to export all ORA2 submission files for a course. Returns a JSON response indicating the export task has been started.

class lms.djangoapps.instructor.views.api.ExportOra2SummaryView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Pushes a Celery task which will aggregate a summary of students’ progress in ora2 tasks for a course into a .csv

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiates a Celery task to generate an ORA summary report for the specified course.

Parameters:
  • request – The HTTP request object

  • course_id – The string representation of the course key

Returns:

A JSON response with a status message indicating the report generation has started

Return type:

Response

class lms.djangoapps.instructor.views.api.GenerateBulkCertificateExceptions(**kwargs)#

Bases: APIView

Adds students to the certificate allowlist using data from the uploaded CSV file.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.generate_bulk_certificate_exceptions'#
post(request, course_id)#
Parameters:
  • request (WSGIRequest) – Django HTTP request object.

  • course_id (string) – Course-Run key

Returns:

{

general_errors: [errors related to csv file e.g. csv uploading, csv attachment, content reading, etc. ], row_errors: {

data_format_error: [users/data in csv file that are not well formatted], user_not_exist: [users that cannot be found in the LMS], user_already_allowlisted: [users that already appear on the allowlist of this course-run], user_not_enrolled: [users that are not currently enrolled in this course-run], user_on_certificate_invalidation_list: [users that have an active certificate invalidation in this

course-run]

}, success: [list of users sucessfully added to the certificate allowlist]

}

Return type:

dict

class lms.djangoapps.instructor.views.api.GenerateCertificateExceptions(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Generate Certificate for students on the allowlist.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.generate_certificate_exceptions'#
post(request, course_id, generate_for=None)#
Parameters:
  • request – HttpRequest object,

  • course_id – course identifier of the course for whom to generate certificates

  • generate_for – string to identify whether to generate certificates for ‘all’ or ‘new’ additions to the allowlist

Returns:

JsonResponse object containing success/failure message and certificate exception data

class lms.djangoapps.instructor.views.api.GetAnonIds(**kwargs)#

Bases: APIView

Respond with 2-column CSV output of user-id, anonymized-user-id. This API processes the incoming request to generate a CSV file containing two columns: user-id and anonymized-user-id. The CSV is returned as a response to the client.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Handle POST request to generate a CSV output.

Returns:

A CSV file with two columns: user-id and anonymized-user-id.

Return type:

Response

class lms.djangoapps.instructor.views.api.GetCourseSurveyResults(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

get the survey results report for the particular course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enrollment_report'#
post(request, course_id)#

method to return survey results report for the particular course.

class lms.djangoapps.instructor.views.api.GetGradingConfig(**kwargs)#

Bases: APIView

Respond with json which contains a html formatted grade summary.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Post method to return grading config.

class lms.djangoapps.instructor.views.api.GetInactiveEnrolledStudents(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Initiate generation of a CSV file containing information about students who are enrolled in a course but have inactive account.

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(request, *args, **kwargs)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiate generation of a CSV file containing information about students who are enrolled in a course but have inactive account.

Responds with JSON

{“status”: “… status message …”}

class lms.djangoapps.instructor.views.api.GetIssuedCertificates(**kwargs)#

Bases: APIView

Responds with JSON if CSV is not required. contains a list of issued certificates.

all_issued_certificates(request, course_id)#

common method for both post and get. This method will return all issued certificates.

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(request, course_id)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_issued_certificates'#
post(request, course_id)#

Arguments: course_id :returns: [{course_id: xyz, mode: ‘honor’}, …]} :rtype: {“certificates”

class lms.djangoapps.instructor.views.api.GetProblemResponses(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Initiate generation of a CSV file containing all student answers to a given problem.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Initiate generation of a CSV file containing all student answers to a given problem.

Example requests

POST /courses/{course_id}/instructor/api/get_problem_responses {

“problem_location”: “{usage_key1},{usage_key2},{usage_key3}””

} POST /courses/{course_id}/instructor/api/get_problem_responses {

“problem_location”: “{usage_key}”, “problem_types_filter”: “problem”

}

POST Parameters

A POST request can include the following parameters:

  • problem_location: A comma-separated list of usage keys for the blocks to include in the report. If the location is a block that contains other blocks, (such as the course, section, subsection, or unit blocks) then all blocks under that block will be included in the report.

  • problem_types_filter: Optional. A comma-separated list of block types to include in the repot. If set, only blocks of the specified types will be included in the report.

To get data on all the poll and survey blocks in a course, you could POST the usage key of the course for problem_location, and “poll, survey” as the value for problem_types_filter.

Example Response: If initiation is successful (or generation task is already running): ```json {

“status”: “The problem responses report is being created. …”, “task_id”: “4e49522f-31d9-431a-9cff-dd2a2bf4c85a”

}#

Responds with BadRequest if any of the provided problem locations are faulty.

class lms.djangoapps.instructor.views.api.GetProctoredExamResults(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

get the proctored exam results report for the particular course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
post(request, course_id)#

get the proctored exam results report for the particular course.

class lms.djangoapps.instructor.views.api.GetStudentEnrollmentStatus(**kwargs)#

Bases: APIView

Get the enrollment status of a student.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_enrollments'#
post(request, course_id)#

Permission: Limited to staff access. Takes query parameter unique_student_identifier

class lms.djangoapps.instructor.views.api.GetStudentsFeatures(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Respond with json which contains a summary of all enrolled students profile information.

Responds with JSON

{“students”: [{-student-info-}, …]}

TO DO accept requests for different attribute sets.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id, csv=False)#

Handle POST requests to retrieve student profile information for a specific course.

Parameters:
  • request – The HTTP request object.

  • course_id – The ID of the course for which to retrieve student information.

  • csv – Optional; if ‘csv’ is present in the URL, it indicates that the response should be in CSV format.

  • None. (Defaults to)

Returns:

A JSON response containing student profile information, or CSV if the csv parameter is provided.

Return type:

Response

class lms.djangoapps.instructor.views.api.GetStudentsWhoMayEnroll(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Initiate generation of a CSV file containing information about

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(request, *args, **kwargs)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#
Initiate generation of a CSV file containing information about

students who may enroll in a course.

Responds with JSON

{“status”: “… status message …”}

class lms.djangoapps.instructor.views.api.HasCertificateActionPermission#

Bases: BasePermission

DRF permission class to validate course-level certificate task permissions based on the action URL parameter.

has_permission(request, view)#

Check whether the user has permission to perform the requested certificate action on the specified course.

permission_map = {'generate': 'instructor.start_certificate_generation', 'regenerate': 'instructor.start_certificate_regeneration', 'toggle': 'instructor.enable_certificate_generation'}#
class lms.djangoapps.instructor.views.api.InstructorTaskSerializerV2(*args, **kwargs)#

Bases: Serializer

Serializer that describes the format of a single instructor task.

class lms.djangoapps.instructor.views.api.InstructorTasks(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

Lists currently running instructor tasks

Parameters
  • With no arguments, lists running tasks.

  • problem_location_str lists task history for problem

  • problem_location_str and unique_student_identifier lists task

    history for problem AND student (intersection)

Example Requests:

GET /courses/{course_id}/instructor/api/v0/tasks

Response Values
{
“tasks”: [
{

“status”: “Incomplete”, “task_type”: “grade_problems”, “task_id”: “2519ff31-22d9-4a62-91e2-55495895b355”, “created”: “2019-01-15T18:00:15.902470+00:00”, “task_input”: “{}”, “duration_sec”: “unknown”, “task_message”: “No status information available”, “requester”: “staff”, “task_state”: “PROGRESS”

}

]

}

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

List instructor tasks filtered by course_id.

Use Cases

Lists currently running instructor tasks

Parameters
  • With no arguments, lists running tasks.

  • problem_location_str lists task history for problem

  • problem_location_str and unique_student_identifier lists task

    history for problem AND student (intersection)

Example Requests:

GET /courses/{course_id}/instructor/api/v0/tasks

Response Values ```json

{
“tasks”: [
{

“status”: “Incomplete”, “task_type”: “grade_problems”, “task_id”: “2519ff31-22d9-4a62-91e2-55495895b355”, “created”: “2019-01-15T18:00:15.902470+00:00”, “task_input”: “{}”, “duration_sec”: “unknown”, “task_message”: “No status information available”, “requester”: “staff”, “task_state”: “PROGRESS”

}

]

}

```

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
class lms.djangoapps.instructor.views.api.InstructorTasksListSerializer(*args, **kwargs)#

Bases: Serializer

Serializer to describe the response of the instructor tasks list API.

class lms.djangoapps.instructor.views.api.ListBackgroundEmailTasks(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

List background email tasks.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.email'#
post(request, course_id)#

List background email tasks.

class lms.djangoapps.instructor.views.api.ListCourseEnrollmentsView(**kwargs)#

Bases: APIView

View to list all enrollments (learners/students) for a specific course. Requires the user to have instructor access.

Supports optional search and pagination parameters: - search: Filter users by username, email, first_name, or last_name - page: Page number (default: 1) - page_size: Number of results per page (default: 20, max: 100)

Returns JSON of the form {

“course_id”: “some/course/id”, “enrollments”: [

{

“username”: “student1”, “email”: “student1@example.org”, “first_name”: “Jane”, “last_name”: “Doe”,

}

], “count”: 100, “num_pages”: 5, “current_page”: 1

}

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_enrollments'#
post(request, course_id)#

Handles POST request to list course enrollments.

Parameters:
  • request (HttpRequest) – The request object containing user data.

  • course_id (str) – The ID of the course to list enrollments for.

Returns:

A Response object containing the list of enrollments or an error message.

Return type:

Response

Raises:

Http404 – If the course does not exist.

class lms.djangoapps.instructor.views.api.ListCourseRoleMembersView(**kwargs)#

Bases: APIView

View to list instructors and staff for a specific course. Requires the user to have instructor access.

rolename is one of [‘instructor’, ‘staff’, ‘beta’, ‘ccx_coach’]

Supports optional search and pagination parameters: - search: Filter users by username, email, first_name, or last_name - page: Page number (default: 1) - page_size: Number of results per page (default: 20, max: 100)

Returns JSON of the form {

“course_id”: “some/course/id”, “staff”: [

{

“username”: “staff1”, “email”: “staff1@example.org”, “first_name”: “Joe”, “last_name”: “Shmoe”,

}

], “count”: 10, “num_pages”: 1, “current_page”: 1

}

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.edit_course_access'#
post(request, course_id)#

Handles POST request to list instructors and staff.

Parameters:
  • request (HttpRequest) – The request object containing user data.

  • course_id (str) – The ID of the course to list instructors and staff for.

Returns:

A Response object containing the list of instructors and staff or an error message.

Return type:

Response

Raises:

Http404 – If the course does not exist.

class lms.djangoapps.instructor.views.api.ListEmailContent(**kwargs)#

Bases: APIView

List the content of bulk emails sent

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.email'#
post(request, course_id)#

List the content of bulk emails sent for a specific course.

Parameters:
  • request (HttpRequest) – The HTTP request object.

  • course_id (str) – The ID of the course for which to list the bulk emails.

Returns:

A response object containing the list of bulk email contents.

Return type:

HttpResponse

class lms.djangoapps.instructor.views.api.ListEntranceExamInstructorTasks(**kwargs)#

Bases: APIView

List entrance exam related instructor tasks.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.show_tasks'#
post(request, course_id)#

List entrance exam related instructor tasks.

Takes either of the following query parameters
  • unique_student_identifier is an email or username

  • all_students is a boolean

class lms.djangoapps.instructor.views.api.ListForumMembers(**kwargs)#

Bases: APIView

Lists forum members of a certain rolename. Limited to staff access.

The requesting user must be at least staff. Staff forum admins can access all roles EXCEPT for FORUM_ROLE_ADMINISTRATOR

which is limited to instructors.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>, <class 'lms.djangoapps.instructor.permissions.ForumAdminRequiresInstructorAccess'>)#
permission_name = 'instructor.view_forum_members'#
post(request, course_id)#

Handle the POST request to list forum members with a certain role name for the given course.

Parameters:
  • request (HttpRequest) – The request object containing the data sent by the client.

  • course_id (int) – The ID of the course for which the role is being assigned or managed.

Returns:

The Json constians lists of members.

Return type:

Response

Raises:

ValidationError – If the provided rolename is not valid according to the serializer.

serializer_class#

alias of ForumRoleNameSerializer

class lms.djangoapps.instructor.views.api.ListInstructorTasks(**kwargs)#

Bases: APIView

List instructor tasks.

Takes optional query parameters.
  • With no arguments, lists running tasks.

  • problem_location_str lists task history for problem

  • problem_location_str and unique_student_identifier lists task

    history for problem AND student (intersection)

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.show_tasks'#
post(request, course_id)#

List instructor tasks.

serializer_class#

alias of ListInstructorTaskInputSerializer

class lms.djangoapps.instructor.views.api.ListReportDownloads(**kwargs)#

Bases: APIView

List grade CSV files that are available for download for this course.

Takes the following query parameters: - (optional) report_name - name of the report

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#
class lms.djangoapps.instructor.views.api.MarkStudentCanSkipEntranceExam(**kwargs)#

Bases: APIView

Mark a student to skip entrance exam.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.allow_student_to_bypass_entrance_exam'#
post(request, course_id)#

Takes unique_student_identifier as required POST parameter.

class lms.djangoapps.instructor.views.api.ModifyAccess(**kwargs)#

Bases: APIView

Modify staff/instructor access of other user. Requires instructor access.

NOTE: instructors cannot remove their own instructor access.

Query parameters: unique_student_identifier is the target user’s username or email rolename is one of [‘instructor’, ‘staff’, ‘beta’, ‘ccx_coach’] action is one of [‘allow’, ‘revoke’]

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.edit_course_access'#
post(request, course_id)#

Modify staff/instructor access of other user. Requires instructor access.

serializer_class#

alias of AccessSerializer

class lms.djangoapps.instructor.views.api.OverrideProblemScoreView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

DRF view to override a student’s score for a specific problem.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.override_grades'#
post(request, course_id)#
Takes the following query parameters:
  • problem_to_reset: a urlname of a problem

  • unique_student_identifier: an email or username

  • score: the score to override with

Returns a response indicating the success or failure of the operation. If the user does not have permission to override scores for the problem, a 403 Forbidden response is returned. If the problem cannot be found or parsed, a 400 Bad Request response is returned. If the score override is successful, a 200 OK response is returned with the task status and the problem and student identifiers in the response payload.

serializer_class#

alias of OverrideProblemScoreSerializer

class lms.djangoapps.instructor.views.api.ProblemGradeReport(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Request a CSV showing students’ grades for all problems in the course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.research'#
post(request, course_id)#

Request a CSV showing students’ grades for all problems in the course.

AlreadyRunningError is raised if the course’s grades are already being updated.

class lms.djangoapps.instructor.views.api.ProblemResponseReportInitiate(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Initiate generation of a CSV file containing all student answers to a given problem.

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'>)#
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 = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
post(request, course_id)#

Initiate generation of a CSV file containing all student answers to a given problem.

Example requests

POST /api/instructor/v1/reports/{course_id}/generate/problem_responses {
“problem_locations”: [

“{usage_key1}”, “{usage_key2}”, “{usage_key3}”

]

} POST /api/instructor/v1/reports/{course_id}/generate/problem_responses {

“problem_locations”: [“{usage_key}”], “problem_types_filter”: [“problem”]

}

POST Parameters

A POST request can include the following parameters:

  • problem_location: A list of usage keys for the blocks to include in the report. If the location is a block that contains other blocks, (such as the course, section, subsection, or unit blocks) then all blocks under that block will be included in the report.

  • problem_types_filter: Optional. A comma-separated list of block types to include in the report. If set, only blocks of the specified types will be included in the report.

To get data on all the poll and survey blocks in a course, you could POST the usage key of the course for problem_location, and “poll, survey” as the value for problem_types_filter.

Example Response: If initiation is successful (or generation task is already running): ```json {

“status”: “The problem responses report is being created. …”, “task_id”: “4e49522f-31d9-431a-9cff-dd2a2bf4c85a”

}#

Responds with BadRequest if any of the provided problem locations are faulty.

class lms.djangoapps.instructor.views.api.ProblemResponseReportPostParamsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer that describes that POST parameters for the report generation API.

class lms.djangoapps.instructor.views.api.ProblemResponsesReportStatusSerializer(*args, **kwargs)#

Bases: Serializer

Serializer that describes the response of the problem response report generation API.

class lms.djangoapps.instructor.views.api.RegisterAndEnrollStudents(**kwargs)#

Bases: APIView

Create new account and Enroll students in this course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enroll'#
post(request, course_id)#

Create new account and Enroll students in this course. Passing a csv file that contains a list of students. Order in csv should be the following email = 0; username = 1; name = 2; country = 3. If there are more than 4 columns in the csv: cohort = 4, course mode = 5. Requires staff access.

-If the email address and username already exists and the user is enrolled in the course, do nothing (including no email gets sent out)

-If the email address already exists, but the username is different, match on the email address only and continue to enroll the user in the course using the email address as the matching criteria. Note the change of username as a warning message (but not a failure). Send a standard enrollment email which is the same as the existing manual enrollment

-If the username already exists (but not the email), assume it is a different user and fail to create the new account. The failure will be messaged in a response in the browser.

class lms.djangoapps.instructor.views.api.ReportDownloadSerializer(*args, **kwargs)#

Bases: Serializer

Serializer that describes a single report download.

class lms.djangoapps.instructor.views.api.ReportDownloads(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view to list report downloads for a course.

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

List report CSV files that are available for download for this course.

Use Cases

Lists reports available for download

Example Requests:

GET /api/instructor/v1/reports/{course_id}

Response Values ```json {

“downloads”: [
{

“url”: “https://1.mock.url”, “link”: “<a href=”https://1.mock.url”>mock_file_name_1</a>”, “name”: “mock_file_name_1”

}

]

}#

The report name will depend on the type of report generated. For example a problem responses report for an entire course might be called:

edX_DemoX_Demo_Course_student_state_from_block-v1_edX+DemoX+Demo_Course+type@course+block@course_2021-04-30-0918.csv

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>,)#
class lms.djangoapps.instructor.views.api.ReportDownloadsListSerializer(*args, **kwargs)#

Bases: Serializer

Serializer that describes the response of the report downloads list API.

class lms.djangoapps.instructor.views.api.RescoreEntranceExamView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Starts a background process for a student’s attempts counter for entrance exam. Optionally deletes student state for a problem. Limited to instructor access.

Takes either of the following parameters:
  • unique_student_identifier: an email or username

  • all_students: a boolean

all_students and unique_student_identifier cannot both be present.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.rescore_exams'#
post(request, course_id)#

Initiates a Celery task to rescore the entrance exam for a student or all students.

serializer_class#

alias of RescoreEntranceExamSerializer

class lms.djangoapps.instructor.views.api.RescoreProblem(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Starts a background process a students attempts counter. Optionally deletes student state for a problem. Rescore for all students is limited to instructor access.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.override_grades'#
post(request, course_id)#
Takes either of the following query parameters
  • problem_to_reset is a urlname of a problem

  • unique_student_identifier is an email or username

  • all_students is a boolean

all_students and unique_student_identifier cannot both be present.

serializer_class#

alias of ProblemResetSerializer

class lms.djangoapps.instructor.views.api.ResetDueDate(**kwargs)#

Bases: APIView

Rescinds a due date extension for a student on a particular unit.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

reset a due date extension to a student for a particular unit. params:

url (str): The URL related to the block that needs the due date update. student (str): The email or username of the student whose access is being modified. reason (str): Optional param.

serializer_class#

alias of BlockDueDateSerializer

class lms.djangoapps.instructor.views.api.ResetStudentAttempts(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Resets a students attempts counter or starts a task to reset all students attempts counters. Optionally deletes student state for a problem. Limited to staff access. Some sub-methods limited to instructor access.

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.

http_method_names = ['post']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Takes some of the following query parameters - problem_to_reset is a urlname of a problem - unique_student_identifier is an email or username - all_students is a boolean

requires instructor access mutually exclusive with delete_module mutually exclusive with delete_module

  • delete_module is a boolean

    requires instructor access mutually exclusive with all_students

serializer_class#

alias of StudentAttemptsSerializer

class lms.djangoapps.instructor.views.api.ResetStudentAttemptsForEntranceExam(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Resets a students attempts counter or starts a task to reset all students attempts counters for entrance exam. Optionally deletes student state for entrance exam. Limited to staff access. Some sub-methods limited to instructor access.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Resets a student’s entrance exam attempts or deletes entrance exam state.

Parameters (in request.data):
  • unique_student_identifier (str, optional):

    Email or username of the student. If provided, must exist.

  • all_students (bool, optional):

    If True, applies to all students. Mutually exclusive with unique_student_identifier and delete_module.

  • delete_module (bool, optional):

    If True, deletes entrance exam state for the student. Mutually exclusive with all_students.

Behavior:
  • At least one of unique_student_identifier, all_students, or delete_module must be provided.

  • If unique_student_identifier is provided but does not exist, returns a validation error.

  • If mutually exclusive parameters are provided, returns a validation error.

  • Requires staff access; instructor access required for all_students or delete_module actions.

  • Returns a JSON response with the task status and student identifier.

serializer_class#

alias of ResetEntranceExamAttemptsSerializer

class lms.djangoapps.instructor.views.api.SendEmail(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Send an email to self, staff, cohorts, or everyone involved in a course.

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.

http_method_names = ['post']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.email'#
post(request, course_id)#

Query Parameters: - ‘send_to’ specifies what group the email should be sent to

Options are defined by the CourseEmail model in lms/djangoapps/bulk_email/models.py

  • ‘subject’ specifies email’s subject

  • ‘message’ specifies email’s content

serializer_class#

alias of SendEmailSerializer

class lms.djangoapps.instructor.views.api.ShowStudentExtensions(**kwargs)#

Bases: APIView

Shows all of the due date extensions granted to a particular student in a particular course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Handles POST requests to retrieve due date extensions for a specific student within a specified course.

Parameters: - request: The HTTP request object containing user-submitted data. - course_id: The ID of the course for which the extensions are being queried.

Data expected in the request: - student: A required field containing the identifier of the student for whom

the due date extensions are being retrieved. This data is extracted from the request body.

Returns: - A JSON response containing the details of the due date extensions granted to

the specified student in the specified course.

serializer_class#

alias of ShowStudentExtensionSerializer

class lms.djangoapps.instructor.views.api.ShowUnitExtensionsView(**kwargs)#

Bases: APIView

API view to retrieve a list of students who have due date extensions for a specific unit in a course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Shows all of the students which have due date extensions for the given unit.

serializer_class#

alias of ShowUnitExtensionsSerializer

class lms.djangoapps.instructor.views.api.StartCertificateGeneration(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Start generating certificates for all students enrolled in given course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.start_certificate_generation'#
post(request, course_id)#

Generating certificates for all students enrolled in given course.

class lms.djangoapps.instructor.views.api.StartCertificateRegeneration(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Start regenerating certificates for students whose certificate statuses lie with in ‘certificate_statuses’ entry in POST data.

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.

http_method_names = ['post']#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.start_certificate_regeneration'#
post(request, course_id)#

certificate_statuses ‘certificate_statuses’ in POST data.

serializer_class#

alias of CertificateStatusesSerializer

class lms.djangoapps.instructor.views.api.StudentProgressUrl(**kwargs)#

Bases: APIView

Get the progress url of a student. Limited to staff access.

Takes query parameter unique_student_identifier and if the student exists returns e.g. {

‘progress_url’: ‘/../…’

}

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'>)#
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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enrollment_report'#
post(request, course_id)#

Post method for validating incoming data and generating progress URL

serializer_class#

alias of StudentProgressUrlSerializer

class lms.djangoapps.instructor.views.api.StudentProgressUrlSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for course renders

get_progress_url(obj)#

Return the progress URL for the student. :param obj: The dictionary containing data for the serializer. :type obj: dict

Returns:

The URL for the progress of the student in the course.

Return type:

str

class lms.djangoapps.instructor.views.api.StudentsUpdateEnrollmentView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view to enroll or unenroll students in a course.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enroll'#
post(request, course_id)#

Handle POST request to enroll or unenroll students.

Parameters: - action (str): ‘enroll’ or ‘unenroll’ - identifiers (str): comma/newline separated emails or usernames - auto_enroll (bool): auto-enroll in verified track if applicable - email_students (bool): whether to send enrollment emails - async_processing (bool): whether to process asynchronously - reason (str, optional): reason for enrollment change

Returns: - JSON response with action, auto_enroll flag, and enrollment results.

class lms.djangoapps.instructor.views.api.UpdateForumRoleMembership(**kwargs)#

Bases: APIView

Modify a user’s forum role in a course.

Permissions: - Must be authenticated. - Must be instructor or (staff + forum admin). - Only instructors can grant FORUM_ROLE_ADMINISTRATOR.

Request (POST body): {

“unique_student_identifier”: “user@example.com”, “rolename”: “FORUM_ROLE_MODERATOR”, “action”: “allow” or “revoke”

}

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>, <class 'lms.djangoapps.instructor.permissions.ForumAdminRequiresInstructorAccess'>)#
permission_name = 'instructor.edit_forum_roles'#
post(request, course_id)#

Handles role modification requests for a forum user.

Query parameters: - email is the target users email - rolename is one of [FORUM_ROLE_ADMINISTRATOR, FORUM_ROLE_GROUP_MODERATOR,

FORUM_ROLE_MODERATOR, FORUM_ROLE_COMMUNITY_TA]

  • action is one of [‘allow’, ‘revoke’]

serializer_class#

alias of UpdateForumRoleMembershipSerializer

lms.djangoapps.instructor.views.api.add_certificate_exception(course_key, student, certificate_exception)#

Add a certificate exception.

Raises ValueError in case Student is already allowlisted or if they appear on the block list.

Parameters:
  • course_key – identifier of the course whose certificate exception will be added.

  • student – User object whose certificate exception will be added.

  • certificate_exception – A dict object containing certificate exception info.

Returns:

Allowlist item in dict format containing certificate exception info.

lms.djangoapps.instructor.views.api.common_exceptions_400(func)#

Catches common exceptions and renders matching 400 errors. (decorator without arguments)

lms.djangoapps.instructor.views.api.create_and_enroll_user(email, username, name, country, password, course_id, course_mode, enrolled_by, email_params, email_user=True)#
Create a new user and enroll him/her to the given course, return list of errors in the following format
Error format:

each error is key-value pait dict with following key-value pairs. 1. username: username of the user to enroll 1. email: email of the user to enroll 1. response: readable error message

Parameters:
  • email – user’s email address

  • username – user’s username

  • name – user’s name

  • country – user’s country

  • password – user’s password

  • course_id – course identifier of the course in which to enroll the user.

  • course_mode – mode for user enrollment, e.g. ‘honor’, ‘audit’ etc.

  • enrolled_by – User who made the manual enrollment entry (usually instructor or support)

  • email_params – information to send to the user via email

  • email_user – If True and it’s a new user, an email will be sent to them upon account creation.

Returns:

list of errors

lms.djangoapps.instructor.views.api.create_manual_course_enrollment(user, course_id, mode, enrolled_by, reason, state_transition)#

Create course enrollment for the given student and create manual enrollment audit trail.

Parameters:
  • user – User who is to enroll in course

  • course_id – course identifier of the course in which to enroll the user.

  • mode – mode for user enrollment, e.g. ‘honor’, ‘audit’ etc.

  • enrolled_by – User who made the manual enrollment entry (usually instructor or support)

  • reason – Reason behind manual enrollment

  • state_transition – state transition denoting whether student enrolled from un-enrolled, un-enrolled from enrolled etc.

:return CourseEnrollment instance.

lms.djangoapps.instructor.views.api.create_user_and_user_profile(email, username, name, country, password)#

Create a new user, add a new Registration instance for letting user verify its identity and create a user profile.

Parameters:
  • email – user’s email address

  • username – user’s username

  • name – user’s name

  • country – user’s country

  • password – user’s password

Returns:

User instance of the new user.

lms.djangoapps.instructor.views.api.enable_certificate_generation(*args, **kwargs)#
lms.djangoapps.instructor.views.api.generate_random_string(length)#

Create a string of random characters of specified length

lms.djangoapps.instructor.views.api.generate_unique_password(generated_passwords, password_length=12)#

generate a unique password for each student.

lms.djangoapps.instructor.views.api.get_student(username_or_email)#

Retrieve and return User object from db, raise ValueError if user is does not exists or is not enrolled in the given course.

Parameters:
  • username_or_email – String containing either user name or email of the student.

  • course_key – CourseKey object identifying the current course.

Returns:

User object

lms.djangoapps.instructor.views.api.get_user_invoice_preference(request, course_id)#

Gets invoice copy user’s preferences.

lms.djangoapps.instructor.views.api.invalidate_certificate(request, generated_certificate, notes, student)#

Invalidate given GeneratedCertificate and add CertificateInvalidation record for future reference or re-validation.

Parameters:
  • request – HttpRequest object

  • generated_certificate – GeneratedCertificate object, the certificate we want to invalidate

  • notes – notes values.

  • student – User object, this user is tied to the generated_certificate we are going to invalidate

Returns:

dict object containing updated certificate invalidation data.

lms.djangoapps.instructor.views.api.parse_request_data(request)#

Parse and return request data, raise ValueError in case of invalid JSON data.

Parameters:

request – HttpRequest request object.

Returns:

dict object containing parsed json data.

lms.djangoapps.instructor.views.api.parse_request_data_and_get_user(request)#

Parse request data into Certificate Exception and User object. Certificate Exception is the dict object containing information about certificate exception.

Parameters:
  • request

  • course_key – Course Identifier of the course for whom to process certificate exception

Returns:

key-value pairs containing certificate exception data and User object

lms.djangoapps.instructor.views.api.re_validate_certificate(request, *args, **kwargs)#
lms.djangoapps.instructor.views.api.remove_certificate_exception(course_key, student)#

Remove certificate exception for given course and student from the certificate allowlist.

Raises ValueError if an error occurs during removal of the allowlist entry.

Parameters:
  • course_key – identifier of the course whose certificate exception needs to be removed.

  • student – User object whose certificate exception needs to be removed.

Returns:

lms.djangoapps.instructor.views.api.require_course_permission(permission)#

Decorator with argument that requires a specific permission of the requesting user. If the requirement is not satisfied, returns an HttpResponseForbidden (403).

Assumes that request is in args[0]. Assumes that course_id is in kwargs[‘course_id’].

lms.djangoapps.instructor.views.api.require_finance_admin(func)#

Decorator for checking finance administrator access before executing an HTTP endpoint. This decorator is designed to be used for a request based action on a course. It assumes that there will be a request object as well as a course_id attribute to leverage to check course level privileges.

If the user does not have privileges for this operation, this will return HttpResponseForbidden (403).

lms.djangoapps.instructor.views.api.require_sales_admin(func)#

Decorator for checking sales administrator access before executing an HTTP endpoint. This decorator is designed to be used for a request based action on a course. It assumes that there will be a request object as well as a course_id attribute to leverage to check course level privileges.

If the user does not have privileges for this operation, this will return HttpResponseForbidden (403).

lms.djangoapps.instructor.views.api.start_certificate_generation(request, course_id)#

Initiates the generation of certificates for all enrolled students in the course.

This function triggers an asynchronous background task that generates certificates for every student enrolled in the specified course. It returns a response payload containing a confirmation message and the task ID for tracking the task’s progress.

Parameters:
  • request (HttpRequest) – The HTTP request object.

  • course_key (CourseKey) – The course identifier for which to generate certificates.

Returns:

A dictionary with a success message and the task ID.

Return type:

dict

lms.djangoapps.instructor.views.api.start_certificate_regeneration(request, course_id, certificates_statuses)#

Initiates regeneration of certificates for students based on given certificate statuses.

This function triggers a background task that regenerates certificates for students whose certificates match the provided list of statuses.

Parameters:
  • request (HttpRequest) – The HTTP request object.

  • course_key (CourseKey) – The identifier of the course for which certificates are being regenerated.

  • certificates_statuses (list[str]) – A list of certificate statuses to filter the affected certificates.

Returns:

A dictionary with a success message and success status.

Return type:

dict

lms.djangoapps.instructor.views.api.toggle_certificate_generation(request, course_id)#

Enable or disable student-generated certificates for a course.

Based on the value of the POST field certificates-enabled, this function updates the course setting to allow or prevent students from generating their own certificates. This function assumes that permission checks have already been performed.

Parameters:
  • request (HttpRequest) – The incoming POST request.

  • course_id (str) – The course identifier in string format.

Returns:

Redirects back to the instructor dashboard (certificates section) after updating the course setting.

Return type:

HttpResponseRedirect

lms.djangoapps.instructor.views.api_urls module#

Instructor API endpoint urls.

lms.djangoapps.instructor.views.api_v2 module#

Instructor API v2 views.

This module contains the v2 API endpoints for instructor functionality. These APIs are designed to be consumed by MFEs and other API clients.

class lms.djangoapps.instructor.views.api_v2.BetaTesterModifyView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Add or remove one or more beta testers for a course.

Example Request

POST /api/instructor/v2/courses/{course_id}/beta_testers/modify

Parameters

  • identifier (required): List of emails or usernames of learners

  • action (required): ‘add’ or ‘remove’

  • email_students (optional): Send email notification (default: false)

  • auto_enroll (optional): Auto-enroll in the course (add action; default: false)

Response Values

{

“action”: “add”, “results”: [

{“identifier”: “learner@example.com”, “success”: true, “is_active”: true}, {“identifier”: “missing”, “success”: false, “error”: “User not found: missing”}

]

}

Returns

  • 200: OK - Per-identifier results returned (successes and failures)

  • 400: Bad Request - Invalid top-level parameters

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enroll_beta'#
post(request, course_id)#

Add or remove one or more beta testers for the course.

class lms.djangoapps.instructor.views.api_v2.BulkCertificateExceptionsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to grant certificate exceptions via CSV upload.

Example Requests

POST /api/instructor/v2/courses/{course_id}/certificates/exceptions/bulk

POST Request Body

Form data with CSV file uploaded as ‘file’ field. CSV format: username_or_email,notes (optional second column)

Returns

  • 200: OK - Bulk exceptions processed with success/error details

  • 400: Bad Request - Invalid CSV file or format

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.certificate_exception_view'#
post(request, course_id)#

Grant certificate exceptions via CSV upload.

class lms.djangoapps.instructor.views.api_v2.CertificateConfigView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to retrieve certificate configuration for a course.

Use Cases

Check if certificate generation is enabled for the platform and validate course existence.

Example Requests

GET /api/instructor/v2/courses/{course_id}/certificates/config

Response Values

{

“enabled”: true

}

Returns

  • 200: OK - Returns certificate configuration

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

get(request, course_id)#

Retrieve certificate configuration.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_issued_certificates'#
class lms.djangoapps.instructor.views.api_v2.CertificateExceptionsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to grant or remove certificate exceptions (allowlist).

Example Requests

POST /api/instructor/v2/courses/{course_id}/certificates/exceptions DELETE /api/instructor/v2/courses/{course_id}/certificates/exceptions

POST Request Body

{

“learners”: [“username1”, “username2”], “notes”: “Reason for granting exceptions”

}

DELETE Request Body

{

“username”: “username1”

}

Returns

  • 200: OK - Exception granted/removed successfully

  • 400: Bad Request - Invalid request or user not found

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

delete(request, course_id)#

Remove certificate exception (remove from allowlist).

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.certificate_exception_view'#
post(request, course_id)#

Grant certificate exceptions (add to allowlist).

class lms.djangoapps.instructor.views.api_v2.CertificateGenerationHistoryView(**kwargs)#

Bases: ListAPIView

View to retrieve certificate generation history for a course.

Example Requests

GET /api/instructor/v2/courses/{course_id}/certificates/generation_history GET /api/instructor/v2/courses/{course_id}/certificates/generation_history?page=2

Response Values

{

“count”: 25, “next”: “http://example.com/api/instructor/v2/courses/…/certificates/generation_history?page=2”, “previous”: null, “results”: [

{

“task_name”: “Regenerated”, “date”: “January 15, 2024”, “details”: “audit not passing states”

}, {

“task_name”: “Generated”, “date”: “January 10, 2024”, “details”: “For exceptions”

]

}

Parameters

course_id: Course key for the course page (optional): Page number for pagination page_size (optional): Number of results per page

Returns

  • 200: OK - Returns paginated list of certificate generation history

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

get_queryset()#

Returns the queryset of certificate generation history.

This method returns a Django QuerySet that will be paginated by DRF.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_issued_certificates'#
serializer_class#

alias of CertificateGenerationHistorySerializer

class lms.djangoapps.instructor.views.api_v2.CertificateInvalidationsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to invalidate or re-validate certificates.

Example Requests

POST /api/instructor/v2/courses/{course_id}/certificates/invalidations DELETE /api/instructor/v2/courses/{course_id}/certificates/invalidations

POST Request Body

{

“learners”: [“username1”, “username2”], “notes”: “Reason for invalidation”

}

DELETE Request Body

{

“username”: “username1”

}

Returns

  • 200: OK - Certificate invalidated/re-validated successfully

  • 400: Bad Request - Invalid request or certificate not found

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

delete(request, course_id)#

Re-validate certificate (remove invalidation).

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.certificate_invalidation_view'#
post(request, course_id)#

Invalidate certificates.

class lms.djangoapps.instructor.views.api_v2.ChangeDueDateView(**kwargs)#

Bases: APIView

Grants a due date extension to a student for a particular unit. this version works with a new payload that is JSON and more up to date.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id)#

Grants a due date extension to a learner for a particular unit.

params:

blockId (str): The URL related to the block that needs the due date update. due_datetime (str): The new due date and time for the block. email_or_username (str): The email or username of the learner whose access is being modified.

serializer_class#

alias of BlockDueDateSerializerV2

class lms.djangoapps.instructor.views.api_v2.CourseAllowancesView(**kwargs)#

Bases: DeveloperErrorViewMixin, ListAPIView

List or bulk-create exam allowances for a course.

Example Requests

GET /api/instructor/v2/courses/{course_id}/special_exams/allowances GET /api/instructor/v2/courses/{course_id}/special_exams/allowances?search=student1 GET /api/instructor/v2/courses/{course_id}/special_exams/allowances?ordering=-value POST /api/instructor/v2/courses/{course_id}/special_exams/allowances

Query Parameters

search (optional): Filter by username or email. ordering (optional): Sort by field. Prefix with ‘-’ for descending.

Valid values: username, email, exam_name, allowance_type, value.

page (optional): Page number for pagination. page_size (optional): Number of results per page.

ORDERING_FIELDS = {'allowance_type': 'key', 'email': 'user.email', 'exam_name': 'proctored_exam.exam_name', 'key': 'key', 'proctored_exam.exam_name': 'proctored_exam.exam_name', 'user.email': 'user.email', 'user.username': 'user.username', 'username': 'user.username', 'value': 'value'}#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
post(request, course_id)#

Bulk-create allowances across multiple exams and users.

serializer_class#

alias of ExamAllowanceSerializer

class lms.djangoapps.instructor.views.api_v2.CourseEnrollmentsView(**kwargs)#

Bases: DeveloperErrorViewMixin, ListAPIView

List all active enrollments for a course with optional search, filtering, and pagination.

Example Requests

GET /api/instructor/v2/courses/{course_id}/enrollments GET /api/instructor/v2/courses/{course_id}/enrollments?search=john GET /api/instructor/v2/courses/{course_id}/enrollments?is_beta_tester=true GET /api/instructor/v2/courses/{course_id}/enrollments?page=2&page_size=50

Response Values

{

“course_id”: “course-v1:edX+DemoX+Demo_Course”, “count”: 150, “num_pages”: 15, “current_page”: 1, “start”: 0, “next”: “http://example.com/api/instructor/v2/courses/…/enrollments?page=2”, “previous”: null, “results”: [

{

“username”: “learner1”, “full_name”: “Jane Doe”, “email”: “jane@example.com”, “mode”: “audit”, “is_beta_tester”: false

]

}

Parameters

course_id: Course key for the course. search (optional): Filter by username, email, first name, or last name. is_beta_tester (optional): Filter by beta tester status (true/false). page (optional): Page number for pagination. page_size (optional): Number of results per page (default: 10, max: 100).

Returns

  • 200: OK - Returns paginated list of active enrollments

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]#
filterset_class#

alias of CourseEnrollmentFilter

get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

get_serializer_context()#

Extra context provided to the serializer class.

list(request, *args, **kwargs)#
permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_enrollments'#
serializer_class#

alias of CourseEnrollmentSerializerV2

class lms.djangoapps.instructor.views.api_v2.CourseExamAttemptsView(**kwargs)#

Bases: DeveloperErrorViewMixin, ListAPIView

List all exam attempts across all exams in a course with optional search, sorting, and pagination.

Example Requests

GET /api/instructor/v2/courses/{course_id}/special_exams/attempts GET /api/instructor/v2/courses/{course_id}/special_exams/attempts?search=student1 GET /api/instructor/v2/courses/{course_id}/special_exams/attempts?ordering=-started_at GET /api/instructor/v2/courses/{course_id}/special_exams/attempts?page=2&page_size=50

Query Parameters

search (optional): Filter by username or email. ordering (optional): Sort by field. Prefix with ‘-’ for descending.

Valid values: username, exam_name, time_limit, type, started_at, completed_at, status.

page (optional): Page number for pagination. page_size (optional): Number of results per page.

ORDERING_FIELDS = {'completed_at': 'completed_at', 'email': 'user.email', 'end_time': 'completed_at', 'exam_name': 'proctored_exam.exam_name', 'proctored_exam.exam_name': 'proctored_exam.exam_name', 'proctored_exam.time_limit_mins': 'proctored_exam.time_limit_mins', 'start_time': 'started_at', 'started_at': 'started_at', 'status': 'status', 'time_limit': 'proctored_exam.time_limit_mins', 'user.email': 'user.email', 'user.username': 'user.username', 'username': 'user.username'}#
get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
serializer_class#

alias of ExamAttemptSerializer

class lms.djangoapps.instructor.views.api_v2.CourseMetadataView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

Retrieve comprehensive course metadata including enrollment counts, dashboard configuration, permissions, and navigation sections.

get(request, course_id)#

Retrieve comprehensive course information including metadata, enrollment statistics, dashboard configuration, and user permissions.

Use Cases

Retrieve comprehensive course metadata including enrollment counts, dashboard configuration, permissions, and navigation sections.

Example Requests

GET /api/instructor/v2/courses/{course_id}

Response Values

{

“course_id”: “course-v1:edX+DemoX+Demo_Course”, “display_name”: “Demonstration Course”, “org”: “edX”, “course_number”: “DemoX”, “enrollment_start”: “2013-02-05T00:00:00Z”, “enrollment_end”: null, “start”: “2013-02-05T05:00:00Z”, “end”: “2024-12-31T23:59:59Z”, “pacing”: “instructor”, “has_started”: true, “has_ended”: false, “total_enrollment”: 150, “enrollment_counts”: {

“total”: 150, “audit”: 100, “verified”: 40, “honor”: 10

}, “num_sections”: 12, “grade_cutoffs”: “A is 0.9, B is 0.8, C is 0.7, D is 0.6”, “course_errors”: [], “studio_url”: “https://studio.example.com/course/course-v1:edX+DemoX+2024”, # May be null if user does not have access: “admin_console_url”: “http://apps.local.openedx.io:2025/admin-console/authz”, “permissions”: {

“admin”: false, “instructor”: true, “finance_admin”: false, “sales_admin”: false, “staff”: true, “forum_admin”: true, “data_researcher”: false

}, “tabs”: [

{

“tab_id”: “courseware”, “title”: “Course”, “url”: “INSTRUCTOR_MICROFRONTEND_URL/courses/course-v1:edX+DemoX+2024/courseware”

}, {

“tab_id”: “progress”, “title”: “Progress”, “url”: “INSTRUCTOR_MICROFRONTEND_URL/courses/course-v1:edX+DemoX+2024/progress”

},

], “disable_buttons”: false, “analytics_dashboard_message”: “To gain insights into student enrollment and participation…”

}

Parameters

course_key: Course key for the course.

Returns

  • 200: OK - Returns course metadata

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.CourseTeamMemberView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Revoke one or more course roles from a user.

DELETE Example Request (single role)

DELETE /api/instructor/v2/courses/{course_id}/team/jane_doe {

“roles”: [“staff”]

}

DELETE Example Request (multiple roles)

DELETE /api/instructor/v2/courses/{course_id}/team/jane_doe {

“roles”: [“staff”, “beta”]

}

DELETE Response Values

{

“identifier”: “jane_doe”, “roles”: [“staff”, “beta”], “action”: “revoke”, “success”: true

}

Returns

  • 200: Role(s) revoked successfully

  • 400: Invalid parameters

  • 401: User is not authenticated

  • 403: User lacks course team management permissions (requires instructor or discussion Administrator role)

  • 404: Course or user not found

  • 409: Cannot remove own instructor access

delete(request, course_id, email_or_username)#

Revoke one or more course roles from a user.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.CourseTeamPermission'>)#
class lms.djangoapps.instructor.views.api_v2.CourseTeamRolesView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

List the available course team roles for a specific course.

The returned roles are filtered based on course configuration. For example, the ccx_coach role is only included when the CUSTOM_COURSES_EDX feature flag is enabled and the course has CCX enabled (course.enable_ccx).

When the editable=true query parameter is passed, the results are further filtered to only include roles the requesting user has permission to assign. Discussion Administrators will only see forum roles; instructors will see all roles.

GET Example Request

GET /api/instructor/v2/courses/{course_id}/team/roles GET /api/instructor/v2/courses/{course_id}/team/roles?editable=true

GET Response Values

{

“course_id”: “course-v1:edX+DemoX+Demo_Course”, “results”: [

{“role”: “staff”, “display_name”: “Staff”}, {“role”: “limited_staff”, “display_name”: “Limited Staff”}, {“role”: “instructor”, “display_name”: “Admin”}, {“role”: “beta”, “display_name”: “Beta Tester”}, {“role”: “data_researcher”, “display_name”: “Data Researcher”}

]

}

Returns

  • 200: OK

  • 401: User is not authenticated

  • 403: User lacks course team management permissions (requires instructor or discussion Administrator role)

get(request, course_id)#

Return the list of available course team roles for this course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.CourseTeamPermission'>)#
class lms.djangoapps.instructor.views.api_v2.CourseTeamView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

List course team members, or grant/revoke a role for one or more users.

GET Example Requests

GET /api/instructor/v2/courses/{course_id}/team GET /api/instructor/v2/courses/{course_id}/team?role=staff

GET Response Values

Each result is one record per user, aggregating all of that user’s roles into a roles array. Each role object contains the role identifier and its localized display_name.

When role is omitted, returns all team members across all roles:

{

“course_id”: “course-v1:edX+DemoX+Demo_Course”, “role”: null, “results”: [

{

“username”: “jane_doe”, “email”: “jane@example.com”, “first_name”: “Jane”, “last_name”: “Doe”, “roles”: [

{“role”: “staff”, “display_name”: “Staff”}, {“role”: “beta”, “display_name”: “Beta Tester”}, {“role”: “ccx_coach”, “display_name”: “CCX Coach”}

]

}

]

}

When role is specified, returns only members with that role (still one record per user, with the roles array containing only that role):

{

“course_id”: “course-v1:edX+DemoX+Demo_Course”, “role”: “staff”, “results”: [

{

“username”: “staff_user1”, “email”: “staff1@example.com”, “first_name”: “Bob”, “last_name”: “Jones”, “roles”: [

{“role”: “staff”, “display_name”: “Staff”}

]

}

]

}

POST Example Request (grant)

POST /api/instructor/v2/courses/{course_id}/team {

“identifiers”: [“jane_doe”, “john@example.com”], “role”: “staff”, “action”: “allow”

}

POST Example Request (revoke)

POST /api/instructor/v2/courses/{course_id}/team {

“identifiers”: [“jane_doe”], “role”: “staff”, “action”: “revoke”

}

POST Response Values

{

“action”: “allow”, “role”: “staff”, “results”: [

{

“identifier”: “jane_doe”, “error”: false, “userDoesNotExist”: false, “is_active”: true

}, {

“identifier”: “john@example.com”, “error”: false, “userDoesNotExist”: false, “is_active”: true

}

]

}

Returns

  • 200: OK (GET, POST - role granted/revoked)

  • 400: Invalid parameters

  • 401: User is not authenticated

  • 403: User lacks course team management permissions (requires instructor or discussion Administrator role)

  • 404: Course not found

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(request, course_id)#

List course team members, optionally filtered by role and identity.

If no role is specified, returns members across all course and forum roles. The optional email_or_username query param performs a case-insensitive substring match against username and email.

Results are paginated via page and page_size.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.CourseTeamPermission'>)#
post(request, course_id)#

Grant or revoke a course role for one or more users.

class lms.djangoapps.instructor.views.api_v2.DeleteStateView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Delete a learner’s problem state permanently.

The learner query parameter is required. This operation is destructive and cannot be undone.

delete(request, course_id, problem)#

Delete learner problem state.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
class lms.djangoapps.instructor.views.api_v2.EnrollmentModifyView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Enroll or unenroll one or more learners in a course.

Example Request

POST /api/instructor/v2/courses/{course_id}/enrollments/modify

Parameters

  • identifier (required): List of emails or usernames of learners

  • action (required): ‘enroll’ or ‘unenroll’

  • auto_enroll (optional): Auto-enroll in verified track (enroll action; default: false)

  • email_students (optional): Send email notification (default: false)

  • reason (optional): Reason for the change

Response Values

{

“action”: “enroll”, “results”: [

{

“identifier”: “learner@example.com”, “success”: true, “user_is_registered”: true, “enrollment”: true, “allowed”: false, “auto_enroll”: false

}, {

“identifier”: “bad@”, “success”: false, “error”: “Invalid email address: bad@”

}

]

}

Returns

  • 200: OK - Per-identifier results returned (successes and failures)

  • 400: Bad Request - Invalid top-level parameters

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks staff permissions

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enroll'#
post(request, course_id)#

Enroll or unenroll one or more learners in the course.

class lms.djangoapps.instructor.views.api_v2.ExamAllowanceView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Grant, update, or remove an allowance for a student on a proctored exam.

Example Requests

POST /api/instructor/v2/courses/{course_id}/special_exams/{exam_id}/allowance DELETE /api/instructor/v2/courses/{course_id}/special_exams/{exam_id}/allowance

delete(request, course_id, exam_id)#

Remove allowances for one or more students on a proctored exam.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
post(request, course_id, exam_id)#

Grant an allowance for a student on a proctored exam.

class lms.djangoapps.instructor.views.api_v2.GenerateReportView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

Generate a specific type of report for a course.

Example Requests

POST /api/instructor/v2/courses/{course_key}/reports/enrolled_students/generate POST /api/instructor/v2/courses/{course_key}/reports/grade/generate POST /api/instructor/v2/courses/{course_key}/reports/problem_responses/generate

Response Values

{

“status”: “The report is being created. Please check the data downloads section for the status.”

}

Parameters

course_key: Course key for the course. report_type: Type of report to generate. Valid values:

  • enrolled_students: Enrolled Students Report

  • pending_enrollments: Pending Enrollments Report

  • pending_activations: Pending Activations Report (inactive users with enrollments)

  • anonymized_student_ids: Anonymized Student IDs Report

  • grade: Grade Report

  • problem_grade: Problem Grade Report

  • problem_responses: Problem Responses Report

  • ora2_summary: ORA Summary Report

  • ora2_data: ORA Data Report

  • ora2_submission_files: ORA Submission Files Report

  • issued_certificates: Issued Certificates Report

Returns

  • 200: OK - Report generation task has been submitted

  • 400: Bad Request - Task is already running or invalid report type

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
property permission_name#

Return the appropriate permission name based on the requested report type. For the issued certificates report, mirror the v1 behavior by using VIEW_ISSUED_CERTIFICATES (course-level staff access). For all other reports, require CAN_RESEARCH.

post(request, course_id, report_type)#

Generate a specific type of report for a course.

class lms.djangoapps.instructor.views.api_v2.GradedSubsectionsView(**kwargs)#

Bases: APIView

View to retrieve graded subsections with due dates

get(request, course_id)#

Retrieves a list of graded subsections (units with due dates) within a specified course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.GradingConfigView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view for retrieving course grading configuration.

Returns an HTML-formatted summary of the course grading context, including the course grader type, graded sections with assignment types and weights, and all graded blocks.

GET returns text/html content type.

Note: The response is a pre-formatted text string produced by instructor_analytics_basic.dump_grading_context, which is a debugging utility carried over from the v1 instructor API. It is served as text/html so the MFE can render it directly inside a <pre> block without additional parsing.

get(request, course_id)#

Retrieve the grading configuration for a course as an HTML summary.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.InstructorTaskListView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

List instructor tasks for a course.

Example Requests

GET /api/instructor/v2/courses/{course_key}/instructor_tasks GET /api/instructor/v2/courses/{course_key}/instructor_tasks?problem_location_str=block-v1:… GET /api/instructor/v2/courses/{course_key}/instructor_tasks? problem_location_str=block-v1:…&unique_student_identifier=student@example.com

Response Values

{
“tasks”: [
{

“task_id”: “2519ff31-22d9-4a62-91e2-55495895b355”, “task_type”: “grade_problems”, “task_state”: “PROGRESS”, “status”: “Incomplete”, “created”: “2019-01-15T18:00:15.902470+00:00”, “task_input”: “{}”, “task_output”: null, “duration_sec”: “unknown”, “task_message”: “No status information available”, “requester”: “staff”

}

]

}

Parameters

course_key: Course key for the course. problem_location_str (optional): Filter tasks to a specific problem location. unique_student_identifier (optional): Filter tasks to specific student (must be used with problem_location_str).

Returns

  • 200: OK - Returns list of instructor tasks

  • 400: Bad Request - Invalid parameters

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

get(request, course_id)#

List instructor tasks for a course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.show_tasks'#
class lms.djangoapps.instructor.views.api_v2.IssuedCertificatesView(**kwargs)#

Bases: ListAPIView

View to retrieve issued certificates for a course with allowlist and invalidation details.

Example Requests

GET /api/instructor/v2/courses/{course_id}/certificates/issued GET /api/instructor/v2/courses/{course_id}/certificates/issued?search=username GET /api/instructor/v2/courses/{course_id}/certificates/issued?filter=received GET /api/instructor/v2/courses/{course_id}/certificates/issued?page=2&page_size=50

Response Values

{

“count”: 100, “next”: “http://example.com/api/instructor/v2/courses/…/certificates/issued?page=2”, “previous”: null, “results”: [

{

“username”: “student1”, “email”: “student1@example.com”, “enrollment_track”: “verified”, “certificate_status”: “downloadable”, “special_case”: “Exception”, “exception_granted”: “January 15, 2024”, “exception_notes”: “Medical emergency”, “invalidated_by”: null, “invalidation_date”: null

]

}

Parameters

course_id: Course key for the course search (optional): Filter by username or email filter (optional): Filter certificates by category:

  • “all”: All Learners (default)

  • “received”: Received (downloadable certificates)

  • “not_received”: Not Received (not passing, unavailable)

  • “audit_passing”: Audit - Passing

  • “audit_not_passing”: Audit - Not Passing

  • “error”: Error State

  • “granted_exceptions”: Granted Exceptions (allowlisted)

  • “invalidated”: Invalidated

page (optional): Page number for pagination page_size (optional): Number of results per page

Returns

  • 200: OK - Returns paginated list of issued certificates

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

get_queryset()#

Returns the queryset of issued certificates for the course.

This method returns a Django QuerySet that will be further processed by DRF’s default pagination.

get_serializer_context()#

Provide enrollment, allowlist, and invalidation data in serializer context.

list(request, *args, **kwargs)#

Override list to handle granted_exceptions and invalidated filters specially.

For these filters, we need to show ALL relevant users, even those without GeneratedCertificate records yet.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_issued_certificates'#
serializer_class#

alias of IssuedCertificateSerializer

class lms.djangoapps.instructor.views.api_v2.LearnerView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view for retrieving learner information.

GET Example Response: ```json {

“username”: “john_harvard”, “email”: “john@example.com”, “full_name”: “John Harvard”, “progress_url”: “https://example.com/courses/course-v1:edX+DemoX+Demo_Course/progress/42/”, “is_enrolled”: true

}#

get(request, course_id, email_or_username)#

Retrieve comprehensive learner information including profile, enrollment status, progress URLs, and current grading data.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.ORASummaryView(**kwargs)#

Bases: GenericAPIView

View to get a summary of Open Response Assessments (ORAs) for a given course.

  • Requires token authentication.

  • Only instructors or staff for the course are able to access this view.

get(request, *args, **kwargs)#

Return a summary of ORAs for the specified course.

get_course()#

Retrieve the course object based on the course_id URL parameter.

Validates that the course exists and is not deprecated. Raises NotFound if the course does not exist.

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>]#
permission_name = 'instructor.dashboard'#
serializer_class#

alias of ORASummarySerializer

class lms.djangoapps.instructor.views.api_v2.ORAView(**kwargs)#

Bases: GenericAPIView

View to list all Open Response Assessments (ORAs) for a given course.

  • Requires token authentication.

  • Only instructors or staff for the course are able to access this view.

get(request, *args, **kwargs)#

Return a list of all ORAs for the specified course.

get_course()#

Retrieve the course object based on the course_id URL parameter.

Validates that the course exists and is not deprecated. Raises NotFound if the course does not exist.

permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>]#
permission_name = 'instructor.dashboard'#
serializer_class#

alias of ORASerializer

class lms.djangoapps.instructor.views.api_v2.ProblemView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view for retrieving problem metadata.

GET Example Response: ```json {

“id”: “block-v1:edX+DemoX+Demo_Course+type@problem+block@sample_problem”, “name”: “Sample Problem”, “breadcrumbs”: [

{“display_name”: “Demonstration Course”}, {

“display_name”: “Week 1”, “usage_key”: “block-v1:edX+DemoX+Demo_Course+type@chapter+block@week1”

}, {

“display_name”: “Homework”, “usage_key”: “block-v1:edX+DemoX+Demo_Course+type@sequential+block@hw1”

}, {

“display_name”: “Sample Problem”, “usage_key”: “block-v1:edX+DemoX+Demo_Course+type@problem+block@sample_problem”

}

], “current_score”: {

“score”: 7.0, “total”: 10.0

}, “attempts”: {

“current”: 3, “total”: null

}

}#

get(request, course_id, location)#

Retrieve problem metadata including display name, location in course hierarchy, and usage key.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.ProctoringSettingsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Retrieve or update proctoring configuration for a course.

Example Requests

GET /api/instructor/v2/courses/{course_id}/proctoring_settings PATCH /api/instructor/v2/courses/{course_id}/proctoring_settings

get(request, course_id)#

Retrieve proctoring configuration for the course.

patch(request, course_id)#

Update proctoring settings for the course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
class lms.djangoapps.instructor.views.api_v2.RegenerateCertificatesView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to regenerate certificates for a course.

Use Cases

Regenerate certificates for learners in a course, optionally filtering by certificate status or student set (all learners or allowlisted learners).

Example Requests

POST /api/instructor/v2/courses/{course_id}/certificates/regenerate

Request Body: {

“statuses”: [“downloadable”, “notpassing”], “student_set”: “all”

}

Request Body Parameters

statuses (optional): List of certificate statuses to regenerate student_set (optional): “all” for all learners, “allowlisted” for allowlisted learners only,

“allowlisted_not_generated” for allowlisted learners without certificates

Response Values

{

“task_id”: “abc-123”, “message”: “Certificate regeneration task has been started”

}

Returns

  • 200: OK - Certificate regeneration task started successfully

  • 400: Bad Request - Invalid parameters

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.start_certificate_regeneration'#
post(request, course_id)#

Initiate certificate regeneration for a course.

class lms.djangoapps.instructor.views.api_v2.ReportDownloadsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Use Cases

List all available report downloads for a course.

Example Requests

GET /api/instructor/v2/courses/{course_key}/reports

Response Values

{
“downloads”: [
{

“report_name”: “course-v1_edX_DemoX_Demo_Course_grade_report_2024-01-26-1030.csv”, “report_url”:

“/grades/course-v1:edX+DemoX+Demo_Course/” “course-v1_edX_DemoX_Demo_Course_grade_report_2024-01-26-1030.csv”,

“date_generated”: “2024-01-26T10:30:00Z”, “report_type”: “grade” # Uses ReportType.GRADE.value

}

]

}

Parameters

course_key: Course key for the course.

Returns

  • 200: OK - Returns list of available reports

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks staff access to the course

  • 404: Not Found - Course does not exist

get(request, course_id)#

List all available report downloads for a course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enrollment_report'#
class lms.djangoapps.instructor.views.api_v2.RescoreView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Rescore problem submissions for a learner or all learners.

POST with learner query param: rescores a single learner (asynchronous task). POST without learner: rescores all learners (asynchronous task).

Optionally accepts only_if_higher=true query param to only update if new score is higher.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.override_grades'#
post(request, course_id, problem)#

Rescore problem submissions.

class lms.djangoapps.instructor.views.api_v2.ResetAttemptsView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Reset problem attempts for a learner or all learners.

POST with learner query param: resets a single learner’s attempts (synchronous). POST without learner: queues a background task to reset all learners (asynchronous).

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.give_student_extension'#
post(request, course_id, problem)#

Reset problem attempts for one or all learners.

class lms.djangoapps.instructor.views.api_v2.ScoreOverrideView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Override a learner’s score for a specific problem.

The learner query parameter is required. Accepts a JSON body with score field.

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 = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.override_grades'#
put(request, course_id, problem)#

Override a learner’s score.

class lms.djangoapps.instructor.views.api_v2.SpecialExamAttemptsView(**kwargs)#

Bases: DeveloperErrorViewMixin, ListAPIView

List all attempts for a specific proctored exam.

Example Request

GET /api/instructor/v2/courses/{course_id}/special_exams/{exam_id}/attempts

get_queryset()#

Get the list of items for this view. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

This method should always be used rather than accessing self.queryset directly, as self.queryset gets evaluated only once, and those results are cached for all subsequent requests.

You may want to override this if you need to provide different querysets depending on the incoming request.

(Eg. return a list of items that is specific to the user)

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
serializer_class#

alias of ExamAttemptSerializer

class lms.djangoapps.instructor.views.api_v2.SpecialExamDetailView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Retrieve details for a specific special exam.

Example Request

GET /api/instructor/v2/courses/{course_id}/special_exams/{exam_id}

get(request, course_id, exam_id)#

Retrieve details for a specific special exam.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
class lms.djangoapps.instructor.views.api_v2.SpecialExamResetView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

Reset a student’s proctored exam attempt.

Example Request

POST /api/instructor/v2/courses/{course_id}/special_exams/{exam_id}/reset/{username}

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
post(request, course_id, exam_id, username)#

Reset a student’s proctored exam attempt.

class lms.djangoapps.instructor.views.api_v2.SpecialExamsListView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

List all proctored/timed exams in a course.

Example Requests

GET /api/instructor/v2/courses/{course_id}/special_exams GET /api/instructor/v2/courses/{course_id}/special_exams?exam_type=proctored

Query Parameters

exam_type (optional): Filter by exam type. Values: proctored, timed, practice.

Response Values

A JSON array of special exam objects.

get(request, course_id)#

List all proctored/timed exams in the course.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.view_exam_results'#
class lms.djangoapps.instructor.views.api_v2.TaskStatusView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

API view for checking background task status.

GET Example Response: ```json {

“task_id”: “a1b2c3d4-e5f6-7890-abcd-ef1234567890”, “state”: “completed”, “progress”: {

“current”: 150, “total”: 150

}, “result”: {

“success”: true, “message”: “Reset attempts for 150 learners”

}, “created_at”: “2024-01-15T10:30:00Z”, “updated_at”: “2024-01-15T10:35:23Z”

}#

get(request, course_id, task_id)#

Check the status of a background task.

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.show_tasks'#
class lms.djangoapps.instructor.views.api_v2.ToggleCertificateGenerationView(**kwargs)#

Bases: DeveloperErrorViewMixin, APIView

View to toggle certificate generation for a course.

Example Requests

POST /api/instructor/v2/courses/{course_id}/certificates/toggle_generation

Request Body

{

“enabled”: true

}

Response Values

{

“enabled”: true

}

Returns

  • 200: OK - Certificate generation toggled successfully

  • 400: Bad Request - Invalid request body

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.enable_certificate_generation'#
post(request, course_id)#

Toggle certificate generation for a course.

class lms.djangoapps.instructor.views.api_v2.UnitDueDateExtension(username: str, full_name: str, email: str, unit_title: str, unit_location: str, extended_due_date: str | None)#

Bases: object

Dataclass representing a unit due date extension for a student.

email: str#
extended_due_date: str | None#
classmethod from_block_tuple(row: Tuple, unit)#
classmethod from_course_tuple(row: Tuple, units_dict: dict)#
full_name: str#
unit_location: str#
unit_title: str#
username: str#
class lms.djangoapps.instructor.views.api_v2.UnitExtensionsView(**kwargs)#

Bases: ListAPIView

Retrieve a paginated list of due date extensions for units in a course.

Example Requests

GET /api/instructor/v2/courses/{course_id}/unit_extensions GET /api/instructor/v2/courses/{course_id}/unit_extensions?page=2 GET /api/instructor/v2/courses/{course_id}/unit_extensions?page_size=50 GET /api/instructor/v2/courses/{course_id}/unit_extensions?email_or_username=john GET /api/instructor/v2/courses/{course_id}/unit_extensions?block_id=block-v1:org@problem+block@unit1

Response Values

{

“count”: 150, “next”: “http://example.com/api/instructor/v2/courses/course-v1:org+course+run/unit_extensions?page=2”, “previous”: null, “results”: [

{

“username”: “student1”, “full_name”: “John Doe”, “email”: “john.doe@example.com”, “unit_title”: “Unit 1: Introduction”, “unit_location”: “block-v1:org+course+run+type@problem+block@unit1”, “extended_due_date”: “2023-12-25T23:59:59Z”

]

}

Parameters

course_id: Course key for the course. page (optional): Page number for pagination. page_size (optional): Number of results per page.

Returns

  • 200: OK - Returns paginated list of unit extensions

  • 401: Unauthorized - User is not authenticated

  • 403: Forbidden - User lacks instructor permissions

  • 404: Not Found - Course does not exist

filter_backends = []#
get_queryset()#

Returns the queryset of unit extensions for the specified course.

This method uses the core logic from get_overrides_for_course to retrieve due date extension data and transforms it into a list of normalized objects that can be paginated and serialized.

Supports filtering by: - email_or_username: Filter by username or email address - block_id: Filter by specific unit/subsection location

permission_classes = (<class 'rest_framework.permissions.IsAuthenticated'>, <class 'lms.djangoapps.instructor.permissions.InstructorPermission'>)#
permission_name = 'instructor.dashboard'#
serializer_class#

alias of UnitExtensionSerializer

lms.djangoapps.instructor.views.api_v2.add_or_replace_allowance_for_user(exam_id, username_or_email, key, value)#

Add an allowance for a user on an exam, removing any existing allowance with a different key.

Enforces one allowance per user per exam regardless of allowance type. If the user already has an allowance for this exam with a different key, it is removed before the new one is created.

lms.djangoapps.instructor.views.filters_v2 module#

Filters for the Instructor API v2.

class lms.djangoapps.instructor.views.filters_v2.CourseEnrollmentFilter(data=None, queryset=None, *, request=None, prefix=None)#

Bases: FilterSet

FilterSet for filtering course enrollments.

Supports filtering by: - search: case-insensitive partial match on username, email, first name, or last name - is_beta_tester: filter by beta tester role membership

class Meta#

Bases: object

fields = ['search', 'is_beta_tester']#
model#

alias of CourseEnrollment

base_filters = {'is_beta_tester': <django_filters.rest_framework.filters.BooleanFilter object>, 'search': <django_filters.filters.CharFilter object>}#
declared_filters = {'is_beta_tester': <django_filters.rest_framework.filters.BooleanFilter object>, 'search': <django_filters.filters.CharFilter object>}#
filter_is_beta_tester(queryset, name, value)#

Filter enrollments by beta tester role membership.

Filter enrollments by username, email, first name, or last name.

lms.djangoapps.instructor.views.gradebook_api module#

Grade book view for instructor and pagination work (for grade book) which is currently use by ccx and instructor apps.

lms.djangoapps.instructor.views.gradebook_api.calculate_page_info(offset, total_students)#

Takes care of sanitizing the offset of current page also calculates offsets for next and previous page and information like total number of pages and current page number.

Parameters:

offset – offset for database query

Returns:

tuple consist of page number, query offset for next and previous pages and valid offset

lms.djangoapps.instructor.views.gradebook_api.get_grade_book_page(request, course, course_key)#

Get student records per page along with page information i.e current page, total pages and offset information.

lms.djangoapps.instructor.views.instructor_dashboard module#

Instructor Dashboard Views

class lms.djangoapps.instructor.views.instructor_dashboard.InstructorDashboardTab(tab_dict)#

Bases: CourseTab

Defines the Instructor Dashboard view type that is shown as a course tab.

is_dynamic = True#
classmethod is_enabled(course, user=None)#

Returns true if the specified user has staff access.

priority = 300#
title = 'Instructor'#
type = 'instructor'#
view_name = 'instructor_dashboard'#
lms.djangoapps.instructor.views.instructor_dashboard.get_analytics_dashboard_message(course_key)#

Returns the analytics dashboard message for the given course key.

lms.djangoapps.instructor.views.instructor_dashboard.get_instructor_dashboard_url(course_key: CourseKey) str#

Gets instructor microfrontend URL for the current course locator.

lms.djangoapps.instructor.views.instructor_dashboard.instructor_dashboard_2(request, course_id)#

Display the instructor dashboard for a course.

lms.djangoapps.instructor.views.instructor_dashboard.is_ecommerce_course(course_key)#

Checks if the given course is an e-commerce course or not, by checking its SKU value from CourseMode records for the course

lms.djangoapps.instructor.views.instructor_dashboard.null_applicable_aside_types(block)#

get_aside method for monkey-patching into applicable_aside_types while rendering an HtmlBlock for email text editing. This returns an empty list.

lms.djangoapps.instructor.views.instructor_dashboard.set_course_mode_price(request, course_id)#

set the new course price and add new entry in the CourseModesArchive Table

lms.djangoapps.instructor.views.instructor_dashboard.show_analytics_dashboard_message(course_key)#

Defines whether or not the analytics dashboard URL should be displayed.

Parameters:

course_key (CourseLocator) – The course locator to display the analytics dashboard message on.

lms.djangoapps.instructor.views.instructor_task_helpers module#

A collection of helper utility functions for working with instructor tasks.

lms.djangoapps.instructor.views.instructor_task_helpers.email_error_information()#

Returns email information marked as None, used in event email cannot be loaded

lms.djangoapps.instructor.views.instructor_task_helpers.extract_email_features(email_task)#

From the given task, extract email content information

Expects that the given task has the following attributes: * task_input (dict containing email_id) * task_output (optional, dict containing total emails sent) * requester, the user who executed the task

With this information, gets the corresponding email object from the bulk emails table, and loads up a dict containing the following: * created, the time the email was sent displayed in default time display * sent_to, the group the email was delivered to * email, dict containing the subject, id, and html_message of an email * number_sent, int number of emails sent * requester, the user who sent the emails If task_input cannot be loaded, then the email cannot be loaded and None is returned for these fields.

lms.djangoapps.instructor.views.instructor_task_helpers.extract_task_features(task)#

Convert task to dict for json rendering. Expects tasks have the following features: * task_type (str, type of task) * task_input (dict, input(s) to the task) * task_id (str, celery id of the task) * requester (str, username who submitted the task) * task_state (str, state of task eg PROGRESS, COMPLETED) * created (datetime, when the task was completed) * task_output (optional)

lms.djangoapps.instructor.views.serializer module#

Instructor apis serializers.

class lms.djangoapps.instructor.views.serializer.AccessSerializer(*args, **kwargs)#

Bases: UniqueStudentIdentifierSerializer

Serializer for managing user access changes. This serializer validates and processes the data required to modify user access within a system.

class lms.djangoapps.instructor.views.serializer.BlockDueDateSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for handling block due date updates for a specific student. Fields:

url (str): The URL related to the block that needs the due date update. due_datetime (str): The new due date and time for the block. student (str): The email or username of the student whose access is being modified. reason (str): Reason why updating this.

validate_student(value)#

Validate that the student corresponds to an existing user.

class lms.djangoapps.instructor.views.serializer.CertificateSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for multiple operations related with certificates. resetting a students attempts counter or starts a task to reset all students attempts counters Also Add/Remove students to/from the certificate allowlist. Also For resetting a students attempts counter or starts a task to reset all students attempts counters.

validate_user(value)#

Validate that the user corresponds to an existing user.

class lms.djangoapps.instructor.views.serializer.CertificateStatusesSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating and serializing certificate status inputs.

This serializer is used to ensure that the provided certificate statuses conform to the predefined set of valid statuses defined in the CertificateStatuses enumeration.

class lms.djangoapps.instructor.views.serializer.EnrollmentListSerializer(*args, **kwargs)#

Bases: PaginatedSearchSerializer

Serializer for enrollment list request parameters.

class lms.djangoapps.instructor.views.serializer.ForumRoleNameSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for forum rolename.

get_users(obj)#

Retrieve a list of users associated with the specified role and course.

Parameters:

obj (dict) – A dictionary containing the ‘rolename’ for which to retrieve users. This dictionary is the data passed to the serializer.

Returns:

A list of dictionaries, each representing a user associated with the specified role.

Each user dictionary contains ‘username’, ‘email’, ‘first_name’, ‘last_name’, and ‘group_name’. If no users are found, an empty list is returned.

Return type:

list

validate_rolename(value)#

Check that the rolename is valid.

class lms.djangoapps.instructor.views.serializer.ListInstructorTaskInputSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for handling the input data for the problem response report generation API.

unique_student_identifier#

The email or username of the student. This field is optional, but if provided, the problem_location_str must also be provided.

Type:

str

problem_location_str#

The string representing the location of the problem within the course. This field is optional, unless unique_student_identifier is provided.

Type:

str

validate(data)#

Validate the data to ensure that if unique_student_identifier is provided, problem_location_str must also be provided.

class lms.djangoapps.instructor.views.serializer.ModifyAccessSerializer(*args, **kwargs)#

Bases: Serializer

serializers for enroll or un-enroll users in beta testing program.

validate_auto_enroll(value)#

handle string values like ‘true’ or ‘false’.

validate_email_students(value)#

handle string values like ‘true’ or ‘false’.

validate_identifiers(value)#

Validate the ‘identifiers’ field which is now a list of strings.

class lms.djangoapps.instructor.views.serializer.OverrideProblemScoreSerializer(*args, **kwargs)#

Bases: UniqueStudentIdentifierSerializer

Serializer for overriding a student’s score for a specific problem.

class lms.djangoapps.instructor.views.serializer.PaginatedSearchSerializer(*args, **kwargs)#

Bases: Serializer

Base serializer for paginated list requests with optional search.

class lms.djangoapps.instructor.views.serializer.ProblemResetSerializer(*args, **kwargs)#

Bases: UniqueStudentIdentifierSerializer

serializer for resetting problem.

class lms.djangoapps.instructor.views.serializer.RescoreEntranceExamSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for entrance exam rescoring

class lms.djangoapps.instructor.views.serializer.ResetEntranceExamAttemptsSerializer(*args, **kwargs)#

Bases: UniqueStudentIdentifierSerializer

Serializer for resetting entrance exam attempts or deleting entrance exam state. Inherits user validation from UniqueStudentIdentifierSerializer.

validate(attrs)#
validate_unique_student_identifier(value)#

Validate that the unique_student_identifier corresponds to an existing user, if a value is provided.

class lms.djangoapps.instructor.views.serializer.RoleNameSerializer(*args, **kwargs)#

Bases: PaginatedSearchSerializer

Serializer for role member list requests.

validate_rolename(value)#

Check that the rolename is valid.

class lms.djangoapps.instructor.views.serializer.SendEmailSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for sending an email with optional scheduling.

Fields:

send_to (str): The email address of the recipient. This field is required. subject (str): The subject line of the email. This field is required. message (str): The body of the email. This field is required. schedule (str, optional): An optional field to specify when the email should be sent. If provided, this should be a string that can be parsed into a datetime format or some other scheduling logic.

class lms.djangoapps.instructor.views.serializer.ShowStudentExtensionSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating and processing the student identifier.

validate_student(value)#

Validate that the student corresponds to an existing user.

class lms.djangoapps.instructor.views.serializer.ShowUnitExtensionsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for showing all students who have due date extensions for a specific unit (block).

Fields:

url (str): The URL (block ID) of the unit for which student extensions should be retrieved.

class lms.djangoapps.instructor.views.serializer.StudentAttemptsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for resetting a students attempts counter or starts a task to reset all students attempts counters.

validate_all_students(value)#

converts the all_student params value to bool.

validate_delete_module(value)#

converts the all_student params value.

validate_unique_student_identifier(value)#

Validate that the student corresponds to an existing user.

verify_bool(value)#

Returns the value of the boolean parameter with the given name in the POST request. Handles translation from string values to boolean values.

class lms.djangoapps.instructor.views.serializer.StudentsUpdateEnrollmentSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for student enroll/unenroll actions.

class lms.djangoapps.instructor.views.serializer.UniqueStudentIdentifierSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for identifying unique_student.

validate_unique_student_identifier(value)#

Validate that the unique_student_identifier corresponds to an existing user.

class lms.djangoapps.instructor.views.serializer.UpdateForumRoleMembershipSerializer(*args, **kwargs)#

Bases: AccessSerializer

Serializer for managing user’s forum role.

This serializer extends the AccessSerializer to allow for different action choices specific to this API. It validates and processes the data required to modify user access within a system.

unique_student_identifier#

The email or username of the user whose access is being modified.

Type:

str

rolename#

The role name to assign to the user.

Type:

str

action#

The specific action to perform on the user’s access, with options ‘activate’ or ‘deactivate’.

Type:

str

class lms.djangoapps.instructor.views.serializer.UserSerializer(*args, **kwargs)#

Bases: ModelSerializer

class Meta#

Bases: object

fields = ['username', 'email', 'first_name', 'last_name']#
model#

alias of User

lms.djangoapps.instructor.views.serializer.extract_user_info(user, course_discussion_settings)#

utility method to convert user into dict for JSON rendering.

lms.djangoapps.instructor.views.serializers_v2 module#

Serializers for Instructor API v2.

These serializers handle data validation and business logic for instructor dashboard endpoints. Following REST best practices, serializers encapsulate most of the data processing logic.

class lms.djangoapps.instructor.views.serializers_v2.AllowanceUserSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for user info within an allowance (uses ‘id’ directly).

class lms.djangoapps.instructor.views.serializers_v2.AsyncOperationResultSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for asynchronous grading operation results.

class lms.djangoapps.instructor.views.serializers_v2.BetaTesterModifyRequestSerializerV2(*args, **kwargs)#

Bases: Serializer

Validates request body for adding/removing one or more beta testers.

class lms.djangoapps.instructor.views.serializers_v2.BetaTesterModifyResponseSerializerV2(*args, **kwargs)#

Bases: Serializer

Documents the response shape for the bulk beta tester add/remove endpoint (mirrors v1).

class lms.djangoapps.instructor.views.serializers_v2.BetaTesterModifyResultSerializerV2(*args, **kwargs)#

Bases: Serializer

Documents the per-identifier result shape for beta tester modifications (mirrors v1).

class lms.djangoapps.instructor.views.serializers_v2.BlockDueDateSerializerV2(*args, **kwargs)#

Bases: Serializer

Serializer for handling block due date updates for a specific student. Fields:

block_id (str): The ID related to the block that needs the due date update. due_datetime (str): The new due date and time for the block. email_or_username (str): The email or username of the student whose access is being modified. reason (str, optional): Reason why updating this.

validate_due_datetime(value)#

Validate and parse the due_datetime string into a datetime object.

validate_email_or_username(value)#

Validate that the email_or_username corresponds to an existing user.

class lms.djangoapps.instructor.views.serializers_v2.BulkAllowanceRequestSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating bulk allowance requests across multiple exams.

class lms.djangoapps.instructor.views.serializers_v2.CertificateExceptionSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for granting certificate exceptions (bulk).

class lms.djangoapps.instructor.views.serializers_v2.CertificateGenerationHistorySerializer(*args, **kwargs)#

Bases: Serializer

Serializer for certificate generation history. Accepts CertificateGenerationHistory model instances.

get_details(obj)#

Get details about what was generated/regenerated.

get_task_name(obj)#

Determine task name based on whether it’s a regeneration.

class lms.djangoapps.instructor.views.serializers_v2.CertificateInvalidationSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for invalidating certificates (bulk).

class lms.djangoapps.instructor.views.serializers_v2.CourseEnrollmentSerializerV2(*args, **kwargs)#

Bases: Serializer

Serializer for course enrollment data.

Serializes CourseEnrollment instances with derived fields for the user’s full name and beta tester status.

get_full_name(enrollment)#

Get the user’s full name from their profile.

get_is_beta_tester(enrollment)#

Check if the user is a beta tester for this course.

class lms.djangoapps.instructor.views.serializers_v2.CourseInformationSerializerV2(*args, **kwargs)#

Bases: Serializer

Serializer for comprehensive course information.

This serializer handles the business logic for gathering all course metadata, enrollment statistics, permissions, and dashboard configuration.

get_admin_console_url(data)#

Get admin console URL (requires instructor access and MFE configuration, null if not accessible).

get_analytics_dashboard_message(data)#

Get analytics dashboard availability message.

get_certificates_enabled(data)#

Check if certificate management features are enabled.

get_course_errors(data)#

Get course validation errors from modulestore.

get_course_id(data)#

Get course ID as string.

get_course_number(data)#

Get course number.

get_course_run(data)#

Get course run identifier

get_disable_buttons(data)#

Check if buttons should be disabled for large courses.

get_display_name(data)#

Get course display name.

get_end(data)#

Get course end date.

get_enrollment_counts(data)#

Get enrollment counts for all configured modes and any mode with active enrollments.

get_enrollment_end(data)#

Get enrollment end date.

get_enrollment_start(data)#

Get enrollment start date.

get_grade_cutoffs(data)#

Format grade cutoffs as a human-readable string.

Parameters:

data – Dictionary containing course object

Returns:

Formatted grade cutoffs (e.g., “A is 0.9, B is 0.8, C is 0.7”)

Return type:

str

get_gradebook_url(data)#

Get MFE gradebook URL for the course.

get_has_ended(data)#

Check if course has ended.

get_has_started(data)#

Check if course has started.

get_learner_count(data)#

Get enrollment count excluding staff and admins.

get_num_sections(data)#

Get number of sections in the course.

get_org(data)#

Get organization identifier.

get_pacing(data)#

Get course pacing type (self or instructor).

get_permissions(data)#

Get user permissions for the course.

get_staff_count(data)#

Get enrollment count for staff and admins only.

get_start(data)#

Get course start date.

get_studio_grading_url(data)#

Get Studio MFE grading settings URL for the course.

get_studio_url(data)#

Get Studio URL for the course.

get_tabs(data)#

Get serialized course tabs.

get_total_enrollment(data)#

Get total enrollment count.

get_username(data)#

Get the username of the current authenticated user.

class lms.djangoapps.instructor.views.serializers_v2.CourseTeamModifySerializer(*args, **kwargs)#

Bases: Serializer

Input serializer for granting or revoking a course team role.

class lms.djangoapps.instructor.views.serializers_v2.CourseTeamRevokeSerializer(*args, **kwargs)#

Bases: Serializer

Input serializer for revoking course team roles.

class lms.djangoapps.instructor.views.serializers_v2.EnrollmentModifyRequestSerializerV2(*args, **kwargs)#

Bases: Serializer

Validates request body for enrolling/unenrolling one or more learners.

class lms.djangoapps.instructor.views.serializers_v2.EnrollmentModifyResponseSerializerV2(*args, **kwargs)#

Bases: Serializer

Documents the response shape for the bulk enroll/unenroll endpoint (mirrors v1).

class lms.djangoapps.instructor.views.serializers_v2.EnrollmentModifyResultSerializerV2(*args, **kwargs)#

Bases: Serializer

Documents the per-identifier result shape for enrollment modifications (mirrors v1).

class lms.djangoapps.instructor.views.serializers_v2.EnrollmentStateSerializerV2(*args, **kwargs)#

Bases: Serializer

Documents the before/after enrollment state shape (mirrors EmailEnrollmentState.to_dict).

class lms.djangoapps.instructor.views.serializers_v2.ExamAllowanceRequestSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating exam allowance grant requests.

class lms.djangoapps.instructor.views.serializers_v2.ExamAllowanceSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for exam allowance data from edx_proctoring.

class lms.djangoapps.instructor.views.serializers_v2.ExamAttemptSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for proctored exam attempt data.

get_exam_type(obj)#

Derive exam type from proctored_exam flags.

class lms.djangoapps.instructor.views.serializers_v2.ExamAttemptUserSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for user info within an exam attempt.

class lms.djangoapps.instructor.views.serializers_v2.InstructorTaskListSerializer(*args, **kwargs)#

Bases: Serializer

class lms.djangoapps.instructor.views.serializers_v2.InstructorTaskSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for instructor task details.

class lms.djangoapps.instructor.views.serializers_v2.IssuedCertificateSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for issued certificates with allowlist and invalidation information. Accepts GeneratedCertificate instances and pulls related data from context.

get_enrollment_track(obj)#

Get enrollment track from context.

get_exception_granted(obj)#

Get exception granted date from allowlist data in context.

get_exception_notes(obj)#

Get exception notes from allowlist data in context.

get_invalidated_by(obj)#

Get invalidated by email from invalidation data in context.

get_invalidation_date(obj)#

Get invalidation date from invalidation data in context.

get_invalidation_note(obj)#

Get invalidation notes from invalidation data in context.

get_special_case(obj)#

Determine special case from allowlist and invalidation data in context.

class lms.djangoapps.instructor.views.serializers_v2.LearnerInputSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating learner identifier (username or email).

validate_email_or_username(value)#

Validate and resolve username/email to user object.

class lms.djangoapps.instructor.views.serializers_v2.LearnerSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for learner information.

Provides comprehensive learner data including profile, enrollment status, and current progress in a course.

class lms.djangoapps.instructor.views.serializers_v2.ORASerializer(*args, **kwargs)#

Bases: Serializer

Serializer for Open Response Assessments (ORAs) in a course.

class lms.djangoapps.instructor.views.serializers_v2.ORASummarySerializer(*args, **kwargs)#

Bases: Serializer

Aggregated ORA statistics for a course

class lms.djangoapps.instructor.views.serializers_v2.ProblemSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for problem metadata and location.

Provides problem information including display name and course hierarchy. Optionally includes learner-specific score and attempt data when a learner query parameter is provided.

class lms.djangoapps.instructor.views.serializers_v2.ProctoringSettingsSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for course proctoring configuration.

class lms.djangoapps.instructor.views.serializers_v2.ProctoringSettingsUpdateSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for validating proctoring settings update requests.

class lms.djangoapps.instructor.views.serializers_v2.RegenerateCertificatesSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for regenerating certificates request.

class lms.djangoapps.instructor.views.serializers_v2.RemoveCertificateExceptionSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for removing a certificate exception.

validate_username(value)#

Validate and resolve username/email to user object.

class lms.djangoapps.instructor.views.serializers_v2.RemoveCertificateInvalidationSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for re-validating a certificate (removing invalidation).

validate_username(value)#

Validate and resolve username/email to user object.

class lms.djangoapps.instructor.views.serializers_v2.ScoreOverrideRequestSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for score override request body.

to_internal_value(data)#

Dict of native values <- Dict of primitive datatypes.

class lms.djangoapps.instructor.views.serializers_v2.SpecialExamSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for proctored/timed exam data from edx_proctoring.

get_exam_type(obj)#

Derive exam type from proctoring flags.

class lms.djangoapps.instructor.views.serializers_v2.SyncOperationResultSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for synchronous grading operation results.

class lms.djangoapps.instructor.views.serializers_v2.TaskStatusSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for background task status.

Provides status and progress information for asynchronous operations.

class lms.djangoapps.instructor.views.serializers_v2.ToggleCertificateGenerationSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for toggling certificate generation request.

class lms.djangoapps.instructor.views.serializers_v2.UnitExtensionSerializer(*args, **kwargs)#

Bases: Serializer

Serializer for unit extension data.

This serializer formats the data returned by get_overrides_for_course for the paginated list API endpoint.

lms.djangoapps.instructor.views.serializers_v2.derive_exam_type(exam_dict)#

Derive exam type string from proctoring flags.

Parameters:

exam_dict – dict with ‘is_proctored’ and ‘is_practice_exam’ keys.

Returns:

‘practice’, ‘proctored’, or ‘timed’.

lms.djangoapps.instructor.views.tools module#

Tools for the instructor dashboard

exception lms.djangoapps.instructor.views.tools.DashboardError#

Bases: Exception

Errors arising from use of the instructor dashboard.

response()#

Generate an instance of HttpResponseBadRequest for this error.

lms.djangoapps.instructor.views.tools.dump_block_extensions(course, unit)#

Dumps data about students with due date extensions for a particular block, specified by ‘url’, in a particular course.

lms.djangoapps.instructor.views.tools.dump_student_extensions(course, student)#

Dumps data about the due date extensions granted for a particular student in a particular course.

lms.djangoapps.instructor.views.tools.find_unit(course, url)#

Finds the unit/block with the given url in the course tree and returns the unit. Raises DashboardError if no unit is found.

lms.djangoapps.instructor.views.tools.get_student_from_identifier(unique_student_identifier)#

Gets a student object using either an email address or username.

Returns the student object associated with unique_student_identifier

Raises User.DoesNotExist if no user object can be found, the user was retired, or the user is in the process of being retired.

DEPRECATED: use student.models.get_user_by_username_or_email instead.

lms.djangoapps.instructor.views.tools.get_units_with_due_date(course)#

Returns all top level units which have due dates. Does not return descendents of those nodes.

lms.djangoapps.instructor.views.tools.handle_dashboard_error(view)#

Decorator which adds seamless DashboardError handling to a view. If a DashboardError is raised during view processing, an HttpResponseBadRequest is sent back to the client with JSON data about the error.

lms.djangoapps.instructor.views.tools.keep_field_private(query_features, field_name)#

Utility to remove a field from a list of field names requested of a report Keeps the specified field_name private (excluded from report)

lms.djangoapps.instructor.views.tools.parse_datetime(datestr)#

Convert user input date string into an instance of datetime.datetime in UTC.

lms.djangoapps.instructor.views.tools.require_student_from_identifier(unique_student_identifier)#

Same as get_student_from_identifier() but will raise a DashboardError if the student does not exist.

lms.djangoapps.instructor.views.tools.set_due_date_extension(course, unit, student, due_date, actor=None, reason='')#

Sets a due date extension.

Raises:
  • DashboardError if the unit or extended, due date is invalid or user is

  • not enrolled in the course.

lms.djangoapps.instructor.views.tools.strip_if_string(value)#
lms.djangoapps.instructor.views.tools.title_or_url(node)#

Returns the display_name attribute of the passed in node of the course tree, if it has one. Otherwise returns the node’s url.

Module contents#