assistants.moodle¶
This file contains all the requests send to Moodle.
Module Contents¶
-
exception
assistants.moodle.MoodleException¶ Bases:
ExceptionMoodle exception.
-
assistants.moodle.send_message(user_id, message)¶ Send a message to one user in Moodle.
The parameters are defined and used to send a message to Moodle. Then, call the function send_query() with the parameters. It handles the actual request to Moodle. :param user_id: ID of the user. :type user_id: str :param message: String text you want to send to the user. :type message: str
-
assistants.moodle.send_bulk_messages(user_ids, message)¶ Send a message to multiple users in Moodle.
- Parameters
user_ids (list(int)) – list of user ids to send the message to
message (str) – the message to send to the users
-
assistants.moodle.send_bulk_different_messages(id_messages_list)¶ Send multiple different messages to different users.
- Parameters
id_messages_list (list(tuple(str, str))) – list containing tuples (user id, message to send to user)
-
assistants.moodle.get_course_by_id_field(course_id)¶ Get the information of a course.
The parameters are defined and used to get the course information. Then, call the function send_query() with the parameters. It handles the actual request to Moodle. :param course_id: Id of a course. :type course_id: int :return: All the information of the course in JSON. :rtype: dict
-
assistants.moodle.get_courses()¶ Get all the courses from Moodle.
- Returns
All courses from Moodle.
- Return type
json
-
assistants.moodle.get_enrolled_users(course_id)¶ Get all the enrolled users of a course.
The parameters are defined and use all information of the enrolled students of a course. Then, call the function send_query() with the parameters. It handles the actual request to Moodle.
- Parameters
course_id (str) – Id of a course.
- Returns
All the information of the courses in JSON.
- Return type
json
-
assistants.moodle.get_assignments(course_id)¶ Request all assignments in a course.
- Parameters
course_id (str) – The course ID.
- Returns
JSON containing the assignments.
- Return type
json
-
assistants.moodle.get_assignment_status(course_id, user_id)¶ Request the status of all assignments in a course for a given user.
- Parameters
course_id (str) – The course ID.
user_id (str) – The user ID.
- Returns
JSON containing the assignment statuses.
- Return type
json
-
assistants.moodle.get_course_contents(course_id)¶ Get all course contents for 1 course from Moodle.
- Parameters
course_id (str) – The course ID.
- Returns
JSON containing the course contents.
- Return type
dict
-
assistants.moodle.get_attempt(attempt_id)¶ Get the information of a course.
The parameters are defined and used to get the course information. Then, call the function send_query() with the parameters. It handles the actual request to Moodle. :param attempt_id: The attempt ID. :type attempt_id: str :return: All the information of the course in JSON. :rtype: json
-
assistants.moodle.get_teachers(course_ids)¶ Get all the teachers for courses in Moodle.
- Parameters
course_ids (list(str)) – List of course_id.
- Returns
All teachers.
- Return type
dict
-
assistants.moodle.send_query(func, data, exp_status_code)¶ Send a query to Moodle in a certain format.
- Parameters
exp_status_code (int) – The expected status code a function should return on success.
func (str) – The web service function that is send to the api.
data (dict) – The parameters send for the function.
- Returns
The Moodle response.
- Return type
json