Set a cap for users in a cohort/group

Set a cap for users in a cohort/group

by Florian Eberhardt -
Number of replies: 2

Hello,

is there a way to set a cap for users in a cohort or a group? 

To understand my needs: 
We produce eLearnings which we'd like to sell to our customers. Because these are usually companies, they buy multiple licenses to our eLearning courses. In this context the email domain of the customers company is activated for creating an account in moodle. When creating an account they're automatically addet to a corresponding cohort. 

To cap the number of accounts per company, I need a way to set the maximum size of a cohort. If there is no way to handle it like this, I could possibly group the users within a course. Anyway I need a restriction to a maximum number of group members.


Average of ratings: -
In reply to Florian Eberhardt

Re: Set a cap for users in a cohort/group

by Dominique Palumbo -
Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

The only way I see to do it it's to modify the core. But as everyone know it's a bad practise.
For cohort you can put your logic here ->function cohort_add_member($cohortid, $userid)
For group you can put your logic here ->function groups_add_member($grouporid, $userorid, $component=null, $itemid=0)

I don't see if a hook or a plugin can do it. That will be a far better solution. Or if you can externalize the management of your cohorts and groups and use web services.

Dominique.
In reply to Dominique Palumbo

Re: Set a cap for users in a cohort/group

by Florian Eberhardt -
Hey Dominique,

I almost thought so. Anyways, thank you for your response and help.

Florian