Skip to content

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. 1

    Pull enrolments

    Use core_enrol_get_enrolled_users per course to get users and roles.

  2. 2

    Provision missing students

    For each learner without a stored Grout id call POST /students with student_id = Moodle user id and personal_email = their Moodle email. Store the returned id and login_email in a custom profile field or your plugin table.

  3. 3

    Mirror course groups

    POST /groups once per Moodle course (name = course full name, faculty_id = the teacher's Grout login email), then PATCH /groups/{id} with the full student_ids list on every run.

  4. 4

    Suspend leavers

    POST /students/{id}/suspend for 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:

bash
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:

  1. Verify the signature (Verify Signatures).
  2. GET /submissions/{submission_id} for score, max_score, feedback.
  3. Map exam_id → Moodle grade item, then call core_grades_update_grades (or your grade item's API) for the student.
  4. If resubmission_required is true, 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.