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

New Web Services for retrieving navigation and administration options available

    XMLWordPrintable

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.1.1
    • 3.2
    • Course, Web Services
    • MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-55415-master
    • Hide
      1. Upgrade Moodle
      2. As admin or manager create a couple of new courses in Moodle
      3. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      4. Create a Token for one user enrolled in the previous course w:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, courseids and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids[0]=4&courseids[1]=11&wsfunction=core_course_get_user_navigation_options&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&moodlewssettingfilter=true' | python -m "json.tool"

      6. Now check that you receive a list of options available in the Moodle web course navigation block, please check that the options that are returned as true by the WS are available in the block and the ones marked as false are not available in the block
      7. You can play with Moodle settings or capabilities to enable / disable options in that block and check that the WS output is updated too with the changes, for example, you can disable blogs or badges at site (or course level for badges)
      8. To check the front-page course, pass as parameter the SITEID course (that is usually 1), the front-page have more navigation options that a regular course
      9. Repeat the previous steps for the administration block, using the wsfunction=core_course_get_user_administration_options
      10. Please note that the frontpage course has less administration options that a regular course.
      11. You can also generate a token for a teacher user to check that you receive extra options that a normal user can't see
      Show
      Upgrade Moodle As admin or manager create a couple of new courses in Moodle As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one user enrolled in the previous course w: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken, courseids and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids [0] =4&courseids [1] =11&wsfunction=core_course_get_user_navigation_options&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&moodlewssettingfilter=true' | python -m "json.tool" Now check that you receive a list of options available in the Moodle web course navigation block, please check that the options that are returned as true by the WS are available in the block and the ones marked as false are not available in the block You can play with Moodle settings or capabilities to enable / disable options in that block and check that the WS output is updated too with the changes, for example, you can disable blogs or badges at site (or course level for badges) To check the front-page course, pass as parameter the SITEID course (that is usually 1), the front-page have more navigation options that a regular course Repeat the previous steps for the administration block, using the wsfunction=core_course_get_user_administration_options Please note that the frontpage course has less administration options that a regular course. You can also generate a token for a teacher user to check that you receive extra options that a normal user can't see

    Description

      After discussing it much (with Dani and Eloy) we think that the new WS names should be:

      • core_course_get_user_administration_options($courseids)
      • core_course_get_user_navigation_options($courseids)

      The new APIs at course/lib.php will be:

      • course_get_user_administration_options($context)
      • course_get_user_navigation_options($context)

      Why we need this new WS?
      Because in the Mobile app we don't have currently a way to know wich options in a course (administration or navigation level) are available for a user.

      The only way to know if something is available for a user is doing a pre-fetch call to the WS and check if is returning errors or not (for example, retrieve the list of participants, the user grade book, the user notes) etc..

      This is causing serious performance and data consumption issues in the app when the user is enrolled in several courses, for 12 courses we are doing like 70 WS calls that we will be able to save with this new web services

      Required core changes

      We'll be refactoring the navigationlib to use this new functions to avoid code duplication (it will be basically moving $CFG and capabilities check to those functions)

      Attachments

        Issue Links

          Activity

            People

              jleyva Juan Leyva
              jleyva Juan Leyva
              Adrian Greeve Adrian Greeve
              Dan Poltawski Dan Poltawski
              Simey Lameze Simey Lameze
              Amaia Anabitarte, Carlos Escobedo, Laurent David, Mikel Martín Corrales, Sabina Abellan, Sara Arjona (@sarjona), Juan Leyva, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                5/Dec/16