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

              Unassigned Unassigned
              marina Marina Glancy
              Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Raquel Ortega, Sabina Abellan, Sara Arjona (@sarjona), Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Raquel Ortega, Sabina Abellan, Sara Arjona (@sarjona), Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Raquel Ortega, Sabina Abellan, Sara Arjona (@sarjona), Adrian Greeve, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie, Tim Hunt, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Kevin Percy, Laurent David, Mathew May, Mihail Geshoski, Raquel Ortega, Sabina Abellan, Sander Bangma, Sara Arjona (@sarjona), Shamim Rezaie
              Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: