https://github.com/jacoblincool/moodle-export
A streamlined library for retrieving data from Moodle.
https://github.com/jacoblincool/moodle-export
data moodle
Last synced: about 1 year ago
JSON representation
A streamlined library for retrieving data from Moodle.
- Host: GitHub
- URL: https://github.com/jacoblincool/moodle-export
- Owner: JacobLinCool
- License: agpl-3.0
- Created: 2023-09-14T13:38:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-26T15:29:02.000Z (about 1 year ago)
- Last Synced: 2025-04-26T16:30:06.730Z (about 1 year ago)
- Topics: data, moodle
- Language: TypeScript
- Homepage: http://jacoblin.cool/moodle-export/
- Size: 313 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moodle Export
A streamlined library for retrieving data from Moodle.
[Documentation](https://jacoblincool.github.io/moodle-export/)
## Example
### An OOP approach
```ts
import { MoodleExporter } from "moodle-export";
// Initialize the exporter
const exporter = MoodleExporter.init({
base: "https://moodle.example.com",
username: "username",
password: "password",
});
// Get all courses and their attendees and activities
const courses = await exporter.courses();
for (const course of courses) {
console.log(course.fullname);
const attendees = await course.attendees();
const activities = await course.activities();
console.log({ attendees, activities });
}
```
### A FP approach
```ts
import { login } from "moodle-export";
const base = "https://moodle.example.com";
// Create a fetcher
const fetcher = await login({
base,
username: "username",
password: "password",
});
// Get all courses and their attendees and activities
const courses = await fetch_course_list(fetcher, base);
for (const course of courses) {
console.log(course.fullname);
const attendees = await fetch_course_attendees(fetcher, base, course.id);
const activities = await fetch_course_activities(fetcher, base, course.id);
console.log({ attendees, activities });
}
```