Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/gradelib.php File Reference

Go to the source code of this file.

Namespaces

namespace  core

Functions

 grade_update ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $itemnumber, $grades=NULL, $itemdetails=NULL)
 grade_update_outcomes ($source, $courseid, $itemtype, $itemmodule, $iteminstance, $userid, $data)
 grade_get_grades ($courseid, $itemtype, $itemmodule, $iteminstance, $userid_or_ids=null)
 grade_get_setting ($courseid, $name, $default=null, $resetcache=false)
 grade_get_settings ($courseid)
 grade_set_setting ($courseid, $name, $value)
 grade_format_gradevalue ($value, &$grade_item, $localized=true, $displaytype=null, $decimals=null)
 grade_format_gradevalue_real ($value, $grade_item, $decimals, $localized)
 grade_format_gradevalue_percentage ($value, $grade_item, $decimals, $localized)
 grade_format_gradevalue_letter ($value, $grade_item)
 grade_get_categories_menu ($courseid, $includenew=false)
 grade_get_letters ($context=null)
 grade_verify_idnumber ($idnumber, $courseid, $grade_item=null, $cm=null)
 grade_force_full_regrading ($courseid)
 grade_force_site_regrading ()
 grade_recover_history_grades ($userid, $courseid)
 grade_regrade_final_grades ($courseid, $userid=null, $updated_item=null)
 grade_grab_course_grades ($courseid, $modname=null, $userid=0)
 grade_update_mod_grades ($modinstance, $userid=0)
 remove_grade_letters ($context, $showfeedback)
 remove_course_grades ($courseid, $showfeedback)
 grade_course_category_delete ($categoryid, $newparentid, $showfeedback)
 grade_uninstalled_module ($modname)
 grade_user_delete ($userid)
 grade_user_unenrol ($courseid, $userid)
 grade_cron ()
 grade_course_reset ($courseid)
 grade_floatval ($number)
 grade_floats_different ($f1, $f2)
 grade_floats_equal ($f1, $f2)

Function Documentation

grade_course_category_delete ( categoryid,
newparentid,
showfeedback 
)

Called when course category deleted - cleanup gradebook

object

Parameters:
int$categoryidcourse category id
int$newparentidempty means everything deleted, otherwise id of category where content moved
bool$showfeedbackprint feedback

Definition at line 1264 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_course_reset ( courseid)

Resel all course grades

Parameters:
int$courseid
Returns:
bool success

Definition at line 1383 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

Grading cron job

object object

Definition at line 1328 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_floats_different ( f1,
f2 
)

Compare two float numbers safely. Uses 5 decimals php precision. Nulls accepted too. Used for skipping of db updates

Parameters:
float$f1
float$f2
Returns:
bool true if different

Definition at line 1425 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_floats_equal ( f1,
f2 
)

Compare two float numbers safely. Uses 5 decimals php precision.

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

Since:
2.0
Parameters:
float$f1
float$f2
Returns:
bool true if the values should be considered as the same grades

Definition at line 1441 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_floatval ( number)

Convert number to 5 decimalfloat, empty string or null db compatible format (we need this to decide if db value changed)

Parameters:
mixed$number
Returns:
mixed float or null

Definition at line 1408 of file gradelib.php.

Here is the caller graph for this function:

grade_force_full_regrading ( courseid)

Force final grade recalculation in all course items

object

Parameters:
int$courseid

Definition at line 901 of file gradelib.php.

Here is the caller graph for this function:

Forces regrading of all site grades - usualy when chanign site setings object object

Definition at line 911 of file gradelib.php.

Here is the caller graph for this function:

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

Returns string representation of grade value

Parameters:
float$valuegrade value
object$grade_item- by reference to prevent scale reloading
bool$localizeduse localised decimal separator
int$displaytypetype of display - GRADE_DISPLAY_TYPE_REAL, GRADE_DISPLAY_TYPE_PERCENTAGE, GRADE_DISPLAY_TYPE_LETTER
int$decimalsnumber of decimal places when displaying float values
Returns:
string

Definition at line 657 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_format_gradevalue_letter ( value,
grade_item 
)
Todo:
Document this function

Definition at line 750 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_format_gradevalue_percentage ( value,
grade_item,
decimals,
localized 
)
Todo:
Document this function

Definition at line 737 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_format_gradevalue_real ( value,
grade_item,
decimals,
localized 
)
Todo:
Document this function

Definition at line 721 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_get_categories_menu ( courseid,
includenew = false 
)

Returns grade options for gradebook category menu

Parameters:
int$courseid
bool$includenewinclude option for new category (-1)
Returns:
array of grade categories in course

Definition at line 778 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns grading information for given activity - optionally with users grades Manual, course or category items can not be queried.

public object

Parameters:
int$courseidid of course
string$itemtype'mod', 'block'
string$itemmodule'forum, 'quiz', etc.
int$iteminstanceid of the item module
array | int$userid_or_idsoptional id of the graded user or array of ids; if userid not used, returns only information about grade_item
Returns:
array Array of grade information objects (scaleid, name, grade and locked status, etc.) indexed with itemnumbers

Definition at line 345 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_get_letters ( context = null)

Returns grade letters array used in context

Parameters:
object$contextobject or null for defaults
Returns:
array of grade_boundary=>letter_string

Definition at line 812 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Returns course gradebook setting

object

Parameters:
int$courseid
string$nameof setting, maybe null if reset only
string$default
bool$resetcacheforce reset of internal static cache
Returns:
string value, NULL if no setting

Definition at line 564 of file gradelib.php.

Here is the caller graph for this function:

grade_get_settings ( courseid)

Returns all course gradebook settings as object properties

object

Parameters:
int$courseid
Returns:
object

Definition at line 600 of file gradelib.php.

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

Refetches data from all course activities

Parameters:
int$courseidthe course ID
string$modnamelimit the grade fetch to a single module type
int$useridlimit the grade fetch to a single user
Returns:
void

Definition at line 1118 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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
Returns:
bool true if successful or false if there was an error or no grades could be recovered

Definition at line 922 of file gradelib.php.

Here is the call graph for this function:

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

Updates all final grades in course.

Parameters:
int$courseid
int$useridif specified, try to do a quick regrading of grades of this user only
object$updated_itemthe item in which
Returns:
boolean true if ok, array of errors if problems found (item id is used as key)

Definition at line 1002 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_set_setting ( courseid,
name,
value 
)

Add/update course gradebook setting

object

Parameters:
int$courseid
string$nameof setting
stringvalue, NULL means no setting==remove
Returns:
void

Definition at line 624 of file gradelib.php.

Here is the call graph for this function:

grade_uninstalled_module ( modname)

Does gradebook cleanup when module uninstalled.

object object

Parameters:
string$modname

Definition at line 1278 of file gradelib.php.

Here is the caller graph for this function:

grade_update ( source,
courseid,
itemtype,
itemmodule,
iteminstance,
itemnumber,
grades = NULL,
itemdetails = NULL 
)

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 do not change existing.

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. public object object object

Parameters:
string$sourcesource of the grade such as 'mod/assignment'
int$courseidid of course
string$itemtypetype of grade item - mod, block
string$itemmodulemore specific then $itemtype - assignment, forum, etc.; maybe NULL for some item types
int$iteminstanceinstance it of graded subject
int$itemnumbermost probably 0, modules can use other numbers when having more than one grades 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

Create or update the grade_item if needed

reset grades if requested

Some extra checks

Finally start processing of grades

normalize and verify grade array

Definition at line 64 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_update_mod_grades ( modinstance,
userid = 0 
)

Force full update of module grades in central gradebook

object object

Parameters:
object$modinstanceobject with extra cmidnumber and modname property
int$userid
Returns:
boolean success

Definition at line 1170 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Updates outcomes of user Manual outcomes can not be updated.

public

Parameters:
string$sourcesource of the grade such as 'mod/assignment'
int$courseidid of course
string$itemtype'mod', 'block'
string$itemmodule'forum, 'quiz', etc.
int$iteminstanceid of the item module
int$useridID of the graded user
array$dataarray itemnumber=>outcomegrade
Returns:
boolean returns true if grade items were found and updated successfully

Definition at line 317 of file gradelib.php.

Here is the call graph for this function:

grade_user_delete ( userid)

Deletes all user data from gradebook.

Parameters:
$userid

Definition at line 1298 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

grade_user_unenrol ( courseid,
userid 
)

Purge course data when user unenrolled.

Parameters:
$userid

Definition at line 1310 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Verify new value of idnumber - checks for uniqueness of new idnumbers, old are kept intact

object

Parameters:
stringidnumber string (with magic quotes)
int$courseidid numbers are course unique only
object$grade_itemis item idnumber
object$cmused for course module idnumbers and items attached to modules
Returns:
boolean true means idnumber ok

Definition at line 864 of file gradelib.php.

Here is the caller graph for this function:

remove_course_grades ( courseid,
showfeedback 
)

Remove all grade related course data - history is kept

Parameters:
int$courseid
bool$showfeedbackprint feedback

Definition at line 1218 of file gradelib.php.

Here is the call graph for this function:

Here is the caller graph for this function:

remove_grade_letters ( context,
showfeedback 
)

Remove grade letters for given context

Parameters:
context$context
bool$showfeedback

Definition at line 1201 of file gradelib.php.

Here is the caller graph for this function:

 All Data Structures Namespaces Files Functions Variables Enumerations