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

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.add_users_to_cohorts(*args, **kwargs)#
lms.djangoapps.instructor.views.api.bulk_beta_modify_access(*args, **kwargs)#
lms.djangoapps.instructor.views.api.calculate_grades_csv(*args, **kwargs)#
lms.djangoapps.instructor.views.api.certificate_exception_view(*args, **kwargs)#
lms.djangoapps.instructor.views.api.certificate_invalidation_view(*args, **kwargs)#
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.export_ora2_data(*args, **kwargs)#
lms.djangoapps.instructor.views.api.export_ora2_submission_files(*args, **kwargs)#
lms.djangoapps.instructor.views.api.export_ora2_summary(*args, **kwargs)#
lms.djangoapps.instructor.views.api.generate_bulk_certificate_exceptions(*args, **kwargs)#
lms.djangoapps.instructor.views.api.generate_certificate_exceptions(*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_course_survey_results(*args, **kwargs)#
lms.djangoapps.instructor.views.api.get_issued_certificates(*args, **kwargs)#
lms.djangoapps.instructor.views.api.get_problem_responses(*args, **kwargs)#
lms.djangoapps.instructor.views.api.get_proctored_exam_results(*args, **kwargs)#
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, certificate_invalidation_data, 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

  • certificate_invalidation_data – dict object containing data for CertificateInvalidation.

  • 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_background_email_tasks(*args, **kwargs)#
lms.djangoapps.instructor.views.api.list_financial_report_downloads(*args, **kwargs)#
lms.djangoapps.instructor.views.api.list_forum_members(*args, **kwargs)#
lms.djangoapps.instructor.views.api.override_problem_score(*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.problem_grade_report(*args, **kwargs)#
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.rescore_entrance_exam(*args, **kwargs)#
lms.djangoapps.instructor.views.api.rescore_problem(*args, **kwargs)#
lms.djangoapps.instructor.views.api.reset_student_attempts_for_entrance_exam(*args, **kwargs)#
lms.djangoapps.instructor.views.api.start_certificate_regeneration(*args, **kwargs)#
lms.djangoapps.instructor.views.api.students_update_enrollment(*args, **kwargs)#
lms.djangoapps.instructor.views.api.update_forum_role_membership(*args, **kwargs)#

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

Bases: ModelSerializer

class Meta#

Bases: object

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

alias of User

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#