CourseService#
- class CourseService[source]#
Methods
Return all Course objects the current user is a member of.
Create a new course.
Get a list of all course roles in a given course.
Add a new CourseRole to the given Course.
Bulk enroll users into this course.
Add or modify a CourseSnippet by key.
Get the all the group sets of a given course.
Create or update a GroupSet in the given course id.
Get all assignments of the given course.
Create a new course for the given assignment.
Get the registration links for the given course.
Create or edit an enroll link.
Get all sections of this course.
Create a new course section.
Update the price of the given course.
Update the price of the given course.
Delete the CourseSnippet with the given id.
Modify the CourseSnippet with the given id.
Get a registration link.
Delete the given registration link.
Remove a CourseRole from the given Course.
Update the Permission of a given CourseRole in the given Course.
Delete a user from a course.
Export a gradebook as CSV for this course.
Get all users and their role in a course.
Set the CourseRole of a user in the given course.
Get a course by id.
Update the given course with new values.
Get all snippets of the given course.
Get user statistics of a specific course.
Get all the permissions of the currently logged in user in this course.
Get all submissions by the given user in this course.
Copy a course into another course.
Join a course as the currently logged in user using a registration link.
Register as a new user, and directly enroll in a course.
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:
extended (
bool
) – Whether to return extended course models or not.offset (
Union
[Just
[int
],_Nothing
[int
]]) – The index of the first course to be returned.limit (
Union
[Just
[int
],_Nothing
[int
]]) – The maximum amount of courses to return.lti_course_id (
Union
[Just
[str
],_Nothing
[str
]]) – The id of the course according to the lti platform.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 response containing the JSON serialized courses
- Return type:
- create(json_body, *, extra_parameters=None)[source]#
Create a new course.
- Parameters:
json_body (
Union
[dict
,list
,CreateCourseData
]) – The body of the request. SeeCreateCourseData
for information about the possible fields. You can provide this data as aCreateCourseData
or as a dictionary.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 response containing the JSON serialization of the new course
- Return type:
- get_course_roles(*, course_id, with_roles=False, extra_parameters=None)[source]#
Get a list of all course roles in a given course.
- Parameters:
course_id (
int
) – The id of the course to get the roles for.with_roles (
bool
) – Should a permission map be added to each role.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:
An array of all course roles for the given course.
- Return type:
- create_role(json_body, *, course_id, extra_parameters=None)[source]#
Add a new CourseRole to the given Course.
- Parameters:
json_body (
Union
[dict
,list
,CreateRoleCourseData
]) – The body of the request. SeeCreateRoleCourseData
for information about the possible fields. You can provide this data as aCreateRoleCourseData
or as a dictionary.course_id (
int
) – The id of the courseextra_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:
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:
json_body (
Union
[dict
,list
,BulkEnrollCourseData
]) – The body of the request. SeeBulkEnrollCourseData
for information about the possible fields. You can provide this data as aBulkEnrollCourseData
or as a dictionary.course_id (
int
) – The id of the course in which users should be enrolled.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 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:
- create_snippet(json_body, *, course_id, extra_parameters=None)[source]#
Add or modify a CourseSnippet by key.
- Parameters:
json_body (
Union
[dict
,list
,CreateSnippetCourseData
]) – The body of the request. SeeCreateSnippetCourseData
for information about the possible fields. You can provide this data as aCreateSnippetCourseData
or as a dictionary.course_id (
int
) – The id of the course in which you want to create a new snippet.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 response containing the JSON serialized snippet and return code 201.
- Return type:
- 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:
- create_group_set(json_body, *, course_id, extra_parameters=None)[source]#
Create or update a GroupSet in the given course id.
- Parameters:
json_body (
Union
[dict
,list
,CreateGroupSetCourseData
]) – The body of the request. SeeCreateGroupSetCourseData
for information about the possible fields. You can provide this data as aCreateGroupSetCourseData
or as a dictionary.course_id (
int
) – The id of the course in which the group set should be created or updated. The course id of a group set cannot change.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:
The created or updated group.
- Return type:
- 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:
course_id (
int
) – The id of the coursehas_rubric (
Union
[Just
[bool
],_Nothing
[bool
]]) – Get only assignments that have a rubric.has_auto_test (
Union
[Just
[bool
],_Nothing
[bool
]]) – Get only assignments that have a AutoTest configuration.has_handin_requirements (
Union
[Just
[bool
],_Nothing
[bool
]]) – Get only assignments that have hand-in requirements.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 response containing the assignments of the given course sorted by deadline of the assignment
- Return type:
- create_assignment(json_body, *, course_id, extra_parameters=None)[source]#
Create a new course for the given assignment.
- Parameters:
json_body (
Union
[dict
,list
,CreateAssignmentCourseData
]) – The body of the request. SeeCreateAssignmentCourseData
for information about the possible fields. You can provide this data as aCreateAssignmentCourseData
or as a dictionary.course_id (
int
) – The course to create an assignment in.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:
The newly created assignment.
- Return type:
- get_all_enroll_links(*, course_id, extra_parameters=None)[source]#
Get the registration links for the given course.
- Parameters:
- Returns:
An array of registration links.
- Return type:
- put_enroll_link(json_body, *, course_id, extra_parameters=None)[source]#
Create or edit an enroll link.
- Parameters:
json_body (
Union
[dict
,list
,PutEnrollLinkCourseData
]) – The body of the request. SeePutEnrollLinkCourseData
for information about the possible fields. You can provide this data as aPutEnrollLinkCourseData
or as a dictionary.course_id (
int
) – The id of the course in which this link should enroll users.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:
The created or edited link.
- Return type:
- 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:
- create_section(json_body, *, course_id, extra_parameters=None)[source]#
Create a new course section.
- Parameters:
json_body (
Union
[dict
,list
,CreateSectionCourseData
]) – The body of the request. SeeCreateSectionCourseData
for information about the possible fields. You can provide this data as aCreateSectionCourseData
or as a dictionary.course_id (
int
) – The id of the course to create a section for.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:
The new section.
- Return type:
- put_price(json_body, *, course_id, extra_parameters=None)[source]#
Update the price of the given course.
- Parameters:
json_body (
Union
[dict
,list
,PutPriceCourseData
]) – The body of the request. SeePutPriceCourseData
for information about the possible fields. You can provide this data as aPutPriceCourseData
or as a dictionary.course_id (
int
) – The id of the course for which you want to update the price.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:
The created or updated price.
- Return type:
- 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:
course_id (
int
) – The id of the course in which the snippet is located.snippet_id (
int
) – The id of the snippetextra_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:
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:
json_body (
Union
[dict
,list
,PatchSnippetCourseData
]) – The body of the request. SeePatchSnippetCourseData
for information about the possible fields. You can provide this data as aPatchSnippetCourseData
or as a dictionary.course_id (
int
) – The id of the course in which the course snippet is saved.snippet_id (
int
) – The id of the snippet to change.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:
An empty response with return code 204.
- Return type:
None
- get_registration_link(*, course_id, link_id, extra_parameters=None)[source]#
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:
- delete_enroll_link(*, course_id, link_id, extra_parameters=None)[source]#
Delete the given registration link.
- 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.self (CourseService[AuthenticatedClient]) –
- Returns:
Nothing.
- Return type:
None
- delete_role(*, course_id, role_id, extra_parameters=None)[source]#
Remove a CourseRole from the given Course.
- Parameters:
course_id (
int
) – The id of the courserole_id (
int
) – The id of the role you want to deleteextra_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:
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:
json_body (
Union
[dict
,list
,PatchRoleCourseData
]) – The body of the request. SeePatchRoleCourseData
for information about the possible fields. You can provide this data as aPatchRoleCourseData
or as a dictionary.course_id (
int
) – The id of the course.role_id (
int
) – The id of the course role.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:
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:
course_id (
int
) – The id of the course to remove the user from.user_id (
int
) – The id of the user to remove from the course.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:
Nothing.
- Return type:
None
- export_gradebook(*, course_id, format='csv', extra_parameters=None)[source]#
Export a gradebook as CSV for this course.
- Parameters:
course_id (
int
) – The id of the course to export.format (
Literal
['csv'
,'json'
]) – The format of the output file. Either “csv” or “json”.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:
The task that creates the export.
- Return type:
- get_all_users(*, course_id, q=Nothing, extra_parameters=None)[source]#
Get all users and their role in a course.
- Parameters:
course_id (
int
) – The id of the courseq (
Union
[Just
[str
],_Nothing
[str
]]) – Only retrieve users whose name or username matches this value. This will change the output to a list of users.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:
All users in this course and their role. If you provided the q parameter only the user is returned, not their role.
- Return type:
- change_user_role(json_body, *, course_id, extra_parameters=None)[source]#
Set the CourseRole of a user in the given course.
- Parameters:
json_body (
Union
[dict
,list
,ChangeUserRoleCourseData_1
,ChangeUserRoleCourseData_1_2
]) – The body of the request. SeeChangeUserRoleCourseData
for information about the possible fields. You can provide this data as aChangeUserRoleCourseData
or as a dictionary.course_id (
int
) – The id of the course in which you want to enroll a new user, or change the role of an existing user.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:
The response will contain the JSON serialized user and course role.
- Return type:
- get(*, course_id, extra_parameters=None)[source]#
Get a course by id.
- Parameters:
- Returns:
A response containing the JSON serialized course
- Return type:
- patch(json_body, *, course_id, extra_parameters=None)[source]#
Update the given course with new values.
- Parameters:
json_body (
Union
[dict
,list
,PatchCourseData
]) – The body of the request. SeePatchCourseData
for information about the possible fields. You can provide this data as aPatchCourseData
or as a dictionary.course_id (
int
) – The id of the course you want to update.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:
The updated course, in extended format.
- Return type:
- 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:
- 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:
- 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:
course_id (
int
) – The id of the course of which the permissions should be retrieved.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 the permission name and a boolean indicating if the currently logged in user has this permission.
- Return type:
- 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:
- import_into(json_body, *, into_course_id, extra_parameters=None)[source]#
Copy a course into another course.
- Parameters:
json_body (
Union
[dict
,list
,ImportIntoCourseData
]) – The body of the request. SeeImportIntoCourseData
for information about the possible fields. You can provide this data as aImportIntoCourseData
or as a dictionary.into_course_id (
int
) – The course you want to import into.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:
The updated course, so the course of which the id was passed in the url.
- Return type:
- 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:
course_id (
int
) – The id of the course in which you want to enroll.link_id (
str
) – The id of the link you want to use to enroll.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:
Nothing.
- Return type:
None
- register_user_with_link(json_body, *, course_id, link_id, extra_parameters=None)[source]#
Register as a new user, and directly enroll in a course.
- Parameters:
json_body (
Union
[dict
,list
,RegisterUserWithLinkCourseData
]) – The body of the request. SeeRegisterUserWithLinkCourseData
for information about the possible fields. You can provide this data as aRegisterUserWithLinkCourseData
or as a dictionary.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 access token that the created user can use to log in.
- Return type:
- email_users(json_body, *, course_id, extra_parameters=None)[source]#
Sent the authors in this course an email.
- Parameters:
json_body (
Union
[dict
,list
,EmailUsersCourseData_1
,EmailUsersCourseData_1_2
]) – The body of the request. SeeEmailUsersCourseData
for information about the possible fields. You can provide this data as aEmailUsersCourseData
or as a dictionary.course_id (
int
) – The id of the course in which you want to send the emails.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 task result that will send these emails.
- Return type: