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

New Web Service core_user_get_user_preferences

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      2. Create a Token for one user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_get_user_preferences&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"

      4. Check that you have retrieved all the preferences presents in the user_preferences table for the current user
      5. Now, append to the parameter list a new parameter name=XYZ where XYZ is a preference returned in the previous steps.
      6. Check that now you receive only the value for that preference
      7. Now, try to retrieve a preference that does not exist, you should get a null value
      8. Now, create a token for an admin user
      9. Run the query again using that token passing as an additional parameter userid=X where X is the value of the user you did you first test with.
      10. Check that as an admin you can retrieve the settings for any user
      11. Now, create a token for another user (not admin) and check that you cannot retrieve settings from other users
      Show
      As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for one user: 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, and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_get_user_preferences&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool" Check that you have retrieved all the preferences presents in the user_preferences table for the current user Now, append to the parameter list a new parameter name=XYZ where XYZ is a preference returned in the previous steps. Check that now you receive only the value for that preference Now, try to retrieve a preference that does not exist, you should get a null value Now, create a token for an admin user Run the query again using that token passing as an additional parameter userid=X where X is the value of the user you did you first test with. Check that as an admin you can retrieve the settings for any user Now, create a token for another user (not admin) and check that you cannot retrieve settings from other users
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55266-master

      Description

      It will return the user Moodle preferences

      Parameters:

      name - Preference name, optional, default to retrieve all preferences
      userid - The user to retrieve the preferences from, optional, default to current user

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Jake Dallimore
              Integrator:
              Andrew Nicols
              Tester:
              Andrew Nicols
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Juan Leyva, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona)
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                5/Dec/16