Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Queue places per user" and "Queue places per group" defaults not being applied when creating a new activity #37

Open
wants to merge 1 commit into
base: MOODLE_403_STABLE
Choose a base branch
from

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.

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.

1 participant