Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

Definition of the grader report class

Copyright: 2007 Nicolas Connault
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 2018 lines (91 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class


Class: grade_report_grader  - X-Ref

Class providing an API for the grader report building and displaying.

__construct($courseid, $gpr, $context, $page=null, $sortitemid=null)   X-Ref
Constructor. Sets local copies of user preferences and initialises grade_tree.

param: int $courseid
param: object $gpr grade plugin return tracking object
param: string $context
param: int $page The current page being viewed (when report is paged)
param: int $sortitemid The id of the grade_item by which to sort the table

process_data($data)   X-Ref
Processes the data sent by the form (grades and feedbacks).
Caller is responsible for all access control checks

param: array $data form submission (with magic quotes)
return: array empty array if success, array of warnings if something fails.

setup_sortitemid()   X-Ref
Setting the sort order, this depends on last state
all this should be in the new table class that we might need to use
for displaying grades.


load_users()   X-Ref
pulls out the userids of the users to be display, and sorts them


get_allgradeitems()   X-Ref
Load all grade items.


load_final_grades()   X-Ref
we supply the userids in this query, and get all the grades
pulls out all the grades, this does not need to worry about paging


get_toggles_html()   X-Ref
Gets html toggle


print_toggle($type)   X-Ref
Prints html toggle

param: unknown $type

get_left_rows($displayaverages)   X-Ref
Builds and returns the rows that will make up the left part of the grader report
This consists of student names and icons, links to user reports and id numbers, as well
as header cells for these columns. It also includes the fillers required for the
categories displayed on the right side of the report.

param: boolean $displayaverages whether to display average rows in the table
return: array Array of html_table_row objects

get_right_rows($displayaverages)   X-Ref
Builds and returns the rows that will make up the right part of the grader report

param: boolean $displayaverages whether to display average rows in the table
return: array Array of html_table_row objects

get_grade_table($displayaverages = false)   X-Ref
Depending on the style of report (fixedstudents vs traditional one-table),
arranges the rows of data in one or two tables, and returns the output of
these tables in HTML

param: boolean $displayaverages whether to display average rows in the table
return: string HTML

get_left_icons_row($rows=array()   X-Ref
Builds and return the row of icons for the left side of the report.
It only has one cell that says "Controls"

param: array $rows The Array of rows for the left part of the report
param: int $colspan The number of columns this cell has to span
return: array Array of rows for the left part of the report

get_left_range_row($rows=array()   X-Ref
Builds and return the header for the row of ranges, for the left part of the grader report.

param: array $rows The Array of rows for the left part of the report
param: int $colspan The number of columns this cell has to span
return: array Array of rows for the left part of the report

get_left_avg_row($rows=array()   X-Ref
Builds and return the headers for the rows of averages, for the left part of the grader report.

param: array $rows The Array of rows for the left part of the report
param: int $colspan The number of columns this cell has to span
param: bool $groupavg If true, returns the row for group averages, otherwise for overall averages
return: array Array of rows for the left part of the report

get_right_icons_row($rows=array()   X-Ref
Builds and return the row of icons when editing is on, for the right part of the grader report.

param: array $rows The Array of rows for the right part of the report
return: array Array of rows for the right part of the report

get_right_range_row($rows=array()   X-Ref
Builds and return the row of ranges for the right part of the grader report.

param: array $rows The Array of rows for the right part of the report
return: array Array of rows for the right part of the report

get_right_avg_row($rows=array()   X-Ref
Builds and return the row of averages for the right part of the grader report.

param: array $rows Whether to return only group averages or all averages.
param: bool $grouponly Whether to return only group averages or all averages.
return: array Array of rows for the right part of the report

get_course_header($element)   X-Ref
Given element category, create a collapsible icon and
course header.

param: array $element
return: string HTML

get_icons($element)   X-Ref
Given a grade_category, grade_item or grade_grade, this function
figures out the state of the object and builds then returns a div
with the icons needed for the grader report.

param: array $element
return: string HTML

get_collapsing_icon($element)   X-Ref
Given a category element returns collapsing +/- icon if available


process_action($target, $action)   X-Ref
Processes a single action against a category, grade_item or grade.

param: string $target eid ({type}{id}, e.g. c4 for category4)
param: string $action Which action to take (edit, delete etc...)
return:

filter_collapsed_categories($courseid, $collapsed)   X-Ref
From the list of categories that this user prefers to collapse choose ones that belong to the current course.

This function serves two purposes.
Mainly it helps migrating from user preference style when all courses were stored in one preference.
Also it helps to remove the settings for categories that were removed if the array for one course grows too big.

param: int $courseid
param: array $collapsed
return: array

get_collapsed_preferences($courseid)   X-Ref
Returns the list of categories that this user wants to collapse or display aggregatesonly

This method also migrates on request from the old format of storing user preferences when they were stored
in one preference for all courses causing DB error when trying to insert very big value.

param: int $courseid
return: array

set_collapsed_preferences($courseid, $collapsed)   X-Ref
Sets the list of categories that user wants to see collapsed in user preferences

This method may filter or even trim the list if it does not fit in DB field.

param: int $courseid
param: array $collapsed

do_process_action($target, $action, $courseid = null)   X-Ref
Processes a single action against a category, grade_item or grade.

param: string $target eid ({type}{id}, e.g. c4 for category4)
param: string $action Which action to take (edit, delete etc...)
param: int $courseid affected course.
return:

get_sort_arrows(array $extrafields = array()   X-Ref
Refactored function for generating HTML of sorting links with matching arrows.
Returns an array with 'studentname' and 'idnumber' as keys, with HTML ready
to inject into a table header cell.

param: array $extrafields Array of extra fields being displayed, such as
return: array An associative array of HTML sorting links+arrows

get_students_per_page()   X-Ref
Returns the maximum number of students to be displayed on each page

return: int The maximum number of students to display per page