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

core_course_get_categories WS is using maxcategorydepth to exclude subcategories.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.3, 3.2
    • Fix Version/s: 3.1.4, 3.2.1
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE, MOODLE_32_STABLE
    • Pull Master Branch:
      MDL-57512-master

      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

              • Assignee:
                pferre22 Pau Ferrer
                Reporter:
                pferre22 Pau Ferrer
                Peer reviewer:
                Juan Leyva
                Integrator:
                Dan Poltawski
                Tester:
                Rajesh Taneja
                Participants:
                Component watchers:
                Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  9/Jan/17