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

"Missing" API Web Service function: core_cohort_get_all_cohorts

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1
    • 2.7.11, 2.8.9, 2.9.3, 3.0.1
    • Web Services
    • MOODLE_27_STABLE, MOODLE_28_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-52568_master
    • 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.

      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.

            kevin.bruton Kevin Bruton
            kevin.bruton Kevin Bruton
            Mark Nelson Mark Nelson
            Dan Poltawski Dan Poltawski
            Ryan Wyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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