Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-50032

Allow external functions to add themselves into services

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.9, 3.1
    • Fix Version/s: 3.1
    • Component/s: Web Services
    • Testing Instructions:
      Hide
      1. Do a Moodle upgrade and check in Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions (select the mobile service) display external functions for all the modules supported by the app (forum, glossary, chat, lti imscp, book, url, page, etc..
      2. With the Mobile app check that you can connect successfully and that you can access to those modules in the app.
      3. Now, bump the version number in /version.php, do a normal upgrade and check that the app still works and that the all the external functions are still displayed under the Mobile service
      4. Install in Moodle the attached plugin (local_testservices.zip), it will install a new service "Testing services service" including the function "local_testservices_say_hello"
      5. Check that this new service also includes the core_webservice_get_site_info function
      6. Go again to Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions and check that now in the Mobile service you see that new function ("local_testservices_say_hello") too
      7. Edit the local/testservices/db/services.php file and remove the line 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), now bump the local/testservices/version.php number and perform a plugin upgrade in Moodle > Notifications
      8. Go again to Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions and check that now in the Mobile service you DON't see the function "local_testservices_say_hello"
      9. In the same place, open the "Testing services service" and check that the function "local_testservices_say_hello" is listed
      10. Now, create a new service manually, use "barcelona" as shortname, add a couple of core functions to that service
      11. Now, install the attached plugin (local_anothertest).zip and check that
        • A new function "local_anothertest_say_bye" is now listed under the Mobile service
        • A new function "local_anothertest_say_bye" is now listed under the "Testing services"
          service
        • In the service you've created (barcelona) you DON't see the "local_anothertest_say_bye" function (the plugin will try to add the function into the service, but that's not allowed because is a manually created service and the functions injection only works with pre-built services)
      12. Now, edit the local/anothertest/db/services.php file, and from the line: 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE, 'local_testservices', 'barcelona') remove the 'local_testservices service.
      13. Bump the local/anothertest/version.php number, do an upgrade of the plugin and check that:
        • The function "local_anothertest_say_bye" is listed under the Mobile service
        • The function "local_anothertest_say_bye" is NOT listed under the "Testing services"
          service
      14. Once you have finished the previous tests, perform a Moodle clean installation (via browser or CLI) and do the same check that you did in Step 1 and Step 2
      Show
      Do a Moodle upgrade and check in Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions (select the mobile service) display external functions for all the modules supported by the app (forum, glossary, chat, lti imscp, book, url, page, etc.. With the Mobile app check that you can connect successfully and that you can access to those modules in the app. Now, bump the version number in /version.php, do a normal upgrade and check that the app still works and that the all the external functions are still displayed under the Mobile service Install in Moodle the attached plugin (local_testservices.zip), it will install a new service "Testing services service" including the function "local_testservices_say_hello" Check that this new service also includes the core_webservice_get_site_info function Go again to Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions and check that now in the Mobile service you see that new function ("local_testservices_say_hello") too Edit the local/testservices/db/services.php file and remove the line 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE), now bump the local/testservices/version.php number and perform a plugin upgrade in Moodle > Notifications Go again to Site administration ▶︎ Plugins ▶︎ Web services ▶︎ External services ▶︎ Functions and check that now in the Mobile service you DON't see the function "local_testservices_say_hello" In the same place, open the "Testing services service" and check that the function "local_testservices_say_hello" is listed Now, create a new service manually, use "barcelona" as shortname, add a couple of core functions to that service Now, install the attached plugin (local_anothertest).zip and check that A new function "local_anothertest_say_bye" is now listed under the Mobile service A new function "local_anothertest_say_bye" is now listed under the "Testing services" service In the service you've created (barcelona) you DON't see the "local_anothertest_say_bye" function (the plugin will try to add the function into the service, but that's not allowed because is a manually created service and the functions injection only works with pre-built services) Now, edit the local/anothertest/db/services.php file, and from the line: 'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE, 'local_testservices', 'barcelona') remove the 'local_testservices service. Bump the local/anothertest/version.php number, do an upgrade of the plugin and check that: The function "local_anothertest_say_bye" is listed under the Mobile service The function "local_anothertest_say_bye" is NOT listed under the "Testing services" service Once you have finished the previous tests, perform a Moodle clean installation (via browser or CLI) and do the same check that you did in Step 1 and Step 2
    • Affected Branches:
      MOODLE_29_STABLE, MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-50032-master

      Description

      Pre-built services are good, but they have limitations:

      • You cannot add new functions (it will require modify the lib/db/services.php and upgrade the site)
      • You cannot add new functions via add-ons

      We need to allow admins (and plugins) to add and remove existing functions, in this way it will be possible to:

      • Create standard Moodle plugins that add new functions (or remove) to the Mobile service

      For the record, the functionality that finally was implemented was:

      • Add a new attribute "services" in the external functions declaration (/db/services.php file), in this attribute you can now indicate a list of prebuilt services where do you want to add the function.

      In this way, via a contributed plugins you can add external functions to the official mobile service to extends its functionality.
      This also has the advantage that now Moodle plugins are self-containing. The plugins are responsible of adding their functions to the service (previously, the core services had the plugins external functions hardcoded)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16