Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-48625

Function to filter list of users who can see the activity

    XMLWordPrintable

    Details

      Description

      Need a function that would reliably return the list of users who are able to see a particular activity.

      \core_availability\info_module::filter_user_list() is not enough because it does not take into account permissions

      How to get the list of users who can see a particular activity:

      1. For the normal course without guest access - take the list of enrolled users; otherwise take the list of all users
      2. If the course is not visible, filter out users without capability 'moodle/course:viewhidden' in the course context
      3. If the activity is hidden filter out users without capability 'moodle/course:viewhiddenactivities' in the module context
      4. If the capability 'mod/xxx:view' exist (xxx is the module type), filter out users without this capability in the module context
      5. If conditional availability is enabled users must either have capability 'moodle/course:viewhiddenactivities' in the module context or satisfy with conditions; method to filter list of users by conditional access is \core_availability\info_module::filter_user_list() (MDL-48660 is created to allow filter_user_list() take into account this cap)

      Also the potential function should take additional filtering arguments $withcapability, $groupid as well as output arguments: $userfields, $orderby (will be especially great if it can also allow pagination).

      Other problems that I foresee are:

      • should we always hide suspended enrolments or have an argument for them?
      • should we always filter by conditional access or have an argument for it? I imagine it will be interesting to respect group condition but ignore other-activity-completion-or-grade condition, what to do in this case?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                marina Marina Glancy
                Participants:
                Component watchers:
                Sam Marshall, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Damyon Wiese, Adrian Greeve, Mihail Geshoski, Peter Dias, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: