Configuring the API for Moodle
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 - Configuring a system role
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
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:
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 2 - 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 3 - Link the new user to the created role
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.
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 1 for the new user created in Step 2.
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 Plugins 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.
In the new service created add the following functions by clicking the ‘functions’ link followed by ‘Add functions’:
Step 4 - Authorize your user
Navigate to the external services overview and click on Authorize users and add the new user you created.
Step 5 - Create 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 6 - Run a test to validate the integration worked