All Collections
Admin Guides
API
Configuring the API for Moodle
Configuring the API for Moodle

Allow FeedbackFruits to sync enrollments and more

Updated over a week ago

Before proceeding with these steps, please inform your contact person or Pilot and Partner Manager at FeedbackFruits to ensure a smooth and safe process.

Introduction

As mentioned in the API Primer, the API integration greatly improves the user experience for teachers using FeedbackFruits.

The Moodle integration uses the REST API integration with a scoped service account.

Configuring the REST API

Step 1 - Adding custom parameters

First step you will need to take is to allow FeedbackFruits to communicate with Moodle. This can be done from the settings of the LTI 1.1 or LTI 1.3 tool(s) you have set previously in your Moodle environment.

To do so you will have to go Site administration, then click on Plugins, and click the Manage tools url in the Activity modules section. Here you will find the FeedbackFruits configuration (either via LTI 1.1 either via LTI 1.3). In order to edit the configuration in place, click the edit-icon in the top right corner of your configuration.

In the configuration of the tool you can now type the following custom parameters:

  • For LTI 1.1 configuration(s): external_course_id=$Context.id

  • For LTI 1.3. configuration(s): course_id=$Context.id

Step 2 - Configuring a system role

The next step in the configuration is to create a new system role within Moodle that is granted only specific permissions that will allow FeedbackFruits to synchronize automatically groups (sets) in Moodle and sending back calendar deadlines (soon).

To set up the new system role, you can go over the Site administration, navigate to the Users tab where you will find the module Permissions. Within this module select the option Define roles and click on Add new role.

In the newly opened window skip the first step by clicking the Continue button.

Fill in the name(s) tab:

  • Short name: FbF

  • Custom full name: FeedbackFruits

  • Custom description: leave blank

For the Context types where this role may be assigned please select the “System” option.

The next step is to enable the usage of the REST API by allowing further permissions. To do so scroll down the role page and allow the following permissions:

  • webservice/rest:use

  • moodle/site:viewparticipants

  • moodle/site:viewuseridentity

  • moodle/course:managegroups

  • moodle/course:view

  • moodle/course:viewparticipants

  • moodle/user:viewdetails

  • moodle/user:viewhiddendetails

  • moodle/course:useremail

  • moodle/course:viewhiddencourses

  • moodle/site:accessallgroups

  • moodle/course:update

  • moodle/user:update

Note: currently the calendar synchronization is not supported with the current API setup, once the integration is validated we will inform which permissions are required to be able to have the calendar synchronization working on your end. Please follow up with your contact person at FeedbackFruits for more information.

Once the permissions are allowed scroll down the page and click Create role.

Step 3 - Creating a new user account

As the role created needs to be linked to FeedbackFruits, you will have to now create a User that is granted the role you just created.

To do so, go to Site administration, select Users and within the module click on Accounts. Here you will have the option to Add a new user.

Fill the required fields based on your wishes. Save the user.

Step 4 - Accepting the user agreements

It is important to note that the Moodle API will work when the user, in this case the system administrator can accept the MoodleCloud and MoodleCloud Cookies policies for the user created. To do so you can navigate to Site administration, select the Users tab, and then click on Privacy and policies and select the User agreements mentioned. If the policies for the FeedbackFruits user are not accepted yet, accept them on the user’s behalf.

Step 5 - Linking the new user to the created role

The next step is to add the role you created in the first step to the user. To do so navigate to the Users tab within the Site administration and select the Permissions category. Within the new tab scroll to the Assign system roles option and select the role you created in step 2 for the new user created in Step 3.

Step 6 - Creating the external service

Furthermore in order to enable the Moodle API you will have to enable the specific functionality you want it to utilize (synchronization of groups and calendar events).

To do so navigate to the Plugins bar within the Site administration and open the Server tab. Scroll down to the Web services category. Select External services and add a new custom service and save it. Make sure you’ve enabled the web service and to select "Authorised users only".

In the new service created add the following functions by clicking the ‘functions’ link followed by ‘Add functions’:

  • Core_course_get_courses

  • Core_enrol_get_enrolled_users

  • Core_group_get_course_groupings

  • Core_group_get_course_groups

  • Core_group_get_groupings

  • Core_group_get_group_members

  • Core_group_get_groups

  • Core_user_get_users_by_field

Step 7 - Authorizing the user

Navigate to the external services overview and click on Authorize users and add the new user you created.

Step 8 - Creating a Web Service Token (WST)

A WST is required as an authentication method for the API integration to work. To do so navigate to Site administration, select Plugins and go to Web services. Within the new window select Manage tokens and click Add.

Select the newly created user and external service and save.

Now you will be redirected to the tokens overview page where your token will be displayed.

Share the token key with your contact person at FeedbackFruits for them to enable the API from our end.

Step 9 - Run a test to validate the integration worked

This concludes the Configuring the API for Moodle tutorial.
If you have any questions or experience a technical issue, please contact our friendly support team by clicking on the blue chat button (Note: support is available 24h every weekday & unavailable on the weekend).

Did this answer your question?