Automating change of users roles in specific courses for a specific time

Automating change of users roles in specific courses for a specific time

by Anwesh Mishra -
Number of replies: 2

Hi,

Need to automate a process by which the role of  some users enrolled in specific courses can be changed for a specific amount of time?

For example, for 15 days, user named A who is a student in a course will have Admin role in that specific course / courses and then after 15 days, will be reverted back to being a student.

 

This needs to be done to an entire list of students automatically through some code. How do i go about writing this code? Or is there a plugin already that allows me to do this?

Can anyone please suggest where do i start from or how do i go about this? Any links will also be appreciated.

Average of ratings: -
In reply to Anwesh Mishra

Re: Automating change of users roles in specific courses for a specific time

by Mark Johnson -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You might want to look at flatfile enrolments, you could either write a small routine to generate the required flatfiles to enrol/unenrol and generate them as required, or use the plugin's code as an example of how to automate enrolments.

In reply to Mark Johnson

Re: Automating change of users roles in specific courses for a specific time

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Either that, or you could use the DB enrolment plugin in the same way.

Or you could write a custom enrolment plugin that does exactly what you want.

Documentation seems to be in enrol/README.txt in the code.