/moodle-local_wsmanager

Moodle Web-Services manager. SOAP or REST API via XML or JSON formats

Primary LanguagePHP

Moodle WSManager Local Plugin

License

Web-Services allows to integrate Moodle data with another external applications and programming languages through XML or JSON formats. For example, you can export or import Moodle users data with your CRM. In other words, this is an API: REST or SOAP.

moodle-local_wsmanager lets you easily manage and test Moodle Web Services instances from one place and much more.

Contents

Why?


Creating Moodle Web-Services and tuning up the ones is a huge job if you are following a "Moodle way": administrator has to jump between a lot of sections. WSManager has only two sections:

  • Dashboard. Global info, settings, docs links and testing tiny service.
  • Web Services. Manage all services and its instances: tokens, users, functions.

Installation


  1. Download the plugin zip-file
  2. Add to your Moodle as administrator
    1. Site administration (/admin/search.php)
    2. Plugins tab
    3. Install plugins link (/admin/tool/installaddon/index.php).
    4. Upload ZIP package and click Install plugin from ZIP file

Overview


Web Services Manager allows you to:

  • Quickly check status/errors and enable or disable WS globally
  • Add a new instance
  • Switch REST and SOAP protocols
  • Manage Mobile App settings
  • Test Web Services through creating a tiny one just to look how does WS works
  • Create a new instance
  • Manage all of Web Services settings and instances in one window:
    • Settings
      • Check the info: Short name, Time added
      • Enable/disable WS
      • Change name (if it is custom WS)
      • Authorised users only switch
      • Can download files switch
      • Can upload files switch
    • Manage Tokens
      • View all WS tokens and its options:
        • Value
        • User
        • IP restriction
        • Valid until
        • Creator
      • Create WS tokens
      • Delete WS tokens
    • Users (if Authorised users only enabled)
      • View all WS users and options:
        • Full name
        • IP restriction
        • Valid until
      • Add WS users
      • Delete WS users
    • Functions
      • View all WS functions and options:
        • Function name
        • Function description
        • Test/execute function
      • Add WS function
      • Delete WS function

Usage


As an administrator follow to:

  1. Site administration (/admin/search.php)
  2. Server tab (/admin/search.php#linkserver)
  3. Find Web services manager section. There are two links: Dashboard and Web services

Dashboard

Here you can control common settings of WS status.

Moodle WSManager Dashboard Overview

Status notification

If some options are breaking WS work, notification will show an error message with AJAX link to fix it to minimum default settings to enable Web-Services. If notification message is Web Services are ready to go means everything fine.

Error example. Just click on Fix it and confirm this action.

Fix errors

Mobile App

Moodle Mobile App works with enabled WS and has an own setting to enable/disable. You can switch it here or go to native Settings section.

Moodle Mobile App settings

Testing

This section is to make a simple test with tiny service and function handler. Web service test client link is an internal Moodle plugin to test some simple functions.

Moodle Web-Services Test Client

Test function widget allows to test built-in tiny simple function with input data argument that is returned.

  1. Click on Create Test Web Service button and confirm modal dialog. Dialog confirm modal
  2. New service with test function local_wsmanager_external_function_test_handle is created Created function
  3. Fields:
    1. Enabled - Web-Service enable/disable switcher. For security reason, disable it if unusual
    2. Web Service name
    3. Function name
    4. Description
    5. Delete button, here you can delete this WS
    6. Type read/write
    7. Testing button that opens a modal dialog to manage function execution

Documentation

List of useful links for Moodle Web-Services: documentation, Built-in external functions, Forum etc.

Documentation links

Web Services

List of exists services with all manage functions

Manage WS

Add service


Click on + Add service link that shows the create form, fill it and save to add the one.

Add Moodle Web Service

Services list sidebar

Services divided to Built-in (Mobile WS and External Plugins WS) and Custom (created by administrator). Here you can navigate to a needle service.

Manage tokens

Token is a necessary parameter to make a request, this is a hashed unique string. Here administrator can add a new token or delete an exist one.

Tokens

Users

If the service restricted with Authorised users only option, administrator can add users to WS.

Users

Functions

External function is a handler and main point of request.

Functions

Test/execute functions

Every request has necessary parameters, at least it's a token and function. Every function has own parameters and type. In the plugin every external function has a manage button Testing (if WS Tokens are not empty) that shows a dialog modal, here we can see all information about this function and also make a test/execution request. But be sure before you execute it that request is fine for you and security. If the type of function is read - recommended request method is GET, if write - POST.

Function execute

Let's take a look at function options

  1. Web Service name of function WS
  2. Function name
  3. Description
  4. Type: read/write
  5. Request Method: GET/POST
  6. Protocol: list of enabled protocols (at Dashboard)
  7. Format: JSON/XML - only for REST protocol
  8. Service Token to use in test request
  9. Function parameters with its info. Fill an own data and data in Request widget will be updated on a blur event Param Info
  10. Request widget. Here you can see all request info data
  11. Execute button to send a test request. Response will be shown above. Response

Credits

License

The Moodle WSManager Moodle plugin is licensed under the terms of the GPL-3.0+ license and is available for free.