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

Add a method to unset user preferences

XMLWordPrintable

    • MOODLE_36_STABLE
    • MOODLE_36_STABLE
    • MDL-63929-master
    • Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a Token in the mobile app service for any user in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      3. Now, Log-out and as the user you created the token for, log in into the Moodle site
      4. "Hide from view" any of the courses displayed in the Dashboard (Course overview), please, annotate the id of the course you just hide.
      5. Refresh the page and check that the hidden course is displayed only when selecting the "Hidden" option in the "Course overview" filter.
      6. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours, replace the "X" in "block_myoverview_hidden_course_X" with the id of the course you annotated.

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_user_preferences&wstoken=3af67232a7596ceb658df4db329e5ad6&preferences[0][type]=block_myoverview_hidden_course_X' | python -m "json.tool"

      7. Go back to the browser, access the site as the user you created the token for, and check that the course you hide is not hidden any more and you can see it when you select the "All" option in the "Course overview" filter
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a Token in the mobile app service for any user in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Now, Log-out and as the user you created the token for, log in into the Moodle site "Hide from view" any of the courses displayed in the Dashboard (Course overview), please, annotate the id of the course you just hide. Refresh the page and check that the hidden course is displayed only when selecting the "Hidden" option in the "Course overview" filter. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours, replace the "X" in "block_myoverview_hidden_course_X" with the id of the course you annotated. curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_user_update_user_preferences&wstoken=3af67232a7596ceb658df4db329e5ad6&preferences [0] [type] =block_myoverview_hidden_course_X' | python -m "json.tool" Go back to the browser, access the site as the user you created the token for, and check that the course you hide is not hidden any more and you can see it when you select the "All" option in the "Course overview" filter

      To hide and unhide a course the user preferrence block_myoverview_hidden_course_COURSEID is set or unset. There's no way to unset the param using WS.

      There are two ways to solve that:

      1. Add a new WS to unset a user preference.
      2. Admit some value into the update user preference WS to unset it (i.e. false).

      In addittion course overview block should consider values 0 or false as not hidden course here.

       

            jleyva Juan Leyva
            pferre22 Pau Ferrer
            Pau Ferrer Pau Ferrer
            Eloy Lafuente (stronk7) Eloy Lafuente (stronk7)
            Jennifer Bauzon Jennifer Bauzon
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 30 minutes
                1h 30m

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