Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
|
Public Member Functions | |
__construct (int $courseid, ?object $gpr, object $context, int $userid, bool $viewasuser=null) | |
Constructor. | |
fill_contributions_column (array $element) | |
This function is called after the table has been built and the aggregationhints have been collected. | |
fill_table () | |
Provide an entry point to build the table. | |
get_lang_string ($strcode, $section=null) | |
First checks the cached language strings, then returns match if found, or uses get_string() to get it from the DB, caches it then returns it. | |
get_numusers ($groups=true, $users=false) | |
Fetches and returns a count of all the users that will be shown on this page. | |
get_pref ($pref, $objectid=null) | |
Given the name of a user preference (without grade_report_ prefix), locally saves then returns the value of that preference. | |
inject_rowspans (array &$element) | |
Recurse through a tree of elements setting the rowspan property on each element. | |
item_types () | |
Get grade item type names in a course to use in filter dropdown. | |
output_report_zerostate () | |
Build the html for the zero state of the user report. | |
print_table (bool $return=false) | |
Prints or returns the HTML from the flexitable. | |
process_action ($target, $action) | |
Stub function. | |
process_data ($data) | |
Processes the data sent by the form (grades and feedbacks). | |
set_pref ($pref, $pref_value='default', $itemid=null) | |
Uses set_user_preferences() to update the value of a user preference. | |
setup_table () | |
Prepares the headers and attributes of the flexitable. | |
setup_users () | |
Sets up this report's user criteria to restrict the selection of users to display. | |
ungraded_counts () | |
Get ungraded grade items info and sum of all grade items in a course. | |
viewed () | |
Trigger the grade_report_viewed event. | |
Static Public Member Functions | |
static | calculate_average (grade_item $gradeitem, array $info) |
Calculate average grade for a given grade item. | |
static | get_additional_context (context_course $context, int $courseid, array $element, grade_plugin_return $gpr, string $mode, stdClass $templatecontext, bool $otherplugins=false) |
Add additional links specific to plugin. | |
static | get_gradable_users (int $courseid, ?int $groupid=null) |
Load a valid list of gradable users in a course. | |
static | supports_mygrades () |
Shows support for being used as a 'Grades' report. | |
Public Attributes | |
string | $baseurl |
bool | $canviewhidden |
context | $context |
The context. | |
object | $course |
The course. | |
int | $courseid |
The courseid. | |
int | $currentgroup |
The current group being displayed. | |
string | $currentgroupname |
The current groupname being displayed. | |
int | $decimals = 2 |
Decimal points to use for values in the report, default 2. | |
void | $evenodd |
object | $gpr |
Grade plugin return tracking object. | |
string | $gradebookroles |
The roles for this report. | |
array | $gradeitemsdata = [] |
An array containing the grade items data for external usage (web services, ajax, etc...) | |
string | $group_selector |
A HTML select element used to select the current group. | |
int | $groupmode |
Current course group mode $groupmode. | |
void | $gseq |
Flat structure similar to grade tree. | |
grade_tree | $gtree |
The grade tree structure. | |
int | $maxdepth |
int | $page |
Current page (for paging). | |
string | $pbarurl |
array | $prefs = array() |
User preferences related to this report. | |
int | $rangedecimals = 0 |
The number of decimal places to round range to, default 0. | |
false | $showaverage = false |
Show average grades in the report, default false. | |
bool | $showcontributiontocoursetotal = true |
Show the calculated contribution to the course total column. | |
bool | $showfeedback = true |
Show grade feedback in the report, default true. | |
bool | $showgrade = true |
Show grades in the report, default true. | |
void | $showhiddenitems |
Show hidden items even when user does not have required cap. | |
bool | $showlettergrade = false |
Show letter grades in the report, default false. | |
void | $showpercentage |
show grade percentages | |
bool | $showrange = true |
Show range. | |
void | $showrank |
show student ranks | |
array | $showtotalsifcontainhidden = [] |
show course/category totals if they contain hidden items $showtotalsifcontainhidden | |
bool | $showweight = true |
Show grade weighting in the report, default true. | |
string null | $switch |
object | $table |
A flexitable to hold the data. | |
array | $tablecolumns = [] |
An array of table columns. | |
array | $tabledata = [] |
An array containing rows of data for the table. | |
array | $tableheaders = [] |
An array of table headers. | |
stdClass | $user |
To store user data $user. | |
Protected Member Functions | |
blank_hidden_total ($courseid, $course_item, $finalgrade) | |
Optionally blank out course/category totals if they contain any hidden items. | |
blank_hidden_total_and_adjust_bounds ($courseid, $course_item, $finalgrade) | |
Optionally blank out course/category totals if they contain any hidden items. | |
get_sort_arrow (string $direction='down', ?moodle_url $sortlink=null) | |
Returns an arrow icon inside an tag, for the purpose of sorting a column. | |
get_users_search_sql (array $mappings, array $userfields) | |
Prepare SQL where clause and associated parameters for any user searching being performed. | |
setup_groups () | |
Sets up this object's group variables, mainly to restrict the selection of users to display. | |
Protected Attributes | |
array | $aggregationhints = [] |
An array that collects the aggregationhints for every grade_item. | |
string | $groupsql |
An SQL fragment used to add linking information to the group tables. | |
string | $groupwheresql |
An SQL constraint to append to the queries used by this object to build the report. | |
array | $groupwheresql_params = array() |
The ordered params for $groupwheresql $groupwheresql_params. | |
course_modinfo | $modinfo = null |
The modinfo object to be used. | |
string | $preferences_page |
To store a link to preferences page $preferences_page. | |
int int | $userid = -1 |
If the user is wanting to show only one particular user their id will be placed here. | |
string string | $usersearch = '' |
If the user is wanting to search for a particular user within searchable fields their needle will be placed here. | |
string | $userwheresql |
An SQL constraint to append to the queries used by this object to build the report. | |
array | $userwheresql_params = array() |
The ordered params for $userwheresql $userwheresql_params. | |
boolean | $viewasuser = false |
View as user. | |
gradereport_user\report\user::__construct | ( | int | $courseid, |
?object | $gpr, | ||
object | $context, | ||
int | $userid, | ||
bool | $viewasuser = null ) |
Constructor.
Sets local copies of user preferences and initialises grade_tree.
int | $courseid | |
null | object | $gpr | grade plugin return tracking object |
object | $context | |
int | $userid | The id of the user |
bool | $viewasuser | Set this to true when the current user is a mentor/parent of the targetted user. |
|
protectedinherited |
Optionally blank out course/category totals if they contain any hidden items.
string | $courseid | the course id |
string | $course_item | an instance of grade_item |
string | $finalgrade | the grade for the course_item |
string | The new final grade |
|
protectedinherited |
Optionally blank out course/category totals if they contain any hidden items.
string | $courseid | the course id |
string | $course_item | an instance of grade_item |
string | $finalgrade | the grade for the course_item |
array[] | containing values for 'grade', 'grademax', 'grademin', 'aggregationstatus' and 'aggregationweight' |
|
staticinherited |
Calculate average grade for a given grade item.
Based on calculate_averages function from grade/report/user/lib.php
grade_item | $gradeitem | Grade item |
array | $info | Ungraded grade items counts and report preferences. |
array | Average grade and meancount. |
gradereport_user\report\user::fill_contributions_column | ( | array | $element | ) |
This function is called after the table has been built and the aggregationhints have been collected.
We need this info to walk up the list of parents of each grade_item.
array | $element | - An array containing the table data for the current row. |
gradereport_user\report\user::fill_table | ( | ) |
Provide an entry point to build the table.
bool |
|
staticinherited |
Add additional links specific to plugin.
context_course | $context | Course context |
int | $courseid | Course ID |
array | $element | An array representing an element in the grade_tree |
grade_plugin_return | $gpr | A grade_plugin_return object |
string | $mode | Mode (user or grade item) |
stdClass | $templatecontext | Template context |
bool | $otherplugins | If we need to insert links to other plugins |
?stdClass | Updated template context |
|
staticinherited |
Load a valid list of gradable users in a course.
int | $courseid | The course ID. |
int | null | $groupid | The group ID (optional). |
array | A list of enrolled gradable users. |
|
inherited |
First checks the cached language strings, then returns match if found, or uses get_string() to get it from the DB, caches it then returns it.
string | $strcode | |
string | $section | Optional language section |
string |
|
inherited |
Fetches and returns a count of all the users that will be shown on this page.
boolean | $groups | include groups limit |
boolean | $users | include users limit - default false, used for searching purposes |
int | Count of users |
|
inherited |
Given the name of a user preference (without grade_report_ prefix), locally saves then returns the value of that preference.
If the preference has already been fetched before, the saved value is returned. If the preference is not set at the User level, the $CFG equivalent is given (site default). Can be called statically, but then doesn't benefit from caching
string | $pref | The name of the preference (do not include the grade_report_ prefix) |
int | $objectid | An optional itemid or categoryid to check for a more fine-grained preference |
mixed | The value of the preference |
|
protectedinherited |
Returns an arrow icon inside an tag, for the purpose of sorting a column.
string | $direction | |
moodle_url | null | $sortlink |
|
protectedinherited |
Prepare SQL where clause and associated parameters for any user searching being performed.
This mostly came from core_user\table\participants_search with some slight modifications four our use case.
array | $mappings | Array of field mappings (fieldname => SQL code for the value) |
array | $userfields | An array that we cast from user profile fields to search within. |
array | SQL query data in the format ['where' => '', 'params' => []]. |
gradereport_user\report\user::inject_rowspans | ( | array & | $element | ) |
Recurse through a tree of elements setting the rowspan property on each element.
array | $element | Either the top element or, during recursion, the current element |
int | The number of elements processed |
|
inherited |
Get grade item type names in a course to use in filter dropdown.
array | Item types. |
gradereport_user\report\user::output_report_zerostate | ( | ) |
Build the html for the zero state of the user report.
string | HTML to display |
gradereport_user\report\user::print_table | ( | bool | $return = false | ) |
Prints or returns the HTML from the flexitable.
bool | $return | Whether or not to return the data instead of printing it directly. |
string|void |
gradereport_user\report\user::process_action | ( | $target, | |
$action ) |
Stub function.
string | $target | |
string | $action |
void |
Reimplemented from grade_report.
gradereport_user\report\user::process_data | ( | $data | ) |
Processes the data sent by the form (grades and feedbacks).
array | $data | Take in some data to provide to the base function. |
void | Success or Failure (array of errors). |
Reimplemented from grade_report.
|
inherited |
Uses set_user_preferences() to update the value of a user preference.
If 'default' is given as the value, the preference will be removed in favour of a higher-level preference.
string | $pref | The name of the preference. |
mixed | $pref_value | The value of the preference. |
int | $itemid | An optional itemid to which the preference will be assigned |
bool | Success or failure. |
|
protectedinherited |
Sets up this object's group variables, mainly to restrict the selection of users to display.
Reimplemented in gradereport_singleview\report\singleview.
|
staticinherited |
Shows support for being used as a 'Grades' report.
Reimplemented in grade_report_overview.
|
inherited |
Get ungraded grade items info and sum of all grade items in a course.
Based on calculate_averages function from grade/report/user/lib.php
array | Ungraded grade items counts with report preferences. |
gradereport_user\report\user::viewed | ( | ) |
Trigger the grade_report_viewed event.
|
protected |
An array that collects the aggregationhints for every grade_item.
The hints contain grade, grademin, grademax status, weight and parent.
|
inherited |
The context.
$context
|
inherited |
The course.
$course
|
inherited |
The courseid.
$courseid
|
inherited |
The current group being displayed.
$currentgroup
|
inherited |
The current groupname being displayed.
$currentgroupname
|
inherited |
Grade plugin return tracking object.
$gpr
|
inherited |
The roles for this report.
$gradebookroles
|
inherited |
A HTML select element used to select the current group.
$group_selector
|
protectedinherited |
An SQL fragment used to add linking information to the group tables.
$groupsql
|
protectedinherited |
An SQL constraint to append to the queries used by this object to build the report.
$groupwheresql
|
inherited |
Current page (for paging).
$page
|
inherited |
User preferences related to this report.
$prefs
object gradereport_user\report\user::$table |
A flexitable to hold the data.
$table
|
protectedinherited |
If the user is wanting to show only one particular user their id will be placed here.
$userid
|
protectedinherited |
If the user is wanting to search for a particular user within searchable fields their needle will be placed here.
$usersearch
|
protectedinherited |
An SQL constraint to append to the queries used by this object to build the report.
$userwheresql
|
protected |
View as user.
When this is set to true, the visibility checks, and capability checks will be applied to the user whose grades are being displayed. This is very useful when a mentor/parent is viewing the report of their mentee because they need to have access to the same information, but not more, not less.