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

New Web Service core_user_set_users_preferences

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.2
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. As admin, create a new external service which includes core_user_set_users_preferences
      2. Create a Token for a site admin 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, USERID with the admin user id and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_set_user_preferences&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preferences[0][name]=calendar_maxevents&preferences[0][value]=4&preferences[0][userid]=USERID' | python -m "json.tool"

      4. Check that you don't see any warnings
      5. Open the user_preferences table in Moodle, and check that the calendar_maxevents is set to 4 for the user used in step 2
      6. You can try to set a preference for a different user using an authenticated user, you should get a exception in this case
      7. If you try to set a preference for an invalid or non-existent user you will get a warning
      Show
      As admin, create a new external service which includes core_user_set_users_preferences Create a Token for a site admin 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, USERID with the admin user id and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_set_user_preferences&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preferences [0] [name] =calendar_maxevents&preferences [0] [value] =4&preferences [0] [userid] =USERID' | python -m "json.tool" Check that you don't see any warnings Open the user_preferences table in Moodle, and check that the calendar_maxevents is set to 4 for the user used in step 2 You can try to set a preference for a different user using an authenticated user, you should get a exception in this case If you try to set a preference for an invalid or non-existent user you will get a warning
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-55347-master

      Description

      Given an array of:

      • preference name
      • preference value
      • user (optional)

      This WS will set the preferences

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

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