Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

Class used to fetch participants based on a filterset.

Copyright: 2020 Michael Hawkins <michaelh@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1108 lines (46 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: participants_search  - X-Ref

Class used to fetch participants based on a filterset.

__construct(stdClass $course, context $context, filterset $filterset)   X-Ref
Class constructor.

param: stdClass $course The course being searched.
param: context $context The context of the search.
param: filterset $filterset The filterset used to filter the participants in a course.

get_participants(string $additionalwhere = '', array $additionalparams = [], string $sort = '',int $limitfrom = 0, int $limitnum = 0)   X-Ref
Fetch participants matching the filterset.

return: moodle_recordset
param: string $additionalwhere Any additional SQL to add to where.
param: array $additionalparams The additional params used by $additionalwhere.
param: string $sort Optional SQL sort.
param: int $limitfrom Return a subset of records, starting at this point (optional).
param: int $limitnum Return a subset comprising this many records (optional, required if $limitfrom is set).

get_total_participants_count(string $additionalwhere = '', array $additionalparams = [])   X-Ref
Returns the total number of participants for a given course.

return: int
param: string $additionalwhere Any additional SQL to add to where.
param: array $additionalparams The additional params used by $additionalwhere.

get_participants_sql(string $additionalwhere, array $additionalparams)   X-Ref
Generate the SQL used to fetch filtered data for the participants table.

return: array
param: string $additionalwhere Any additional SQL to add to where
param: array $additionalparams The additional params

get_enrolled_sql()   X-Ref
Prepare SQL and associated parameters for users enrolled in the course.

return: array SQL query data in the format ['sql' => '', 'forcedsql' => '', 'params' => []].

get_enrol_method_sql($useridcolumn)   X-Ref
Prepare the enrolment methods filter SQL content.

return: array SQL query data in the format ['joins' => [], 'where' => '', 'params' => []].
param: string $useridcolumn User ID column used in the calling query, e.g. u.id

get_status_sql($filteruidcolumn, $forceduidcolumn, $forcedprefix)   X-Ref
Prepare the status filter SQL content.
Note: Users who cannot view suspended users will always have their results filtered to only show active participants.

return: array SQL query data in the format ['joins' => [], 'where' => '', 'params' => [], 'forcestatus' => true]
param: string $filteruidcolumn User ID column used in the calling query, e.g. eu_u.id
param: string $forceduidcolumn User ID column used in any forced query, e.g. feu_u.id
param: string $forcedprefix The prefix to use if forced filtering is required

get_groups_jointype(?int $forcedjointype = null)   X-Ref
Fetch the groups filter's grouplib jointype, based on its filterset jointype.
This mapping is to ensure compatibility between the two, should their values ever differ.

return: int
param: int|null $forcedjointype If set, specifies the join type to fetch mapping for (used when applying forced filtering).

get_roles_sql()   X-Ref
Prepare SQL where clause and associated parameters for any roles filtering being performed.

return: array SQL query data in the format ['where' => '', 'params' => []].

get_country_sql()   X-Ref
Prepare SQL where clause and associated parameters for country filtering

return: array SQL query data in the format ['where' => '', 'params' => []].

get_keywords_search_sql(array $mappings)   X-Ref
Prepare SQL where clause and associated parameters for any keyword searches being performed.

return: array SQL query data in the format ['where' => '', 'params' => []].
param: array $mappings Array of field mappings (fieldname => SQL code for the value)