Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

Determining Cohorts that a User is a Member Of (Webservices)

$
0
0
by Scott Hardwick.  

After researching the Moodle webservices, I can not seem to find one that will return a listing of what cohorts a given user is a member of. Am I missing something? We can use core_cohort_get_cohort_members to get the members for a specific cohort, but it wouldn't be very efficient to have to get the membership of all cohorts, and then parse through it looking for a single user.

It appears we currently have:

2.4 - core_cohort_get_cohorts
2.4 - core_cohort_create_cohorts
2.4 - core_cohort_update_cohorts
2.4 - core_cohort_delete_cohorts

2.4 - core_cohort_get_cohort_members
2.4 - core_cohort_add_cohort_members
2.4 - core_cohort_delete_cohort_members

In essence I am looking for a webservices wrapper for SQL similar to:

SELECT u.id,u.username, u.firstname, u.lastname, hm.cohortid, h.idnumber, h.name
FROM prefix_cohort AS h
JOIN prefix_cohort_members AS hm ON h.id = hm.cohortid
JOIN prefix_user AS u ON hm.userid = u.id
WHERE u.id='insert moodle userid'

SELECT u.id, u.username, u.firstname, u.lastname, hm.cohortid, h.idnumber, h.name
FROM prefix_cohort AS h
JOIN prefix_cohort_members AS hm ON h.id = hm.cohortid
JOIN prefix_user AS u ON hm.userid = u.id
WHERE u.username='insert username'

I guess it could also be argued that maybe this information should be returned as part of:
2.5 - core_user_get_users_by_field

Thanks for any thoughts you might have!


Viewing all articles
Browse latest Browse all 2361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>