Skip to content

dynamyy/MoodleAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MoodleGet

convenient way to get data through Moodle's API

Setup

Install the package using pip:
pip install MoodleGet

Now you can open your project and import the MoodleAPI class
from MoodleGet import MoodleAPI

Initialising the class

url = "https://yourMoodle/webservice/rest/server.php"
token = your Moodle's API token
moodle = MoodleAPI(url, token)

Available methods

.call(function, data, params)

Send a post request to Moodle through their API system. Returns the response from Moodle in json format

argument expected type required default value
function string yes -
data dict no {"wstoken": self.token,
"wsfunction": function,
"moodlewsrestformat": "json"}
params dict no {}

.get_courses()

Find all the courses that the user can see.

Returns a tuple (courses_dict, course_id_list), where

courses_dict is a dictionary, where keys are the course id-s and every key has a list set to it's value. The list contains [course's code, course's name in a readable way]

course_id_list is a list that has all the course's id-s as it's elements for convenient access

.get_calendar_events(courses_list)

Finds all the calendar events in Moodle calendar in the time period now until 3 weeks from now.
Returns a list of the events, where every element of the list is another list containing: [event_id, name, events_course_id, exercise_type, event_starttime]

argument expected type required default value
courses_list list yes -

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages