A small Python package with some functionalities to deal with moodle-based LMS.
# New installation
pip3 install moodle-kit
or
# Upgrade installation
pip3 install moodle-kit --upgrade
# Import Moodle class from package
from moodle_kit import Moodle
# Instantiate an object from Moodle class
moodle = Moodle()
- Login
login_url = 'https://example.com/login/index.php'
username = 'your_username'
password = 'your_password'
moodle.login(login_url, username, password)
# The response object is automatically saved in moodle.response property.So you can check the status code this way.
print(moodle.response.status_code)
# To verify if login is successful, you can print the page title.
print(moodle.title)
# On the other hand, you can also assign a varible to it.
response = moodle.login(login_url, username, password)
print(response.status_code)
- Logout
moodle.logout()
# After logging out, the moodle.response property is updated.
# So, you can verify if it's successful or not by printing the url.
print(moodle.response.url)