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.InstructorTaskSerializer(*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.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’]

Returns JSON of the form {

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

{

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

}

]

}

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: 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 - 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.list_financial_report_downloads(*args, **kwargs)#
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_post_params(*args, **kwargs)#

Checks for required parameters or renders a 400 error. (decorator with arguments)

args is a *list of required POST parameter names. kwargs is a **dict of required POST parameter names

to string explanations of the parameter

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.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.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.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.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: Serializer

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

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