Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Files | Namespaces | Classes | Functions | Variables
core_grades

Files

file  advancedgrading_mapping.php
 Grade item, itemnumber mapping.
 
file  behat_grade.php
 Behat grade related steps definitions.
 
file  calculation_form.php
 A moodleform to allow the editing of a calculated grade item.
 
file  category_form.php
 A moodleform to edit the grade options for an individual grade category.
 
file  component_gradeitem.php
 Compontent definition of a gradeitem.
 
file  component_gradeitems.php
 Helper class to fetch information about component grade items.
 
file  constants.php
 Definitions of constants for gradebook.
 
file  coverage.php
 Coverage information for the grades component.
 
file  edit_form.php
 Edit form for grade scales.
 
file  edit_form.php
 Edit form for grade outcomes.
 
file  edit_form.php
 A moodleform for editing grade letters.
 
file  fetch.php
 Web service functions relating to scale grades and grading.
 
file  fetch.php
 Web service functions relating to point grades and grading.
 
file  form.php
 A form for editing course grade settings.
 
file  grade_category.php
 Definition of a class to represent a grade category.
 
file  grade_form.php
 A moodleform to allow the editing of a user's grade for a particular activity.
 
file  grade_grade.php
 Definition of a class to represent an individual user's grade.
 
file  grade_item.php
 Definition of a class to represent a grade item.
 
file  grade_object.php
 Definition of a grade object class for grade item, grade category etc to inherit from.
 
file  grade_outcome.php
 Definition of grade outcome class.
 
file  grade_scale.php
 Definition of grade scale class.
 
file  gradelib.php
 Library of functions for gradebook - both public and internal.
 
file  grades_external.php
 Core grades external functions.
 
file  import_outcomes_form.php
 A form to allow importing outcomes from a file.
 
file  item_form.php
 A moodleform allowing the editing of the grade options for an individual grade item.
 
file  itemnumber_mapping.php
 Grade item, itemnumber mapping.
 
file  lib.php
 File containing the grade_report class.
 
file  lib.php
 Functions used by gradebook plugins and reports.
 
file  lib.php
 A library of classes used by the grade edit pages.
 
file  outcomeitem_form.php
 A moodleform to allow the creation and editing of outcome grade items.
 
file  querylib.php
 Functions used to retrieve grades objects.
 
file  store.php
 Web service functions relating to scale grades and grading.
 
file  store.php
 Web service functions relating to point grades and grading.
 
file  tabs.php
 Prints navigation tabs for viewing and editing grade outcomes.
 
file  tabs.php
 Prints navigation tabs for viewing and editing grade letters.
 

Namespaces

 core_grades
  
 
 core_grades\grades\grader\gradingpanel\point\external
  
 
 core_grades\grades\grader\gradingpanel\scale\external
  
 
 core_grades\local\gradeitem
  
 
 core_grades\privacy
  
 

Classes

class  behat_grade
 
class  core_grades\component_gradeitem
 Compontent definition of a gradeitem. More...
 
class  core_grades\component_gradeitems
 Helper class to fetch information about component grade items. More...
 
class  core_grades\grades\grader\gradingpanel\point\external\fetch
 External grading panel point API. More...
 
class  core_grades\grades\grader\gradingpanel\point\external\store
 External grading panel point API. More...
 
class  core_grades\grades\grader\gradingpanel\scale\external\fetch
 External grading panel scale API. More...
 
class  core_grades\grades\grader\gradingpanel\scale\external\store
 External grading panel scale API. More...
 
interface  core_grades\local\gradeitem\advancedgrading_mapping
 Grade item, itemnumber mapping. More...
 
interface  core_grades\local\gradeitem\itemnumber_mapping
 Grade item, itemnumber mapping. More...
 
class  core_grades\privacy\provider
 Data provider class. More...
 
class  core_grades_external
 core grades functions More...
 
class  course_settings_form
 First implementation of the preferences in the form of a moodleform. More...
 
class  edit_calculation_form
 
class  edit_category_form
 
class  edit_grade_form
 
class  edit_item_form
 
class  edit_letter_form
 
class  edit_outcome_form
 
class  edit_outcomeitem_form
 
class  edit_scale_form
 
class  grade_category
 
class  grade_edit_tree
 
class  grade_edit_tree_column
 Class grade_edit_tree_column. More...
 
class  grade_edit_tree_column_actions
 Class grade_edit_tree_column_actions. More...
 
class  grade_edit_tree_column_name
 Class grade_edit_tree_column_name. More...
 
class  grade_edit_tree_column_range
 Class grade_edit_tree_column_range. More...
 
class  grade_edit_tree_column_select
 Class grade_edit_tree_column_select. More...
 
class  grade_edit_tree_column_weight
 Class grade_edit_tree_column_weight. More...
 
class  grade_grade
 
class  grade_helper
 Grade helper class. More...
 
class  grade_item
 
class  grade_object
 
class  grade_outcome
 
class  grade_plugin_info
 A simple class containing info about grade plugins. More...
 
class  grade_plugin_return
 Utility class used for return tracking when using edit and other forms in grade plugins. More...
 
class  grade_report
 An abstract class containing variables and methods used by all or most reports. More...
 
class  grade_scale
 
class  grade_seq
 Flat structure similar to grade tree. More...
 
class  grade_structure
 General structure representing grade items in course. More...
 
class  grade_tree
 This class represents a complete tree of categories, grade_items and final grades, organises as an array primarily, but which can also be converted to other formats. More...
 
class  graded_users_iterator
 This class iterates over all users that are graded in a course. More...
 
class  import_outcomes_form
 
class  phpunit_coverage_info
 Coverage information for the tool_dataprivacy plugin. More...
 

Functions

 grade_build_nav ($path, $pagename=null, $id=null)
 Function central to gradebook for building and printing the navigation (breadcrumb trail). More...
 
 grade_button ($type, $courseid, $object)
 Local shortcut function for creating an edit/delete button for a grade_* object. More...
 
 grade_course_category_delete ($categoryid, $newparentid, $showfeedback)
 Called when course category is deleted Cleans the gradebook of associated data. More...
 
 grade_course_reset ($courseid)
 Reset all course grades, refetch from the activities and recalculate. More...
 
moodle_page grade_extend_settings ($plugininfo, $courseid)
 This method adds settings to the settings block for the grade system and its plugins. More...
 
 grade_floats_different ($f1, $f2)
 Compare two float numbers safely. More...
 
 grade_floats_equal ($f1, $f2)
 Compare two float numbers safely. More...
 
 grade_floatval ($number)
 Convert a number to 5 decimal point float, an empty string or a null db compatible format (we need this to decide if db value changed) More...
 
 grade_force_full_regrading ($courseid)
 Force final grade recalculation in all course items. More...
 
 grade_force_site_regrading ()
 Forces regrading of all site grades. More...
 
 grade_format_gradevalue ($value, &$grade_item, $localized=true, $displaytype=null, $decimals=null)
 Returns string representation of grade value. More...
 
 grade_format_gradevalue_letter ($value, $grade_item)
 Returns a letter grade representation of a grade value The array of grade letters used is produced by grade_get_letters() using the course context. More...
 
 grade_format_gradevalue_percentage ($value, $grade_item, $decimals, $localized)
 Returns a percentage representation of a grade value. More...
 
 grade_format_gradevalue_real ($value, $grade_item, $decimals, $localized)
 Returns a float representation of a grade value. More...
 
 grade_get_categories_menu ($courseid, $includenew=false)
 Returns grade options for gradebook grade category menu. More...
 
 grade_get_course_grade ($userid, $courseid_or_ids=null)
 Returns the aggregated or calculated course grade for a single user for one or more courses. More...
 
 grade_get_course_grades ($courseid, $userid_or_ids=null)
 Returns the aggregated or calculated course grade(s) for a single course for one or more users. More...
 
 grade_get_date_for_user_grade (\stdClass $grade, stdClass $user)
 Get the most appropriate grade date for a grade item given the user that the grade relates to. More...
 
 grade_get_gradable_activities ($courseid, $modulename='')
 Returns an array of activities (defined as $cm objects) which are gradeable from gradebook, outcomes are ignored. More...
 
 grade_get_grade_items_for_activity ($cm, $only_main_item=false)
 Returns all grade items (including outcomes) or main item for a given activity identified by $cm object. More...
 
 grade_get_graded_users_select ($report, $course, $userid, $groupid, $includeall)
 
 grade_get_grades ($courseid, $itemtype, $itemmodule, $iteminstance, $userid_or_ids=null)
 
 grade_get_letters ($context=null)
 Returns the array of grade letters to be used in the supplied context. More...
 
 grade_get_plugin_info ($courseid, $active_type, $active_plugin)
 grade_get_plugin_info More...
 
 grade_get_setting ($courseid, $name, $default=null, $resetcache=false)
 Returns a course gradebook setting. More...
 
 grade_get_settings ($courseid)
 Returns all course gradebook settings as object properties. More...
 
 grade_grab_course_grades ($courseid, $modname=null, $userid=0)
 Refetches grade data from course activities. More...
 
 grade_hide_min_max_grade_upgrade_notice ($courseid)
 Hide warning about changed grades during upgrade from 2.8.0-2.8.6 and 2.9.0. More...
 
 grade_is_user_graded_in_activity ($cm, $userid)
 Returns whether or not a user received grades in main grade item for given activity. More...
 
 grade_needs_regrade_final_grades ($courseid)
 Return true if the course needs regrading. More...
 
 grade_needs_regrade_progress_bar ($courseid)
 Return true if the regrade process is likely to be time consuming and will therefore require the progress bar. More...
 
 grade_print_tabs ($active_type, $active_plugin, $plugin_info, $return=false)
 Print grading plugin selection tab-based navigation. More...
 
 grade_recover_history_grades ($userid, $courseid)
 Recover a user's grades from grade_grades_history. More...
 
 grade_regrade_final_grades ($courseid, $userid=null, $updated_item=null, $progress=null)
 Updates all final grades in course. More...
 
 grade_regrade_final_grades_if_required ($course, callable $callback=null)
 Check whether regarding of final grades is required and, if so, perform the regrade. More...
 
 grade_set_setting ($courseid, $name, $value)
 Add, update or delete a course gradebook setting. More...
 
 grade_uninstalled_module ($modname)
 Does gradebook cleanup when a module is uninstalled Deletes all associated grade items. More...
 
 grade_update ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $itemnumber, $grades=NULL, $itemdetails=NULL)
 
 grade_update_mod_grades ($modinstance, $userid=0)
 Force full update of module grades in central gradebook. More...
 
 grade_update_outcomes ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $userid, $data)
 
 grade_upgrade_use_min_max_from_grade_grade ($courseid)
 Use the grade min and max from the grade_grade. More...
 
 grade_upgrade_use_min_max_from_grade_item ($courseid)
 Use the grade min and max from the grade_item. More...
 
 grade_user_delete ($userid)
 Deletes all of a user's grade data from gradebook. More...
 
 grade_user_unenrol ($courseid, $userid)
 Purge course data when user unenrolls from a course. More...
 
 grade_verify_idnumber ($idnumber, $courseid, $grade_item=null, $cm=null)
 Verify new value of grade item idnumber. More...
 
 hide_aggregatesubcats_upgrade_notice ($courseid)
 Hide warning about changed grades during upgrade to 2.8. More...
 
 hide_gradebook_calculations_freeze_notice ($courseid)
 Hide warning about changed grades due to bug fixes. More...
 
 hide_natural_aggregation_upgrade_notice ($courseid)
 Hide warning about changed grades during upgrade to 2.8. More...
 
 print_grade_page_head ($courseid, $active_type, $active_plugin=null, $heading=false, $return=false, $buttons=false, $shownavigation=true, $headerhelpidentifier=null, $headerhelpcomponent=null, $user=null)
 Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and (optional) navigation tabs for any gradebook page. More...
 
 print_grade_plugin_selector ($plugin_info, $active_type, $active_plugin, $return=false)
 Print grading plugin selection popup form. More...
 
 print_graded_users_selector ($course, $actionpage, $userid=0, $groupid=0, $includeall=true, $return=false)
 Print a selection popup form of the graded users in a course. More...
 
 print_natural_aggregation_upgrade_notice ($courseid, $context, $thispage, $return=false)
 Print warning about changed grades during upgrade to 2.8. More...
 
 remove_course_grades ($courseid, $showfeedback)
 Remove all grade related course data Grade history is kept. More...
 
 remove_grade_letters ($context, $showfeedback)
 Remove grade letters for given context. More...
 

