Guides
Moodle
Roster sync, an "Open in GroutCode" button 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 three 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. "Open in GroutCode" activity#
Scope: sso:write.
Add a URL activity that points at your plugin endpoint. On click, the plugin calls:
curl -X POST $API/sso/tokens -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{ "email": "<stored login_email>", "app": "groutcode", "redirect": "exam:<exam_id>", "ttl_seconds": 120 }'and 302-redirects the browser to launch_url. Mint per click.
3. 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.