Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

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

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.

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).
return: moodle_recordset

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

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

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

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

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.

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

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.

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
return: array SQL query data in the format ['joins' => [], 'where' => '', 'params' => [], 'forcestatus' => true]

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.

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

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.

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