Get users for a course using OK Tech WS

Get users for a course using OK Tech WS

by Scott Hooper -
Number of replies: 1

Can anybody suggest a method of obtaining a list of users enrolled in a course via OK Tech WS? I can see the function get_users_bycourse(), but I can't figure out the parameters. It calls for client, session, courseID, id field and idrole. The first three are self explanatory, but I have no idea on the last two. I'm using ASP.Net

The OK Tech WS service is fantastic and I have achieved so much with it, but I wish there were a comprehensive set of examples somewhere. Big shout out to the developers though. Nice work!

Average of ratings: -
In reply to Scott Hooper

Re: Get users for a course using OK Tech WS

by Patrick Pollet -

Hi,

   Have a look to the comments at the top of every function declared in mdl_baseserver.class.php .See https://github.com/patrickpollet/moodlews/blob/master/wspp/mdl_baseserver.class.php if you do not have access to source code 

   Every time OK Tech request an entity identifier xxxxid (ie course, user, group,grouping...) you have the choice of the field used to uniquely identify the entity that is the purpose of the parameter idfield . 'idnumber' is almost always used as default value if absent 

   For a course it can be the Moodle id, the id number or the short name 

   for an user it can be an username, id, idnumber, email 

  for a group it can be id or name 

  ...

Thus get_users_bycourse() can be called with

get_users_bycourse($client,$sess, 46,'id' ... 

or 

get_users_bycourse($client,$sess, 'CHEM 101,'shortname' ... 

 or

get_users_bycourse($client,$sess, 46,'AZ123' ,'idnumber' ...   

 

The optional roleid parameter can be used to filter out users by role as they are declared in table mdl_role (1=admin, 2 creator, 3=teacher ...) 

Cheers.