Skip to content

Conversation

@mi-dave
Copy link

@mi-dave mi-dave commented Jul 11, 2024

In Site administration > Plugins > Grouptool > Default instance settings, I have both of these filled in with non-zero values (1 and 5, respectively).

However, when I go to Add an activity or resource > Grouptool, the "limit" checkboxes next to both of these fields are unticked. Despite that, the correct values are displayed in the disabled input fields:

image

I tracked the cause down to mod_grouptool_mod_form::data_preprocessing(). At first glance, this code looks like it should tick both boxes:

        if (array_key_exists('users_queues_limit', $defaultvalues) && ($defaultvalues['users_queues_limit'] > 0)) {
            $defaultvalues['limit_users_queues'] = 1;
        } else {
            $defaultvalues['limit_users_queues'] = 0;
        }
        if (array_key_exists('groups_queues_limit', $defaultvalues) && ($defaultvalues['groups_queues_limit'] > 0)) {
            $defaultvalues['limit_groups_queues'] = 1;
        } else {
            $defaultvalues['limit_groups_queues'] = 0;
        }

However, it doesn't work for newly created activities because $defaultvalues only contains a subset of the fields at this point, not all of the defaults set in the admin area, so it is always set to 0 for new activities. I have changed it to this:

        if (array_key_exists('users_queues_limit', $defaultvalues)) {
            $defaultvalues['limit_users_queues'] = $defaultvalues['users_queues_limit'] > 0 ? 1 : 0;
        }
        if (array_key_exists('groups_queues_limit', $defaultvalues)) {
            $defaultvalues['limit_groups_queues'] = $defaultvalues['groups_queues_limit'] > 0 ? 1 : 0;
        }

So it only overrides the defaults set in mod_grouptool_mod_form::definition() when a different value is provided - i.e. when editing an existing activity.

@nolowolf
Copy link

Dear @mi-dave this is the intended behaviour. the admin settings are shown correctly. when a user wants to change the default limit, he ticks the boxes and can then set the new limit

@nolowolf
Copy link

I see - so there's no way to have them actually be the default values, enabled by default? Confusing, but I'll stick with my forked version then. Thanks!

i see what you mean now - sorry bout that - it´s actually not intended to do so. i will get back to you

@mi-dave
Copy link
Author

mi-dave commented Jun 23, 2025

(For the record, I posted the comment you quoted above with the wrong account, then realised and deleted it, but hadn't reposted it yet as I was double-checking my understanding.)

Thanks 🙂

@nolowolf
Copy link

(For the record, I posted the comment you quoted above with the wrong account, then realised and deleted it, but hadn't reposted it yet as I was double-checking my understanding.)

Thanks 🙂

so is it that you want to have the admin setting activated when creating a grouptool? this can be done in the site administration setting "use group size".
if it´s not checked by default, and the trainer doesn´t check it either, the limits won´t be executed.

@mi-dave
Copy link
Author

mi-dave commented Jun 30, 2025

so is it that you want to have the admin setting activated when creating a grouptool? this can be done in the site administration setting "use group size".

I would like "Limit" to be ticked by default for "Queue places per user/group" when a new Grouptool instance is created. I already have "Use group size" ticked, and default limits set in the admin settings:

{A25908C3-988B-4E40-BA2C-578326090177}

But the limits are not enabled by default when creating a new instance:

{7BCE83FB-FB0D-43A8-A09E-4A903C532A91}

Note: I renamed "Queues" to "Waiting lists" in the language settings so some strings don't match the defaults.

(Tested with v4.3.1 because we haven't upgraded Moodle to 4.5 yet.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants