CourseService#

class CourseService[source]#

Methods

get_all

Return all Course objects the current user is a member of.

create

Create a new course.

get_course_roles

Get a list of all course roles in a given course.

create_role

Add a new CourseRole to the given Course.

bulk_enroll

Bulk enroll users into this course.

create_snippet

Add or modify a CourseSnippet by key.

get_group_sets

Get the all the group sets of a given course.

create_group_set

Create or update a GroupSet in the given course id.

get_assignments

Get all assignments of the given course.

create_assignment

Create a new course for the given assignment.

get_all_enroll_links

Get the registration links for the given course.

put_enroll_link

Create or edit an enroll link.

get_sections

Get all sections of this course.

create_section

Create a new course section.

put_price

Update the price of the given course.

delete_price

Update the price of the given course.

delete_snippet

Delete the CourseSnippet with the given id.

patch_snippet

Modify the CourseSnippet with the given id.

get_registration_link

Get a registration link.

delete_enroll_link

Delete the given registration link.

delete_role

Remove a CourseRole from the given Course.

patch_role

Update the Permission of a given CourseRole in the given Course.

delete_user

Delete a user from a course.

export_gradebook

Export a gradebook as CSV for this course.

get_all_users

Get all users and their role in a course.

change_user_role

Set the CourseRole of a user in the given course.

get

Get a course by id.

patch

Update the given course with new values.

get_snippets

Get all snippets of the given course.

get_statistics

Get user statistics of a specific course.

get_permissions

Get all the permissions of the currently logged in user in this course.

get_submissions_by_user

Get all submissions by the given user in this course.

import_into

Copy a course into another course.

join_as_logged_in_user

Join a course as the currently logged in user using a registration link.

register_user_with_link

Register as a new user, and directly enroll in a course.

email_users

Sent the authors in this course an email.

get_all(*, extended=True, offset=Nothing, limit=Nothing, lti_course_id=Nothing, extra_parameters=None)[source]#

Return all Course objects the current user is a member of.

Parameters:
Returns:

A response containing the JSON serialized courses

Return type:

Sequence[ExtendedCourse] | Sequence[Course]

create(json_body, *, extra_parameters=None)[source]#

Create a new course.

Parameters:
Returns:

A response containing the JSON serialization of the new course

Return type:

ExtendedCourse

get_course_roles(*, course_id, with_roles=False, extra_parameters=None)[source]#

Get a list of all course roles in a given course.

Parameters:
Returns:

An array of all course roles for the given course.

Return type:

Sequence[CourseRoleAsJSONWithPerms] | Sequence[CourseRole]

create_role(json_body, *, course_id, extra_parameters=None)[source]#

Add a new CourseRole to the given Course.

Parameters:
Returns:

An empty response with return code 204.

Return type:

None

bulk_enroll(json_body, *, course_id, extra_parameters=None)[source]#

Bulk enroll users into this course.

All given users are directly enrolled into the course, and they will receive an email confirming that they have been enrolled.

Users that do not exist yet are created, but no password is set yet so they cannot log in. Their course enrollment email will include a link to a page where they can set their password.

Parameters:
Returns:

A dictionary containing the job sending out the mails, a list of newly created users, and a list of users that could not be created because of SSO incompatibility.

Return type:

CourseBulkEnrollResult

create_snippet(json_body, *, course_id, extra_parameters=None)[source]#

Add or modify a CourseSnippet by key.

Parameters:
Returns:

A response containing the JSON serialized snippet and return code 201.

Return type:

CourseSnippet

get_group_sets(*, course_id, extra_parameters=None)[source]#

Get the all the group sets of a given course.

Parameters:
Returns:

A list of group sets.

Return type:

Sequence[GroupSet]

create_group_set(json_body, *, course_id, extra_parameters=None)[source]#

Create or update a GroupSet in the given course id.

Parameters:
Returns:

The created or updated group.

Return type:

GroupSet

get_assignments(*, course_id, has_rubric=Nothing, has_auto_test=Nothing, has_handin_requirements=Nothing, extra_parameters=None)[source]#

Get all assignments of the given course.

The returned assignments are sorted by deadline.

Parameters:
Returns:

A response containing the assignments of the given course sorted by deadline of the assignment

Return type:

Sequence[Assignment]

create_assignment(json_body, *, course_id, extra_parameters=None)[source]#

Create a new course for the given assignment.

Parameters:
Returns:

The newly created assignment.

Return type:

Assignment

Get the registration links for the given course.

Parameters:
Returns:

An array of registration links.

Return type:

Sequence[CourseRegistrationLink]

Create or edit an enroll link.

Parameters:
Returns:

The created or edited link.

Return type:

CourseRegistrationLink

get_sections(*, course_id, extra_parameters=None)[source]#

Get all sections of this course.

Parameters:
Returns:

A list of all sections connected to this course.

Return type:

Sequence[CourseSection]

create_section(json_body, *, course_id, extra_parameters=None)[source]#

Create a new course section.

Parameters:
Returns:

The new section.

Return type:

CourseSection

put_price(json_body, *, course_id, extra_parameters=None)[source]#

Update the price of the given course.

Parameters:
Returns:

The created or updated price.

Return type:

CoursePrice

delete_price(*, course_id, extra_parameters=None)[source]#

Update the price of the given course.

Parameters:
Returns:

The created or updated price.

Return type:

None

delete_snippet(*, course_id, snippet_id, extra_parameters=None)[source]#

Delete the CourseSnippet with the given id.

Parameters:
Returns:

An empty response with return code 204

Return type:

None

patch_snippet(json_body, *, course_id, snippet_id, extra_parameters=None)[source]#

Modify the CourseSnippet with the given id.

Parameters:
Returns:

An empty response with return code 204.

Return type:

None

Get a registration link.

This route can be used without logging in, i.e. you don’t have to be enrolled in the course to use this route. This route will not work for expired registration links.

Parameters:
  • course_id (int) – The id of the course to which the registration link is connected.

  • link_id (str) – The id of the registration link.

  • extra_parameters (Optional[Mapping[str, Union[str, bool, int, float]]]) – The extra query parameters you might want to add. By default no extra query parameters are added.

Returns:

The specified registration link.

Return type:

ExtendedCourseRegistrationLink

Delete the given registration link.

Parameters:
Returns:

Nothing.

Return type:

None

delete_role(*, course_id, role_id, extra_parameters=None)[source]#

Remove a CourseRole from the given Course.

Parameters:
Returns:

An empty response with return code 204

Return type:

None

patch_role(json_body, *, course_id, role_id, extra_parameters=None)[source]#

Update the Permission of a given CourseRole in the given Course.

Parameters:
Returns:

An empty response with return code 204.

Return type:

None

delete_user(*, course_id, user_id, extra_parameters=None)[source]#

Delete a user from a course.

This does not delete the user’s submissions within the course.

Parameters:
Returns:

Nothing.

Return type:

None

export_gradebook(*, course_id, format='csv', extra_parameters=None)[source]#

Export a gradebook as CSV for this course.

Parameters:
Returns:

The task that creates the export.

Return type:

Job

get_all_users(*, course_id, q=Nothing, extra_parameters=None)[source]#

Get all users and their role in a course.

Parameters:
Returns:

All users in this course and their role. If you provided the q parameter only the user is returned, not their role.

Return type:

Sequence[User] | Sequence[UserCourse]

change_user_role(json_body, *, course_id, extra_parameters=None)[source]#

Set the CourseRole of a user in the given course.

Parameters:
Returns:

The response will contain the JSON serialized user and course role.

Return type:

UserCourse

get(*, course_id, extra_parameters=None)[source]#

Get a course by id.

Parameters:
Returns:

A response containing the JSON serialized course

Return type:

ExtendedCourse

patch(json_body, *, course_id, extra_parameters=None)[source]#

Update the given course with new values.

Parameters:
Returns:

The updated course, in extended format.

Return type:

ExtendedCourse

get_snippets(*, course_id, extra_parameters=None)[source]#

Get all snippets of the given course.

Parameters:
Returns:

An array containing all snippets for the given course.

Return type:

Sequence[CourseSnippet]

get_statistics(*, course_id, extra_parameters=None)[source]#

Get user statistics of a specific course.

Parameters:
Returns:

A response containing the course management statistics

Return type:

CourseStatisticsAsJSON

get_permissions(*, course_id, extra_parameters=None)[source]#

Get all the permissions of the currently logged in user in this course.

This will return the permission as if you have already paid, even if this is not the case. We will also not check any restrictions of the current session.

Parameters:
Returns:

A mapping between the permission name and a boolean indicating if the currently logged in user has this permission.

Return type:

CoursePermMap

get_submissions_by_user(*, course_id, user_id, latest_only=False, extra_parameters=None)[source]#

Get all submissions by the given user in this course.

Parameters:
  • course_id (int) – The id of the course from which you want to get the submissions.

  • user_id (int) – The id of the user of which you want to get the submissions.

  • latest_only (bool) – Only get the latest submission of a user. Please use this option if at all possible, as students have a tendency to submit many attempts and that can make this route quite slow.

  • extra_parameters (Optional[Mapping[str, Union[str, bool, int, float]]]) – The extra query parameters you might want to add. By default no extra query parameters are added.

  • self (CourseService[AuthenticatedClient]) –

Returns:

A mapping between assignment id and the submissions done in that assignment by the given user. If the latest_only query parameter was used the value will still be an array of submissions, but the length will always be one. If the user didn’t submit for an assignment the value might be empty or the id of the assignment will be missing from the returned object.

Return type:

Mapping[str, Sequence[ExtendedWork]]

import_into(json_body, *, into_course_id, extra_parameters=None)[source]#

Copy a course into another course.

Parameters:
Returns:

The updated course, so the course of which the id was passed in the url.

Return type:

ExtendedCourse

join_as_logged_in_user(*, course_id, link_id, extra_parameters=None)[source]#

Join a course as the currently logged in user using a registration link.

Parameters:
Returns:

Nothing.

Return type:

None

Register as a new user, and directly enroll in a course.

Parameters:
Returns:

The access token that the created user can use to log in.

Return type:

UserLoginResponse

email_users(json_body, *, course_id, extra_parameters=None)[source]#

Sent the authors in this course an email.

Parameters:
Returns:

A task result that will send these emails.

Return type:

Job