Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-29934 Web service API Roadmap
  3. MDL-48730

core_group_get_course_user_groups

XMLWordPrintable

    • MOODLE_28_STABLE
    • MOODLE_29_STABLE
    • MDL-48730-master
    • Hide

      Note: Version number is bumped because a new web service is added into the Mobile app service and also in a component.

      1. Create a course with a teacher and a couple of students and two groups.
      2. Enroll one student in two groups and the other one just in one group
      3. Enable "Mobile services": Plugins ► Web Services ► External services
      4. Create a Token for the teacher and the student enrolled in two groups:
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      5. Next, you can do a couple of CURL REST call simulating a WS client with the teacher and the student user .
        • First call as a teacher replace the token with the teacher one, replace the courseid value and userid should be the user enrolled in two groups
        • Second call as a student (for retrieving your own groups), replace the token with the student one, and userid should be the student userid
        • You also need to replace the wstoken and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache'  -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'courseid=3&userid=4&wsfunction=core_group_get_course_user_groups&wstoken=8fb46895ca29a0f0bdac2395e562fe1d' --compressed
          

      6. Confirm that (you should use jsonlint.com for formatting the output):
        • As a teacher you can see all the student groups
        • As a student, you can see only your own groups
      7. Do additional requests for testing permissions. Like as a student requesting the other user groups (you should get permission exceptions) or the teacher requesting groups for a student in a different course
      Show
      Note: Version number is bumped because a new web service is added into the Mobile app service and also in a component. Create a course with a teacher and a couple of students and two groups. Enroll one student in two groups and the other one just in one group Enable "Mobile services": Plugins ► Web Services ► External services Create a Token for the teacher and the student enrolled in two groups: Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a couple of CURL REST call simulating a WS client with the teacher and the student user . First call as a teacher replace the token with the teacher one, replace the courseid value and userid should be the user enrolled in two groups Second call as a student (for retrieving your own groups), replace the token with the student one, and userid should be the student userid You also need to replace the wstoken and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' -H 'Pragma: no-cache' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' --data 'courseid=3&userid=4&wsfunction=core_group_get_course_user_groups&wstoken=8fb46895ca29a0f0bdac2395e562fe1d' --compressed Confirm that (you should use jsonlint.com for formatting the output): As a teacher you can see all the student groups As a student, you can see only your own groups Do additional requests for testing permissions. Like as a student requesting the other user groups (you should get permission exceptions) or the teacher requesting groups for a student in a different course

      This function should return all the groups of a course where a user is enrolled.

            jleyva Juan Leyva
            jleyva Juan Leyva
            Simey Lameze Simey Lameze
            Andrew Lyons Andrew Lyons
            Zachary Durber Zachary Durber
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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