Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)

Namespaces

namespace  core_grades\privacy
  
 

Classes

class  core_grades\privacy\grade_grade_with_history
 A grade_item which has a reference to its historical content. More...
 
class  grade_category
 grade_category is an object mapped to DB table {prefix}grade_categories More...
 
class  grade_grade
 grade_grades is an object mapped to DB table {prefix}grade_grades More...
 
class  grade_item
 Class representing a grade item. More...
 
class  grade_object
 An abstract object that holds methods and attributes common to all grade_* objects defined here. More...
 
class  grade_outcome
 Class representing a grade outcome. More...
 
class  grade_scale
 Class representing a grade scale. More...
 

Functions

 grade_course_category_delete ($categoryid, $newparentid, $showfeedback)
 Called when course category is deleted Cleans the gradebook of associated data.
 
 grade_course_reset ($courseid)
 Reset all course grades, refetch from the activities and recalculate.
 
 grade_floats_different (?float $f1, ?float $f2)
 Compare two float numbers safely.
 
 grade_floats_equal (?float $f1, ?float $f2)
 Compare two float numbers safely.
 
 grade_floatval (?float $number)
 Convert a number to 5 decimal point float, null db compatible format (we need this to decide if db value changed)
 
 grade_force_full_regrading ($courseid)
 Force final grade recalculation in all course items.
 
 grade_force_site_regrading ()
 Forces regrading of all site grades.
 
 grade_format_gradevalue (?float $value, &$grade_item, $localized=true, $displaytype=null, $decimals=null)
 Returns string representation of grade value.
 
 grade_format_gradevalue_letter (?float $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.
 
 grade_format_gradevalue_percentage (?float $value, $grade_item, $decimals, $localized)
 Returns a percentage representation of a grade value.
 
 grade_format_gradevalue_real (?float $value, $grade_item, $decimals, $localized)
 Returns a float representation of a grade value.
 
 grade_get_categories_menu ($courseid, $includenew=false)
 Returns grade options for gradebook grade category menu.
 
 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.
 
 grade_get_course_grades ($courseid, $userid_or_ids=null)
 Functions used to retrieve grades objects.
 
 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.
 
 grade_get_gradable_activities ($courseid, $modulename='')
 Returns an array of activities (defined as $cm objects) which are gradeable from gradebook, outcomes are ignored.
 
 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.
 
 grade_get_grades ($courseid, $itemtype, $itemmodule, $iteminstance, $userid_or_ids=null)
 Returns grading information for given activity, optionally with user grades.
 
 grade_get_letters ($context=null)
 Returns the array of grade letters to be used in the supplied context.
 
 grade_get_setting ($courseid, $name, $default=null, $resetcache=false)
 Returns a course gradebook setting.
 
 grade_get_settings ($courseid)
 Returns all course gradebook settings as object properties.
 
 grade_grab_course_grades ($courseid, $modname=null, $userid=0)
 Refetches grade data from course activities.
 
 grade_is_user_graded_in_activity ($cm, $userid)
 Returns whether or not a user received grades in main grade item for given activity.
 
 grade_needs_regrade_final_grades ($courseid)
 Return true if the course needs regrading.
 
 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.
 
 grade_recover_history_grades ($userid, $courseid)
 Recover a user's grades from grade_grades_history.
 
 grade_regrade_final_grades ($courseid, $userid=null, $updated_item=null, $progress=null)
 Updates all final grades in course.
 
 grade_regrade_final_grades_if_required ($course, callable $callback=null)
 Check whether regarding of final grades is required and, if so, perform the regrade.
 
 grade_set_setting ($courseid, $name, $value)
 Add, update or delete a course gradebook setting.
 
 grade_uninstalled_module ($modname)
 Does gradebook cleanup when a module is uninstalled Deletes all associated grade items.
 
 grade_update ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $itemnumber, $grades=null, $itemdetails=null, $isbulkupdate=false)
 Include essential files.
 
 grade_update_mod_grades ($modinstance, $userid=0)
 Force full update of module grades in central gradebook.
 
 grade_update_outcomes ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $userid, $data)
 Updates a user's outcomes.
 
 grade_user_delete ($userid)
 Deletes all of a user's grade data from gradebook.
 
 grade_user_unenrol ($courseid, $userid)
 Purge course data when user unenrolls from a course.
 
 grade_verify_idnumber ($idnumber, $courseid, $grade_item=null, $cm=null)
 Verify new value of grade item idnumber.
 
 remove_course_grades ($courseid, $showfeedback)
 Remove all grade related course data Grade history is kept.
 
 remove_grade_letters ($context, $showfeedback)
 Remove grade letters for given context.
 

Variables

global $CFG
 
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_SUM - 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.
 
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.
 