Variables

global $CFG
 
 $context = context_course::instance($courseid)
 
 $row = $tabs = array()
 
 $row []
 
 $row = $tabs = array()
 
 $row []
 
if(has_capability('moodle/grade:manageletters', $context)) $tabs [] = $row
 
if(has_capability('moodle/grade:manage', $context)) $tabs [] = $row
 
const GRADE_AGGREGATE_EXTRACREDIT_MEAN 12
 GRADE_AGGREGATE_EXTRACREDIT_MEAN - Use the category mean for grade aggregation and include support for extra credit.
 
const GRADE_AGGREGATE_MAX 6
 GRADE_AGGREGATE_MAX - Use the category maximum grade for grade aggregation.
 
const GRADE_AGGREGATE_MEAN 0
 GRADE_AGGREGATE_MEAN - Use the category mean for grade aggregation.
 
const GRADE_AGGREGATE_MEDIAN 2
 GRADE_AGGREGATE_MEDIAN - Use the category median for grade aggregation.
 
const GRADE_AGGREGATE_MIN 4
 GRADE_AGGREGATE_MIN - Use the category minimum grade for grade aggregation.
 
const GRADE_AGGREGATE_MODE 8
 GRADE_AGGREGATE_MEDIAN - Use the category mode for grade aggregation.
 
const GRADE_AGGREGATE_SUM 13
 GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use Natural in the category for grade aggregation.
 
const GRADE_AGGREGATE_WEIGHTED_MEAN 10
 GRADE_AGGREGATE_WEIGHTED_MEAN - Use a weighted mean of grades in the category for grade aggregation. More...
 
const GRADE_AGGREGATE_WEIGHTED_MEAN2 11
 GRADE_AGGREGATE_WEIGHTED_MEAN2 - Use a simple weighted mean of grades in the category for grade aggregation.
 
const GRADE_DISPLAY_TYPE_DEFAULT 0
 GRADE_DISPLAY_TYPE_DEFAULT - Grade display type can be set at 3 levels: grade_item, course setting and site. More...
 
const GRADE_DISPLAY_TYPE_LETTER 3
 GRADE_DISPLAY_TYPE_LETTER - Display the grade as a letter grade. More...
 
const GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE 32
 GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE - Display the grade as a letter grade and a percentage.
 
const GRADE_DISPLAY_TYPE_LETTER_REAL 31
 GRADE_DISPLAY_TYPE_LETTER_REAL - Display the grade as a letter grade and a decimal number.
 
const GRADE_DISPLAY_TYPE_PERCENTAGE 2
 GRADE_DISPLAY_TYPE_PERCENTAGE - Display the grade as a percentage.
 
const GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER 23
 GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER - Display the grade as a percentage and a letter grade.
 
const GRADE_DISPLAY_TYPE_PERCENTAGE_REAL 21
 GRADE_DISPLAY_TYPE_PERCENTAGE_REAL - Display the grade as a percentage and a decimal number.
 
const GRADE_DISPLAY_TYPE_REAL 1
 GRADE_DISPLAY_TYPE_REAL - Display the grade as a decimal number.
 
const GRADE_DISPLAY_TYPE_REAL_LETTER 13
 GRADE_DISPLAY_TYPE_REAL_LETTER - Display the grade as a decimal number and a letter grade.
 
const GRADE_DISPLAY_TYPE_REAL_PERCENTAGE 12
 GRADE_DISPLAY_TYPE_REAL_PERCENTAGE - Display the grade as a decimal number and a percentage.
 
const GRADE_FEEDBACK_FILEAREA 'feedback'
 The file area to store the associated grade_grades feedback files.
 
const GRADE_FILE_COMPONENT 'grade'
 The component to store grade files.
 
const GRADE_HISTORY_DELETE 3
 GRADE_HISTORY_INSERT - A grade item was deleted.
 
const GRADE_HISTORY_FEEDBACK_FILEAREA 'historyfeedback'
 The file area to store the associated grade_grades_history feedback files.
 
const GRADE_HISTORY_INSERT 1
 GRADE_HISTORY_INSERT - A grade item was inserted.
 
const GRADE_HISTORY_UPDATE 2
 GRADE_HISTORY_UPDATE - A grade item was updated.
 
const GRADE_MIN_MAX_FROM_GRADE_GRADE 2
 GRADE_MIN_MAX_FROM_GRADE_GRADE - Get the grade min/max from the grade grade.
 
const GRADE_MIN_MAX_FROM_GRADE_ITEM 1
 GRADE_MIN_MAX_FROM_GRADE_ITEM - Get the grade min/max from the grade item.
 
const GRADE_NAVMETHOD_COMBO 2
 GRADE_NAVMETHOD_TABS - Display both a drop down and tabs to allow navigation within the gradebook.
 
const GRADE_NAVMETHOD_DROPDOWN 0
 GRADE_NAVMETHOD_DROPDOWN - Display a drop down box to allow navigation within the gradebook.
 
const GRADE_NAVMETHOD_TABS 1
 GRADE_NAVMETHOD_TABS - Display tabs to allow navigation within the gradebook.
 
const GRADE_REPORT_AGGREGATION_POSITION_FIRST 0
 GRADE_REPORT_AGGREGATION_POSITION_FIRST - Display the course totals before the individual activity grades.
 
const GRADE_REPORT_AGGREGATION_POSITION_LAST 1
 GRADE_REPORT_AGGREGATION_POSITION_LAST - Display the course totals after the individual activity grades.
 
const GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN 0
 GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item hide the total from students.
 
const GRADE_REPORT_MEAN_ALL 0
 GRADE_REPORT_MEAN_ALL - Include all grade items including those where the student hasn't received a grade when calculating the mean.
 
const GRADE_REPORT_MEAN_GRADED 1
 GRADE_REPORT_MEAN_GRADED - Only include grade items where the student has a grade when calculating the mean.
 
const GRADE_REPORT_PREFERENCE_DEFAULT 'default'
 GRADE_REPORT_PREFERENCE_DEFAULT - Use the setting from site preferences.
 
const GRADE_REPORT_PREFERENCE_INHERIT 'inherit'
 GRADE_REPORT_PREFERENCE_INHERIT - Inherit the setting value from the parent.
 
const GRADE_REPORT_PREFERENCE_UNUSED -1
 GRADE_REPORT_PREFERENCE_UNUSED - Unused constant.
 
const GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN 2
 GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show students the real total including marks from hidden items.
 
const GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN 1
 GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN - If the category or course total contains a hidden item show the total to students minus grades from the hidden items.
 
const GRADE_TYPE_NONE 0
 GRADE_TYPE_NONE - Ungraded.
 
const GRADE_TYPE_SCALE 2
 GRADE_TYPE_NONE - The grade is a value from the set of values available in a grade scale.
 
const GRADE_TYPE_TEXT 3
 GRADE_TYPE_NONE - Feedback only.
 
const GRADE_TYPE_VALUE 1
 GRADE_TYPE_NONE - The grade is a numeric value.
 
const GRADE_UPDATE_FAILED 1
 GRADE_UPDATE_FAILED - Grade updated failed.
 
const GRADE_UPDATE_ITEM_LOCKED 4
 GRADE_UPDATE_DELETED - Grade item cannot be updated as it is locked.
 
const GRADE_UPDATE_MULTIPLE 2
 GRADE_UPDATE_MULTIPLE - Grade update failed because there are multiple grade items with the same itemnumber for this activity.
 
const GRADE_UPDATE_OK 0
 GRADE_UPDATE_OK - Grade updated completed successfully.
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 
 if (!defined( 'MOODLE_INTERNAL'))
 

Detailed Description

Function Documentation

◆ grade_build_nav()

grade_build_nav (   $path,
  $pagename = null,
  $id = null 
)

Function central to gradebook for building and printing the navigation (breadcrumb trail).

Parameters
string$pathThe path of the calling script (using FILE?)
string$pagenameThe language string to use as the last part of the navigation (non-link)
mixed$idEither a plain integer (assuming the key is 'id') or an array of keys and values (e.g courseid => $courseid, itemid...)
Return values
string

◆ grade_button()

grade_button (   $type,
  $courseid,
  $object 
)

Local shortcut function for creating an edit/delete button for a grade_* object.

Parameters
string$type'edit' or 'delete'
int$courseidThe Course ID
grade_*$object The grade_* object
Return values
stringhtml

◆ grade_course_category_delete()

grade_course_category_delete (   $categoryid,
  $newparentid,
  $showfeedback 
)

Called when course category is deleted Cleans the gradebook of associated data.

Parameters
int$categoryidThe course category id
int$newparentidIf empty everything is deleted. Otherwise the ID of the category where content moved
bool$showfeedbackprint feedback

◆ grade_course_reset()

grade_course_reset (   $courseid)

Reset all course grades, refetch from the activities and recalculate.

Parameters
int$courseidThe course to reset
Return values
boolsuccess

◆ grade_extend_settings()

moodle_page grade_extend_settings (   $plugininfo,
  $courseid 
)

This method adds settings to the settings block for the grade system and its plugins.

$PAGE

◆ grade_floats_different()

grade_floats_different (   $f1,
  $f2 
)

Compare two float numbers safely.

Uses 5 decimals php precision using grade_floatval(). Nulls accepted too. Used for determining if a database update is required

Parameters
float$f1Float one to compare
float$f2Float two to compare
Return values
boolTrue if the supplied values are different

◆ grade_floats_equal()

grade_floats_equal (   $f1,
  $f2 
)

Compare two float numbers safely.

Uses 5 decimals php precision using grade_floatval()

Do not use rounding for 10,5 at the database level as the results may be different from php round() function.

Since
Moodle 2.0
Parameters
float$f1Float one to compare
float$f2Float two to compare
Return values
boolTrue if the values should be considered as the same grades

◆ grade_floatval()

grade_floatval (   $number)

Convert a number to 5 decimal point float, an empty string or a null db compatible format (we need this to decide if db value changed)

Parameters
mixed$numberThe number to convert
Return values
mixedfloat or null

◆ grade_force_full_regrading()

grade_force_full_regrading (   $courseid)

Force final grade recalculation in all course items.

Parameters
int$courseidThe course ID to recalculate

◆ grade_force_site_regrading()

grade_force_site_regrading ( )

Forces regrading of all site grades.

Used when changing site setings

◆ grade_format_gradevalue()

grade_format_gradevalue (   $value,
$grade_item,
  $localized = true,
  $displaytype = null,
  $decimals = null 
)

Returns string representation of grade value.

Parameters
float$valueThe grade value
object$grade_itemGrade item object passed by reference to prevent scale reloading
bool$localizeduse localised decimal separator
int$displaytypetype of display. For example GRADE_DISPLAY_TYPE_REAL, GRADE_DISPLAY_TYPE_PERCENTAGE, GRADE_DISPLAY_TYPE_LETTER
int$decimalsThe number of decimal places when displaying float values
Return values
string

◆ grade_format_gradevalue_letter()

grade_format_gradevalue_letter (   $value,
  $grade_item 
)

Returns a letter grade representation of a grade value The array of grade letters used is produced by grade_get_letters() using the course context.

Parameters
float$valueThe grade value
object$grade_itemGrade item object
Return values
string

◆ grade_format_gradevalue_percentage()

grade_format_gradevalue_percentage (   $value,
  $grade_item,
  $decimals,
  $localized 
)

Returns a percentage representation of a grade value.

Parameters
float$valueThe grade value
object$grade_itemGrade item object
int$decimalsThe number of decimal places
bool$localizeduse localised decimal separator
Return values
string

