Moodle API
This guide provides an overview of how to interact with the Moodle API, including how to access, use, and integrate Moodle data in studies.
Note
This documentation is meant for researchers and non-developers. If you’re a developer working with the backend or extending RPC functionality, refer to the Moodle API technical guide.
Overview
The Moodle API enables authorized users to connect to a Moodle Instance and access course-related data. Researchers typically use this functionality to:
Import student submissions for annotation or evaluation
Distribute study results or feedback
Import user data
Note
We recommend obtaining approval from your research ethics committee before importing user data, as these may include personally identifiable information (PII).
Setting Up the Moodle API
To use the Moodle API, you will need access credentials and permissions configured in your Moodle instance.
You will need:
API Key: Issued by your Moodle system administrator. It must grant access to course and user data relevant to your study.
API URL: The base URL of your Moodle instance (e.g., https://your-moodle-instance.edu).
Course ID: The numeric identifier for the Moodle course you’re working with. This is visible in the course URL as a segment like
id=123.Assignment ID: If you’re importing submissions, you’ll also need the specific assignment ID, which appears similarly in the assignment URL.
Sufficient Permissions: The Moodle account used must be enrolled in the course as a teacher or non-editing teacher to access submissions and user data.
Note
You can find course and assignment IDs by opening the respective pages in Moodle and checking the URL (e.g., .../course/view.php?id=123).
If you’re unsure about your API key or access level, contact your Moodle administrator.
For system administrators: see Administrator configuration for detailed instructions on configuring Moodle to enable API access.
Setting Up the Moodle Integration in CARE
To configure Moodle API access in the CARE platform:
Go to
Settingsin the sidebarSelect the
RPCpanel and then click onmoodleAPIEnter the following:
rpc.moodleAPI.apiKey – your API key from the Moodle admin
rpc.moodleAPI.apiUrl – the base URL of your Moodle instance
rpc.moodleAPI.courseID – the course ID where you are assigned as a tutor or teacher
Note
The Moodle account used must have proper permissions for the course. If you’re unsure, ask your Moodle administrator for help.
Using Moodle with the CARE Platform
Importing Users
Before using this feature, make sure Moodle API access is configured as described in Setting Up the Moodle API.
User data can be imported from Moodle using the course ID:
In the Dashboard navigate to
Users > Import via MoodleCARE will match users by email address
CARE handles three scenarios:
New users are created if not found
Duplicate users are merged based on email match
Conflicts (e.g., mismatched emails) require manual correction
Warning
Never delete a user with an extId unless you are certain it won’t be needed. This could prevent future updates or synchronization.
Tip
If a user’s email in CARE differs from Moodle, edit it manually to allow a match. Avoid duplicates.
The CARE platform integrates directly with Moodle to help manage studies. Researchers typically use the following workflows:
Importing Submissions from Moodle
To collect assignment submissions:
In Moodle, create an assignment. See Assignment creation for detailed configuration instructions.
In CARE:
In the Dashboard go to
SubmissionsChoose
Import via MoodleProvide the correct course and assignment IDs
Study Creation with Imported Submissions
To create a study using either imported submissions or documents:
Single Assignment
In the Dashboard go to
Studies > Add Single AssignmentChoose a template or start from scratch.
If you don’t have a template yet, you can create one in two ways:
Option 1 - From an existing study:
In the Dashboard, go to
StudiesClick on
Addto create a new studyDefine the workflow and settings as needed
After saving, your study will appear in the list
Click on
Save as templateto reuse this setup in future studies
Option 2 - Directly create a template:
In the Dashboard, go to
StudiesClick on
Saved TemplatesClick on
Create Templatein the modalDefine the workflow and settings directly as a template
Choose the assignment type:
Documents: Select from documents for the assignment
Submissions: Select from imported Moodle or manually added submissions
Select the specific document or submission you want to include in the assignment
Assign reviewers and finalize setup
Bulk Assignments
For creating multiple assignments at once:
In the Dashboard go to
Studies > Add Bulk AssignmentsSelect a study template (required)
Choose the assignment type: Documents or Submissions
Select multiple documents or submissions from the table
Choose reviewers from the user list. You can filter reviewers by:
Users with documents
Users from the selected documents/submissions
Configure distribution mode:
Role-based selection: Define how many reviews each role should perform per document/submission
Reviewer-based selection: Distribute the selected documents/submissions among specific reviewers
Review and confirm the assignment details
Note
When using submissions, CARE automatically associates the primary document from each submission with the first workflow step.
Publishing Feedback
After analysis or review, you may want to send feedback to students:
Close your study in CARE.
To do this, go to the
Studiessection in the Dashboard, locate your study in the list, and click theClose Studybutton.In the Dashboard, go to
Submissionsand click onPublish ReviewsSelect the corresponding session and assignment
Use the
Upload to Moodleoption
Warning
Feedback can only be published to users with a valid extId (external ID from Moodle). Missing IDs must be corrected via user re-import.
Assignment Configuration in Moodle
Before configuring assignments, ensure your Moodle instance is set up correctly. See Setting Up the Moodle API.
Depending on the task, configure assignments as follows:
For collecting submissions:
Submission type:File submissionsFeedback type:Feedback commentsSubmit button:NoSubmission statement:Yes
For publishing feedback (no file uploads):
Submission type: NoneFeedback type:Feedback comments(Inline:No)Grade type: NoneCompletion conditions: None
Choose clear and descriptive assignment names for easier tracking in CARE.
Further Reading
For official and technical resources, consult:
These references can provide additional context for permissions, supported functions, and integration behavior when needed.