const GRADE_DISPLAY_TYPE_LETTER 3
 GRADE_DISPLAY_TYPE_LETTER - Display the grade as a letter grade.
 
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_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.
 

Detailed Description

Function Documentation

◆ 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_floats_different()

grade_floats_different ( ?float $f1,
?float $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 | null$f1Float one to compare
float | null$f2Float two to compare
Return values
boolTrue if the supplied values are different

◆ grade_floats_equal()

grade_floats_equal ( ?float $f1,
?float $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 | null$f1Float one to compare
float | null$f2Float two to compare
Return values
boolTrue if the values should be considered as the same grades

◆ grade_floatval()

grade_floatval ( ?float $number)

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

Parameters
float | null$numberThe number to convert
Return values
float|nullfloat 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 ( ?float $value,
& $grade_item,
$localized = true,
$displaytype = null,
$decimals = null )

Returns string representation of grade value.

Parameters
float | null$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 ( ?float $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 | null$valueThe grade value
object$grade_itemGrade item object
Return values
string

◆ grade_format_gradevalue_percentage()

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

Returns a percentage representation of a grade value.

Parameters
float | null$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 ( ?float $value,
$grade_item,
$decimals,
$localized )

Returns a float representation of a grade value.

Parameters
float | null$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 )

Functions used to retrieve grades objects.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 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_grades()

grade_get_grades ( $courseid,
$itemtype,
$itemmodule,
$iteminstance,
$userid_or_ids = null )

Returns grading information for given activity, optionally with user grades.

Manual, course or category items can not be queried.

This function can be VERY costly - it is doing full course grades recalculation if needsupdate = 1 for course grade item. So be sure you really need it. If you need just certain grades consider using grade_item\refresh_grades() together with grade_item\get_grade() instead.

Parameters
int$courseidID of course
string$itemtypeType of grade item. For example, 'mod' or 'block'
string$itemmoduleMore specific then $itemtype. For example, 'forum' or 'quiz'. May be NULL for some item types
int$iteminstanceID of the item module
mixed$userid_or_idsEither a single user ID, an array of user IDs or null. If user ID or IDs are not supplied returns information about grade_item
Return values
stdClassObject with keys {items, outcomes, errors}, where 'items' is an array of grade information objects (scaleid, name, grade and locked status, etc.) indexed with itemnumbers

◆ 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_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_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_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
array|truetrue 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()

grade_update ( $source,
$courseid,
$itemtype,
$itemmodule,
$iteminstance,
$itemnumber,
$grades = null,
$itemdetails = null,
$isbulkupdate = false )

Include essential files.

Submit new or update grade; update/create grade_item definition. Grade must have userid specified, rawgrade and feedback with format are optional. rawgrade NULL means 'Not graded'. Missing property or key means does not change the existing value.

Only following grade item properties can be changed 'itemname', 'idnumber', 'gradetype', 'grademax', 'grademin', 'scaleid', 'multfactor', 'plusfactor', 'deleted' and 'hidden'. 'reset' means delete all current grades including locked ones.

Manual, course or category items can not be updated by this function.

Parameters
string$sourceSource of the grade such as 'mod/assignment'
int$courseidID of course
string$itemtypeType of grade item. For example, mod or block
string$itemmoduleMore specific then $itemtype. For example, assignment or forum. May be NULL for some item types
int$iteminstanceInstance ID of graded item
int$itemnumberMost probably 0. Modules can use other numbers when having more than one grade for each user
mixed$gradesGrade (object, array) or several grades (arrays of arrays or objects), NULL if updating grade_item definition only
mixed$itemdetailsObject or array describing the grading item, NULL if no change
bool$isbulkupdateIf bulk grade update is happening.
Return values
intReturns GRADE_UPDATE_OK, GRADE_UPDATE_FAILED, GRADE_UPDATE_MULTIPLE or GRADE_UPDATE_ITEM_LOCKED

◆ 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_update_outcomes()

grade_update_outcomes ( $source,
$courseid,
$itemtype,
$itemmodule,
$iteminstance,
$userid,
$data )

Updates a user's outcomes.

Manual outcomes can not be updated.

Parameters
string$sourceSource of the grade such as 'mod/assignment'
int$courseidID of course
string$itemtypeType of grade item. For example, 'mod' or 'block'
string$itemmoduleMore specific then $itemtype. For example, 'forum' or 'quiz'. May be NULL for some item types
int$iteminstanceInstance ID of graded item. For example the forum ID.
int$useridID of the graded user
array$dataArray consisting of grade item itemnumber (grade_update()) => outcomegrade
Return values
boolreturns true if grade items were found and updated successfully

◆ 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

◆ 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

◆ 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.