Quick Start¶
Get up and running with py-moodle in minutes!
Prerequisites¶
- Python 3.8+ installed
- Access to a Moodle instance
- Valid Moodle credentials
1. Install py-moodle¶
2. Configure Credentials¶
Create a .env
file with your Moodle credentials:
Edit the .env
file (replace PROD
with your target environment name):
MOODLE_PROD_URL=https://your-moodle-site.com
MOODLE_PROD_USERNAME=your-username
MOODLE_PROD_PASSWORD=your-password
# Optional: CAS URL and token
# MOODLE_PROD_CAS_URL=https://cas.your-institution.org/cas
# MOODLE_PROD_WS_TOKEN=your_webservice_token
Select this environment by running commands with --env prod
or by setting MOODLE_ENV=prod
.
3. Test Your Setup¶
List all available courses:
You should see output like:
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Shortname ┃ Fullname ┃
┡━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 2 │ my-first-course │ My first course │
│ 4 │ my-second-course │ My second course │
└────┴──────────────────────────────┴───────────────────────────────────┘
4. Try Some Commands¶
Show course details:
Create a new course:
Add content to a course:
py-moodle modules add label --course-id 2 --section-id 1 --name "Welcome" --intro "Welcome to the course!"
Next Steps¶
- Check out the CLI Reference for all available commands
- Read the Configuration guide for advanced setup
- Browse API Reference to use py-moodle as a library
Need Help?
Use py-moodle --help
or py-moodle COMMAND --help
for detailed command information.