◆ grade_format_gradevalue_real()

grade_format_gradevalue_real (   $value,
  $grade_item,
  $decimals,
  $localized 
)

Returns a float representation of a grade value.

Parameters
float$valueThe grade value
object$grade_itemGrade item object
int$decimalsThe number of decimal places
bool$localizeduse localised decimal separator
Return values
string

◆ grade_get_categories_menu()

grade_get_categories_menu (   $courseid,
  $includenew = false 
)

Returns grade options for gradebook grade category menu.

Parameters
int$courseidThe course ID
bool$includenewInclude option for new category at array index -1
Return values
arrayof grade categories in course

◆ grade_get_course_grade()

grade_get_course_grade (   $userid,
  $courseid_or_ids = null 
)

Returns the aggregated or calculated course grade for a single user for one or more courses.

Parameters
int$useridThe ID of the single user
int | array$courseid_or_idsOptional ID of course or array of IDs, empty means all of the user's courses
Return values
mixedgrade info or grades array including item info, false if error

◆ grade_get_course_grades()

grade_get_course_grades (   $courseid,
  $userid_or_ids = null 
)

Returns the aggregated or calculated course grade(s) for a single course for one or more users.

Parameters
int$courseidThe ID of course
int | array$userid_or_idsOptional ID of the graded user or array of user IDs; if userid not used, returns only information about grade_item
Return values
stdClassReturns an object containing information about course grade item. scaleid, name, grade and locked status etc and user course grades: $item->grades[$userid] => $usercoursegrade

◆ grade_get_date_for_user_grade()

grade_get_date_for_user_grade ( \stdClass  $grade,
stdClass  $user 
)

Get the most appropriate grade date for a grade item given the user that the grade relates to.

Parameters
stdClass$grade
stdClass$user
Return values
int|null

◆ grade_get_gradable_activities()

grade_get_gradable_activities (   $courseid,
  $modulename = '' 
)

Returns an array of activities (defined as $cm objects) which are gradeable from gradebook, outcomes are ignored.

Parameters
int$courseidIf provided then restrict to one course.
string$modulenameIf defined (could be 'forum', 'assignment' etc) then only that type are returned.
Return values
array::$cmobjects

◆ grade_get_grade_items_for_activity()

grade_get_grade_items_for_activity (   $cm,
  $only_main_item = false 
)

Returns all grade items (including outcomes) or main item for a given activity identified by $cm object.

Parameters
cm_info$cmA course module object (preferably with modname property)
bool$only_main_itemLimit the search to the primary grade item for the activity, 'itemnumber'==0
Return values
mixedAn array of grade item instances, one grade item if $only_main_item == true, false if error or not found

◆ grade_get_letters()

grade_get_letters (   $context = null)

Returns the array of grade letters to be used in the supplied context.

Parameters
object$contextContext object or null for defaults
Return values
arrayof grade_boundary (minimum) => letter_string

◆ grade_get_plugin_info()

grade_get_plugin_info (   $courseid,
  $active_type,
  $active_plugin 
)

grade_get_plugin_info

Parameters
int$courseidThe course id
string$active_typetype of plugin on current page - import, export, report or edit
string$active_pluginactive plugin type - grader, user, cvs, ...
Return values
array

◆ grade_get_setting()

grade_get_setting (   $courseid,
  $name,
  $default = null,
  $resetcache = false 
)

Returns a course gradebook setting.

Parameters
int$courseid
string$nameof setting, maybe null if reset only
string$defaultvalue to return if setting is not found
bool$resetcacheforce reset of internal static cache
Return values
stringvalue of the setting, $default if setting not found, NULL if supplied $name is null

◆ grade_get_settings()

grade_get_settings (   $courseid)

Returns all course gradebook settings as object properties.

Parameters
int$courseid
Return values
object

◆ grade_grab_course_grades()

grade_grab_course_grades (   $courseid,
  $modname = null,
  $userid = 0 
)

Refetches grade data from course activities.

Parameters
int$courseidThe course ID
string$modnameLimit the grade fetch to a single module type. For example 'forum'
int$useridlimit the grade fetch to a single user

◆ grade_hide_min_max_grade_upgrade_notice()

grade_hide_min_max_grade_upgrade_notice (   $courseid)

Hide warning about changed grades during upgrade from 2.8.0-2.8.6 and 2.9.0.

Parameters
int$courseidThe current course id.

◆ grade_is_user_graded_in_activity()

grade_is_user_graded_in_activity (   $cm,
  $userid 
)

Returns whether or not a user received grades in main grade item for given activity.

Parameters
cm_info$cmThe activity context module
int$useridThe user ID
Return values
boolTrue if graded, false if user not graded yet

◆ grade_needs_regrade_final_grades()

grade_needs_regrade_final_grades (   $courseid)

Return true if the course needs regrading.

Parameters
int$courseidThe course ID
Return values
booltrue if course grades need updating.

◆ grade_needs_regrade_progress_bar()

