Looking at tracking alterations to the gradebook in Moodle, the first place to start is the “gradelib” in the lib directory. The functions that jumps to mind would be the grade_update one, this seems to create the grade if it is a new one as well so hopefully it will be the place to do it.
Turns out that it is the grade/report/grader/lib.php process_data that holds the key.
~/lib/gradelib grade_update()
grade_update($source, $courseid, $itemtype, $itemmodule, $iteminstance, $itemnumber, $grades=NULL, $itemdetails=NULL) X-Ref
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.
param: string $source source of the grade such as ‘mod/assignment’
param: int $courseid id of course
param: string $itemtype type of grade item - mod, block
param: string $itemmodule more specific then $itemtype - assignment, forum, etc.; maybe NULL for some item types
param: int $iteminstance instance it of graded subject
param: int $itemnumber most probably 0, modules can use other numbers when having more than one grades for each user
param: mixed $grades grade (object, array) or several grades (arrays of arrays or objects), NULL if updating grade_item definition only
param: mixed $itemdetails object or array describing the grading item, NULL if no change
We also need to look at adding to the log files, this is done using the add_to_log function.
Things to watch for is if the person is logged in as so that we record the fact that someone was impersonating someone to make the changes and record who the real user is and who they were impersonating.
add_to_log($courseid, $module, $action, $url=”, $info=”, $cm=0, $user=0) X-Ref
Add an entry to the log table.
Add an entry to the log table. These are “action” focussed rather
than web server hits, and provide a way to easily reconstruct what
any particular student has been doing.
param: int $courseid The course id
param: string $module The module name - e.g. forum, journal, resource, course, user etc
param: string $action ’view’, ‘update’, ‘add’ or ‘delete’, possibly followed by another word to clarify.
param: string $url The file and parameters used to see the results of the action
param: string $info Additional description information
param: string $cm The course_module->id if there is one
param: string $user If log regards $user other than $USER
Book Mark it-> del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Netscape | Yahoo | BlinkList