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

core_course_get_categories WS is using maxcategorydepth to exclude subcategories.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.1.4, 3.2.1
    • 3.1.3, 3.2
    • Course
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MOODLE_31_STABLE, MOODLE_32_STABLE
    • MDL-57512-master
    • Hide
      1. As an admin create 4 or more categories (one inside the other: so you will have a category in depth level 4).
      2. Remember the PARENT OF THE DEEPEST category Id.
      3. Check maxcategorydepth is set to 2.
      4. Create a user different than admin.
      5. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      6. Create a Token for the created user:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Next, you can do a CURL REST call simulating a WS client with the created user.
        • You need to replace the wstoken, value (with the category id) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'criteria%5B0%5D%5Bkey%5D=id&criteria%5B0%5D%5Bvalue%5D=2&addsubcategories=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_categories&wstoken=936d4adb5f6834727cf952fa2ab92e62' | python -m "json.tool"

      8. Confirm that you can see category you are retrieving and its children in the list.
      Show
      As an admin create 4 or more categories (one inside the other: so you will have a category in depth level 4). Remember the PARENT OF THE DEEPEST category Id. Check maxcategorydepth is set to 2. Create a user different than admin. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the created user: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the created user. You need to replace the wstoken, value (with the category id) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'criteria%5B0%5D%5Bkey%5D=id&criteria%5B0%5D%5Bvalue%5D=2&addsubcategories=1&moodlewssettingfilter=true&moodlewssettingfileurl=true&wsfunction=core_course_get_categories&wstoken=936d4adb5f6834727cf952fa2ab92e62' | python -m "json.tool" Confirm that you can see category you are retrieving and its children in the list.

      Using maxcategorydepth as a way to exclude subcategories is causing that you cannot get subcategories with deeper level also when retrieving a depper category directly.

      IMO this has to be used only if no criteria is used in the parameters.

            pferre22 Pau Ferrer
            pferre22 Pau Ferrer
            Juan Leyva Juan Leyva
            Dan Poltawski Dan Poltawski
            Rajesh Taneja Rajesh Taneja
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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