grade_needs_regrade_progress_bar (   $courseid)

Return true if the regrade process is likely to be time consuming and will therefore require the progress bar.

Parameters
int$courseidThe course ID
Return values
boolWhether the regrade process is likely to be time consuming

◆ grade_print_tabs()

grade_print_tabs (   $active_type,
  $active_plugin,
  $plugin_info,
  $return = false 
)

Print grading plugin selection tab-based navigation.

Parameters
string$active_typetype of plugin on current page - import, export, report or edit
string$active_pluginactive plugin type - grader, user, cvs, ...
array$plugin_infoArray of plugins
boolean$returnreturn as string
Return values
nothingor string if $return true

◆ grade_recover_history_grades()

grade_recover_history_grades (   $userid,
  $courseid 
)

Recover a user's grades from grade_grades_history.

Parameters
int$useridthe user ID whose grades we want to recover
int$courseidthe relevant course
Return values
booltrue if successful or false if there was an error or no grades could be recovered

◆ grade_regrade_final_grades()

grade_regrade_final_grades (   $courseid,
  $userid = null,
  $updated_item = null,
  $progress = null 
)

Updates all final grades in course.

Parameters
int$courseidThe course ID
int$useridIf specified try to do a quick regrading of the grades of this user only
object$updated_itemOptional grade item to be marked for regrading. It is required if $userid is set.
core\progress\base$progressIf provided, will be used to update progress on this long operation.
Return values
booltrue if ok, array of errors if problems found. Grade item id => error message

◆ grade_regrade_final_grades_if_required()

grade_regrade_final_grades_if_required (   $course,
callable  $callback = null 
)

Check whether regarding of final grades is required and, if so, perform the regrade.

If the regrade is expected to be time consuming (see grade_needs_regrade_progress_bar), then this function will output the progress bar, and redirect to the current PAGE->url after regrading completes. Otherwise the regrading will happen immediately and the page will be loaded as per normal.

A callback may be specified, which is called if regrading has taken place. The callback may optionally return a URL which will be redirected to when the progress bar is present.

Parameters
stdClass$courseThe course to regrade
callable$callbackA function to call if regrading took place
Return values
moodle_urlThe URL to redirect to if redirecting

◆ grade_set_setting()

grade_set_setting (   $courseid,
  $name,
  $value 
)

Add, update or delete a course gradebook setting.

Parameters
int$courseidThe course ID
string$nameName of the setting
string$valueValue of the setting. NULL means delete the setting.

◆ grade_uninstalled_module()

grade_uninstalled_module (   $modname)

Does gradebook cleanup when a module is uninstalled Deletes all associated grade items.

Parameters
string$modnameThe grade item module name to remove. For example 'forum'

◆ grade_update_mod_grades()

grade_update_mod_grades (   $modinstance,
  $userid = 0 
)

Force full update of module grades in central gradebook.

Parameters
object$modinstanceModule object with extra cmidnumber and modname property
int$useridOptional user ID if limiting the update to a single user
Return values
boolTrue if success

◆ grade_upgrade_use_min_max_from_grade_grade()

grade_upgrade_use_min_max_from_grade_grade (   $courseid)

Use the grade min and max from the grade_grade.

This is reserved for core use after an upgrade.

Parameters
int$courseidThe current course id.

◆ grade_upgrade_use_min_max_from_grade_item()

grade_upgrade_use_min_max_from_grade_item (   $courseid)

Use the grade min and max from the grade_item.

This is reserved for core use after an upgrade.

Parameters
int$courseidThe current course id.

◆ grade_user_delete()

grade_user_delete (   $userid)

Deletes all of a user's grade data from gradebook.

Parameters
int$useridThe user whose grade data should be deleted

◆ grade_user_unenrol()

grade_user_unenrol (   $courseid,
  $userid 
)

Purge course data when user unenrolls from a course.

Parameters
int$courseidThe ID of the course the user has unenrolled from
int$useridThe ID of the user unenrolling

◆ grade_verify_idnumber()

grade_verify_idnumber (   $idnumber,
  $courseid,
  $grade_item = null,
  $cm = null 
)

Verify new value of grade item idnumber.

Checks for uniqueness of new ID numbers. Old ID numbers are kept intact.

Parameters
string$idnumberstring (with magic quotes)
int$courseidID numbers are course unique only
grade_item$grade_itemThe grade item this idnumber is associated with
stdClass$cmused for course module idnumbers and items attached to modules
Return values
booltrue means idnumber ok

◆ hide_aggregatesubcats_upgrade_notice()

hide_aggregatesubcats_upgrade_notice (   $courseid)

Hide warning about changed grades during upgrade to 2.8.

Parameters
int$courseidThe current course id.

◆ hide_gradebook_calculations_freeze_notice()

hide_gradebook_calculations_freeze_notice (   $courseid)

Hide warning about changed grades due to bug fixes.

