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

New Web Service core_user_get_user_preferences

XMLWordPrintable

    • MOODLE_31_STABLE
    • MOODLE_32_STABLE
    • MDL-55266-master
    • 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

      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

            jleyva Juan Leyva
            jleyva Juan Leyva
            Jake Dallimore Jake Dallimore
            Andrew Lyons Andrew Lyons
            Andrew Lyons Andrew Lyons
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.