I hope that somebody can give us some ideas. My institution has a Moodle 3.5.3 version. We are trying to use the following method to update the dates of a user enrollment:
This method requires the User enrolment ID as a parameter although there is no method that we can use to retrieve that information.
We want to update the "Enrolment Ends" date field for a student. Are we doing doing something wrong? Can somebody give us some ideas?
Thanks for your help,
Yes, you are on the right track. You can easily update the "Enrolment Ends" date field for your user. The webservice function core_enrol_edit_user_enrolment requires three required parameter - courseid, user enrolments id, enrol status and optional parameters like timestart and timeend (timestamp). You can easily find user enrolment id in Moodle's user_enrolment table. This requires a good knowledge of Mysql queries and Moodle's table. You can apply join of user_enrolments and enrol table.
After getting all required fields you can call webservice like
If you want I will share the required query with you with the help of which you can get user enrolment id.
If you don't want to do this with webservice API function, you can also use moodle's core function update_user_enrol.
Thanks Mayank for the information. Let me explain what we want to achieve and please tell me if you have better ideas.
All of our enrolments are handle by Drupal. So Drupal will follow these steps:
1. call for a specific course the following web service method: core_enrol_get_enrooled_users
This method should return the user enrolment id. With this field, I think we will have enough information to call
Does that make sense? Thanks for your ideas.
I don't think so this method will return enrolment id for the user. It will return enrolled users details like firstname, lastname, profile description and many other details related to users. The details return by this method are
All these details are not required for calling core_enrol_edit_user_enrolment.
Thanks and Regards,