<< Back
Message for this thread
Posted by Messages text
Kinny

Noavatar
Total post : 39
> Profile
Written on : 06/01/2011 11:58 ( more than one month )
Object : [Docebo 4.0.x] How to create new users and subscribe them to course through api
Hello,

I've created a new topic here because I think this question doesn't belongs to that post http://www.docebo.com/community/doceboCms/forum/9_1/message/idThread_5803-ini_1-result_ok/Rest_API_broke_in_4_0_x%3F.html.

I'd like to create new users and subscribe them to a course directly by api, I don't see how to do it in the api documentation : http://www.docebo.com/community/doceboCms/wiki/129_327/show/english/0/createuser

But I've seen the function CreateUser in api.user.php that course can be assigned (if I understand well the source code)
line 116 :

//apply enroll rules

$enrollrules = new EnrollrulesAlms();

$course_list = $enrollrules->getApplicableRuleForNewUser($userdata['language']);

if(!empty($entities)) {

$course_entity_list = $enrollrules->getApplicableRuleForEntity($entities, $userdata['language']);

$course_list = array_merge($course_list, $course_entity_list);

}

// do the subscription

if(!empty($course_list)) {

 

require_once(_lms_.'/lib/lib.subscribe.php');

$cs = new CourseSubscribe_Management();

$course_list = array_unique($course_list);

$cs->multipleUserSubscribe($user_idst, $course_list, 3);



How I can use or make a subscription to course with api (or with createuser function) ?

Thank you for help :)

Kinny 
 
Kinny

Noavatar
Total post : 39
> Profile
Written on : 12/01/2011 14:46 ( more than one month )
Object : Re: [Docebo 4.0.x] How to create new users and subscribe them to course through api
Hello,

I've found this great powerful feature that is Enrollment rules that subscribe new user to different set of course.

My question is :

Can I use Enrollment rules to cover my needs that is to subscribe automatically new user created by api to some course ?

Thanks for your help,

Kinny 
 
Derks Giovanni

Avatar
Total post : 1861
> Profile
Attachment : file
Object : Re: [Docebo 4.0.x] How to create new users and subscribe them to course through api
Scritto da:: Kinny

I've found this great powerful feature that is Enrollment rules that subscribe new user to different set of course.


Hello,
yes you're right. What it does when you call the createuser method of the api is to check if there are some enrollment rules defined and then it will apply them.

But, after checking the code you copied, we noticed there were a couple of bugs so I'm going to attach you the updated version on this post.

Please note that you'll have to set the "language" parameter when you call the api; this is a new parameter introduced with version 4.0 and it is used to get the enrollment rules.

bye,
Giovanni. 

Docebo Staff
 - Docebo 4 released! -

 
<< Back