Parameters
int$courseidThe current course id.

◆ hide_natural_aggregation_upgrade_notice()

hide_natural_aggregation_upgrade_notice (   $courseid)

Hide warning about changed grades during upgrade to 2.8.

Parameters
int$courseidThe current course id.

◆ print_grade_page_head()

print_grade_page_head (   $courseid,
  $active_type,
  $active_plugin = null,
  $heading = false,
  $return = false,
  $buttons = false,
  $shownavigation = true,
  $headerhelpidentifier = null,
  $headerhelpcomponent = null,
  $user = null 
)

Prints the page headers, breadcrumb trail, page heading, (optional) dropdown navigation menu and (optional) navigation tabs for any gradebook page.

All gradebook pages MUST use these functions in favour of the usual print_header(), print_header_simple(), print_heading() etc. !IMPORTANT! Use of tabs.php file in gradebook pages is forbidden unless tabs are switched off at the site level for the gradebook ($CFG->grade_navmethod = GRADE_NAVMETHOD_DROPDOWN).

Parameters
int$courseidCourse id
string$active_typeThe type of the current page (report, settings, import, export, scales, outcomes, letters)
string$active_pluginThe plugin of the current page (grader, fullview etc...)
string$headingThe heading of the page. Tries to guess if none is given
boolean$returnWhether to return (true) or echo (false) the HTML generated by this function
string$bodytagsAdditional attributes that will be added to the <body> tag
string$buttonsAdditional buttons to display on the page
boolean$shownavigationshould the gradebook navigation drop down (or tabs) be shown?
string$headerhelpidentifierThe help string identifier if required.
string$headerhelpcomponentThe component for the help string.
stdClass$userThe user object for use with the user context header.
Return values
stringHTML code or nothing if $return == false

◆ print_grade_plugin_selector()

print_grade_plugin_selector (   $plugin_info,
  $active_type,
  $active_plugin,
  $return = false 
)

Print grading plugin selection popup form.

Parameters
array$plugin_infoAn array of plugins containing information for the selector
boolean$returnreturn as string
Return values
nothingor string if $return true

◆ print_graded_users_selector()

print_graded_users_selector (   $course,
  $actionpage,
  $userid = 0,
  $groupid = 0,
  $includeall = true,
  $return = false 
)

Print a selection popup form of the graded users in a course.

Deprecated:
since 2.0
Parameters
int$courseid of the course
string$actionpageThe page receiving the data from the popoup form
int$useridid of the currently selected user (or 'all' if they are all selected)
int$groupidid of requested group, 0 means all
int$includeallbool include all option
bool$returnIf true, will return the HTML, otherwise, will print directly
Return values
null

◆ print_natural_aggregation_upgrade_notice()

print_natural_aggregation_upgrade_notice (   $courseid,
  $context,
  $thispage,
  $return = false 
)

Print warning about changed grades during upgrade to 2.8.

Parameters
int$courseidThe current course id.
context$contextThe course context.
string$thispageThe relative path for the current page. E.g. /grade/report/user/index.php
boolean$returnreturn as string
Return values
nothingor string if $return true

◆ remove_course_grades()

remove_course_grades (   $courseid,
  $showfeedback 
)

Remove all grade related course data Grade history is kept.

Parameters
int$courseidThe course ID
bool$showfeedbackIf true success notifications will be displayed

◆ remove_grade_letters()

remove_grade_letters (   $context,
  $showfeedback 
)

Remove grade letters for given context.

Parameters
context$contextThe context
bool$showfeedbackIf true a success notification will be displayed

Variable Documentation

◆ $row [1/2]

$row[]
Initial value:
= new tabobject('lettersview',
$CFG->wwwroot.'/grade/edit/letter/index.php?id='.$COURSE->id,
get_string('letters', 'grades'))

◆ $row [2/2]

$row[]
Initial value:
= new tabobject('courseoutcomes',
$CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$courseid,
get_string('outcomescourse', 'grades'))

◆ GRADE_AGGREGATE_WEIGHTED_MEAN

const GRADE_AGGREGATE_WEIGHTED_MEAN 10

GRADE_AGGREGATE_WEIGHTED_MEAN - Use a weighted mean of grades in the category for grade aggregation.

Weights can be manually set.

◆ GRADE_DISPLAY_TYPE_DEFAULT

const GRADE_DISPLAY_TYPE_DEFAULT 0

GRADE_DISPLAY_TYPE_DEFAULT - Grade display type can be set at 3 levels: grade_item, course setting and site.

Use the display type from the higher level.

◆ GRADE_DISPLAY_TYPE_LETTER

const GRADE_DISPLAY_TYPE_LETTER 3

GRADE_DISPLAY_TYPE_LETTER - Display the grade as a letter grade.

For example, A, B, C, D or F.

tabobject
Stores one tab.
Definition: outputcomponents.php:3840
$CFG
global object $CFG
$CFG
Definition: componentlib.class.php:134