ncstate-delta / moodle-mod_zoom

Moodle plugin for Zoom meeting
https://moodle.org/plugins/mod_zoom
61 stars 108 forks source link

Redefine licenses only from specific Zoom group(s) or exclude specific group(s) #148

Open tsostef opened 4 years ago

tsostef commented 4 years ago

Hi

Is it possible to consider the "redefine licenses" option with only a particular group in Zoom? This would prevent certain users from losing their licenses at times like administrators etc. and the license would be taken only from the group members in Zoom.

Or inverse to be able to exclude specific group from "pool" so that they do not lose their license.

Thank you

jrchamp commented 4 years ago

I'm not advocating for or against this idea, but I would think that Role (where most of the "pool" people are Member) might be better than Group. Not sure if this meets your use case. (Edit: I no longer believe in the Role-based approach.)

tsostef commented 4 years ago

Either Role based or Group based exclusion from the "pool" would be fine for our case. For example our 250 licenses would be allocated as 220 for the pool where all member have to use the plugin in order to get a license and 30 for people that must have a license at all times.

I have seen this posted on the moodle forum as well so I assume that other people must have the same issue like us

tsostef commented 3 years ago

If other users are facing the same issue as my original post, how do you deal with it?

Thanks

lcollong commented 3 years ago

We have the same need. I think "Group" is better than "Role" to exclude/include some users from the pool of "down gradable" ones (set type to basic). First because a user can belong to several groups whereas he can only have one role. Second because it's a hard process to create a new role in Zoom UI as you can't clone it. You need to go through all the params to set them correctly.

As the field "dept" is included in the get_users API call, it would be even easier to check against a free string field set in the plugin configuration (ie "school,teachers") to exclude users having such a string in their "dept" field. This avoid the need to fetch group or role definition to store in the setup. But role_id, and group_ids are also there. So....

The current process is using the last_login field to select the "oldest" user to down grade. But I'm wondering if this field is updated in Zoom when a user create or start a meeting from within Moodle (from the API ) ? Some of our very active users (as hosts or alternative hosts) don't even never connect to their zoom account web site....

jrchamp commented 3 years ago

I agree @lcollong, last_login_time is updated when they log in to the Zoom account, either via the website or another Zoom client. If they are not using the Host features, it is possible that they might not be logging in.

As far as a minimal implementation, it might be as simple as adding an additional requirement to _get_least_recently_active_paid_user_id(): https://github.com/ncstate-delta/moodle-mod_zoom/blob/8203d4718389fbe10775127debf5f02cd3ba5ae7/classes/webservice.php#L401

Example if there's only one , though I think the real group IDs are 22 character strings:

if ($user->type != ZOOM_USER_TYPE_BASIC && !in_array('ABCDEF_123456', $user->group_ids, true) && isset($user->last_login_time)) {

A full implementation would probably need to fetch the list of groups using https://marketplace.zoom.us/docs/api-reference/zoom-api/groups/groups and then allow one or more selections from the list. A cleaner implementation of the code would then be more like:

// Skip basic users.
if ($user->type == ZOOM_USER_TYPE_BASIC) {
    continue;
}

// Skip users in protected groups.
foreach ($protectedgroups as $groupid) {
    if (in_array($groupid, $user->group_ids, true)) {
        continue 2;
    }
}

// Try to pick the least recently active user.
if (isset($user->last_login_time)) {