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

"Missing" API Web Service function: core_cohort_get_all_cohorts

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.7.11, 2.8.9, 2.9.3, 3.0.1
    • Fix Version/s: 3.1
    • Component/s: Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a bunch of cohorts.
      2. As an admin visit 'Plugins' > 'Web Services' > 'Overview' and follow the required steps:
      3. Create a new Web Service
      4. Add the core_cohort_get_cohorts function
      5. Create a token for a user.
      6. Next you will have to do a CURL REST call simulating a WS client with one of the users - example:

        curl '<yoursite>/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_cohort_get_cohorts&wstoken=<yourtoken>' | python -m "json.tool"

      7. Do the corresponding web service API call to core_cohort_get_cohorts without parameters, checking that all cohorts are returned.
      8. Do the corresponding web service API call to core_cohort_get_cohorts with one or several cohort ids as parameters, to check that the "old" functionality of this function still works as expected.
      Show
      Create a bunch of cohorts. As an admin visit 'Plugins' > 'Web Services' > 'Overview' and follow the required steps: Create a new Web Service Add the core_cohort_get_cohorts function Create a token for a user. Next you will have to do a CURL REST call simulating a WS client with one of the users - example: curl '<yoursite>/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=core_cohort_get_cohorts&wstoken=<yourtoken>' | python -m "json.tool" Do the corresponding web service API call to core_cohort_get_cohorts without parameters, checking that all cohorts are returned. Do the corresponding web service API call to core_cohort_get_cohorts with one or several cohort ids as parameters, to check that the "old" functionality of this function still works as expected.
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull Master Branch:
      MDL-52568_master

      Description

      Surprisingly there doesn´t seem to be a way to get a list of all the cohorts in the system.
      The present function core_cohort_get_cohorts requires you to know previously de ids of the cohorts you want to get.

      A function has been offered to cover this need http://stackoverflow.com/questions/31592674/moodle-api-list-all-cohorts, but I believe this should be included in Moodle Core.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    23/May/16