Guides
Moodle
Roster sync and gradebook write-back from Moodle.
This guide assumes a small local plugin or an external service with access to Moodle's web services. It uses two Grout keys, one per job, as recommended in API Keys & Scopes.
1. Nightly roster sync#
Scopes: students:write, groups:write, faculty:read.
- 1
Pull enrolments
Use
core_enrol_get_enrolled_usersper course to get users and roles. - 2
Provision missing students
For each learner without a stored Grout id call
POST /studentswithstudent_id= Moodle user id andpersonal_email= their Moodle email. Store the returnedidandlogin_emailin a custom profile field or your plugin table. - 3
Mirror course groups
POST /groupsonce per Moodle course (name = course full name,faculty_id= the teacher's Grout login email), thenPATCH /groups/{id}with the fullstudent_idslist on every run. - 4
Suspend leavers
POST /students/{id}/suspendfor users whose enrolment ended.
2. Gradebook write-back#
Scopes: submissions:read, webhooks:write.
Register an endpoint subscribed to exam.graded. On delivery:
- Verify the signature (Verify Signatures).
GET /submissions/{submission_id}forscore,max_score,feedback.- Map
exam_id→ Moodle grade item, then callcore_grades_update_grades(or your grade item's API) for the student. - If
resubmission_requiredistrue, set the grade to "needs revision" instead.
Cron sizing#
A 5 000-student institution syncs comfortably within the default 600 requests/minute using POST /students/bulk and PATCH /groups/{id} — roughly 30 bulk calls plus one call per course.