Moodle
  1. Moodle
  2. MDL-15015

Choice, in group mode, does not work with limited choices

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.1
    • Fix Version/s: 1.9.2
    • Component/s: Choice
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      24433

      Description

      In particular, the code for submitting a choice does not use group mode when determining whether the maximum number of choices has been reached. If a choice is limited to 1 it will prevent you from choosing it if 1 person has already chosen it - even if they are in a totally different group.

      The form that shows you options does already work correctly, showing that the choice is 'full' if you select the group where somebody chose it, and showing it as available if you select another group.

      This is critical for a usage in a course here where they want people in each tutor group to pick a subject area for projects (the idea is that everyone in the group does a different part of the issue, so with the whole group together they cover it, I think). As there are hundreds of tutor groups it is a bit of a problem if only one person in one of those groups can choose the option.

      (Wow, choice module is horrific. I do not intend to fix general suckage only this specific issue!)

        Activity

        Hide
        Sam Marshall added a comment -

        I have fixed this issue in MOODLE_19 (tagged merged) + HEAD. The code previously selected all records where users chose this option; now, if groupmode is enabled and a current group is selected, it selects only cases where users who are in the selected group chose this option.

        In addition I made the following changes to that function as tidying-up while I was rewriting it:

        1) Changed variable names (it was horrific, using $countanswers to store the actual answer records and then using it again to be a count of them - I changed this to $answers and $countanswers as a count only).

        2) Improved performance - getting the answer count is hugely performance-intensive, taking many queries (a has_capability) for every user who has selected the choice before. This is improved in two ways, first because we are now only considering users in the same group (when groupmode is on) but also because I made it only get the count if the number of answers is limited, it doesn't need it otherwise.

        OK the performance of saving a new choice is probably not a critical point for most servers. Still every little helps.

        Show
        Sam Marshall added a comment - I have fixed this issue in MOODLE_19 (tagged merged) + HEAD. The code previously selected all records where users chose this option; now, if groupmode is enabled and a current group is selected, it selects only cases where users who are in the selected group chose this option. In addition I made the following changes to that function as tidying-up while I was rewriting it: 1) Changed variable names (it was horrific, using $countanswers to store the actual answer records and then using it again to be a count of them - I changed this to $answers and $countanswers as a count only). 2) Improved performance - getting the answer count is hugely performance-intensive, taking many queries (a has_capability) for every user who has selected the choice before. This is improved in two ways, first because we are now only considering users in the same group (when groupmode is on) but also because I made it only get the count if the number of answers is limited, it doesn't need it otherwise. OK the performance of saving a new choice is probably not a critical point for most servers. Still every little helps.
        Hide
        Dan Marsden added a comment -

        thanks Sam,

        MD and I spent a good chunk of time on choice just before the 1.9 release on performance, so hopefully it's better than it was! - Choice module has never done groups very well - espeically since the limit stuff went in around 1.6 - I thought we'd improved it in 1.9, but obviously we missed this!

        the var names are messy I know! - I keep meaning to tidy them up a bit, - and there are a couple of other outstanding bugs that I really should patch... but finding the time.....

        hopefully it's not all s*it

        Dan

        Show
        Dan Marsden added a comment - thanks Sam, MD and I spent a good chunk of time on choice just before the 1.9 release on performance, so hopefully it's better than it was! - Choice module has never done groups very well - espeically since the limit stuff went in around 1.6 - I thought we'd improved it in 1.9, but obviously we missed this! the var names are messy I know! - I keep meaning to tidy them up a bit, - and there are a couple of other outstanding bugs that I really should patch... but finding the time..... hopefully it's not all s*it Dan
        Hide
        Sam Marshall added a comment -

        Oh I'm sure it's better than before, just that it was really, REALLY bad before.

        (As for performance - really the bad performance when saving a choice didn't matter all that much, we can cope with a few thousand db queries when people save a choice, it doesn't happen that often - that's probably why you didn't get to it before. It looked like the main view-form page wasn't so bad in this area so that's probably what you fixed.)

        Show
        Sam Marshall added a comment - Oh I'm sure it's better than before, just that it was really, REALLY bad before. (As for performance - really the bad performance when saving a choice didn't matter all that much, we can cope with a few thousand db queries when people save a choice, it doesn't happen that often - that's probably why you didn't get to it before. It looked like the main view-form page wasn't so bad in this area so that's probably what you fixed.)

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: