Connecting Moodle instance

How to integrate courses of a moodle-instance

This connection-workflow is in an experimental proof-of-concept phase.

Idea / Description

Goal: all Moodle courses of a Moodle instance are to be queried automatically via the API of Moodle and listed in OERSI.

At the moment this is still in the proof-of-concept phase. We have looked at moodle’s API and checked if it is suitable and what needs to be done so that we can use it.

Current status: harvesting via the Moodle API has been implemented using the Moodle instance of VLC as an example. If a Moodle instance can be connected to OERSI have to be checked for every new Moodle instance, as it depends heavily on the metadata provided by the Moodle instance. Sometimes metadata fields have to be defined fixed per instance.

Moodle-Configuration

In a standard Moodle installation, some things are not enabled by default and need to be configured by a Moodle admin for OERSI integration.

The configuration listed here was tested in a local Moodle installation via moodle-box, Moodle version 4.0.1.

Free accessible course pages

Detail pages of Moodle courses should ideally be freely accessible without registration (guest access). To do this, make the following configuration:

  • Enable guest access system-wide for new courses: Website Administration => Plugins => Enrollment => Enable “Eye” on Guest Access
  • automatically log in as guest (saves the user from logging in manually): Website Administration => Users => Rights => Enable “Automatically log in guests “
  • already existing courses can be changed (for each course individually) as follows: Course page => Participants => Enrollment methods (via drop-down) => Enable “eye” on guest access (see also https://docs.moodle.org/400/de/Gastzugang_zum_Kurs)

activate Webservice-API (required)

The idea is to use Moodle’s webservice-API to retrieve course metadata automatically. In Moodle this is only possible for authenticated and authorized users. This means we need an account for the OERSI integration and credentials for the API.

  • Create user: Website-Administration => Users => Create User => Name: “oersi” (if applicable?), Authentication: “Webservices “
  • configure Webservice-API
    • Activate Webservices: Website-Administration => Server => Webservices => Enable Webservices.
    • Activate Rest-Protocol: Website-Administration => Server => Webservices => Activate Protocols => activate “Rest” & “Documentation”
    • Select service: Website-Administration => Server => Webservices => Select Service => Edit “Moodle mobile web service “ => Activate
    • Create new role with appropriate rights: Website-Administration => Users => Rights => Manage roles => Add new role => Such as “webservice users “ => Enable permissions: “moodle/webservice:createtoken”, “moodle/course:view” and “webservice/rest:use”; Context: “course”, “course area”; Allow “role assignment” for managers
    • Set up permissions for previously created users: Website-Administration => Users => Rights => Global Roles => Select previously created role “webservice users “ => Select previously created user “oersi “
    • Generate token to authenticate the oersi user: Website-Administration => Server => Webservices => Manage Tokens => Generate Token => Select previously created user “oersi “
    • now it should be possible to query the courses via the Rest-API: `https://YOUR-MOODLE-HOST/webservice/rest/server.php?wstoken=YOUR-TOKEN&wsfunction=core_course_get_courses_by_field