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

core_course_get_categories WS is using maxcategorydepth to exclude subcategories.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.1.3, 3.2
    • 3.1.4, 3.2.1
    • 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.

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              pferre22 Pau Ferrer
              pferre22 Pau Ferrer
              Juan Leyva Juan Leyva
              Dan Poltawski Dan Poltawski
              Rajesh Taneja Rajesh Taneja
              Amaia Anabitarte, Carlos Escobedo, Laurent David, Mikel Martín Corrales, Sabina Abellan, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                9/Jan/17