iramosdev / moodle-rest-wrapper
A wrapper for llagerlof/moodlerest
dev-main
2024-12-07 11:01 UTC
Requires
- php: ^7.3|^8.0
- llagerlof/moodlerest: ^2.4
This package is auto-updated.
Last update: 2025-06-06 17:34:24 UTC
README
Description:
Wrapper for llagerlof/MoodleRest, simplify http Request to Moodle Rest
Required:
- PHP 7.4 or greater
Instructions:
Installation
- Run:
$ composer require iramosdev/moodle-rest-wrapper
Usages:
Create a new instance for MoodleRestService:
use IramosDev\MoodleRestWrapper\Service as MoodleRestService; $moodleRestService = new MoodleRestService('https://www.moodle-site.com/api/endpoint', 'Moodle_token');
Create a new student:
$newStudent = $moodleRestService->createStudent([ 'firstname' => 'John', 'lastname' => 'Doe', 'username' => 'john.doe', 'email' => 'jdoe@mail.com', 'password' => 'user_password', 'phone1' => '+1 (714) 990-7103', ]);
Retrieve course data:
$course = $moodleRestService->getCourse('course_name');
Enroll new student:
$moodleRestService->enrollStudent($newStudent[0]['id'], $course[0]?->id, 5);
Check if student is currently enroll in a specific course:
$moodleRestService->isEnrolled(5, 'jdoe@mail.com')