Ok, there is already a grade report under the report list - just download that and then modify to suit your needs. The document you posted is php code so it was very confusing.
Configurable reports block (plugin)
Report on Assignment Grading Summary in Category
This discussion has been locked so you can no longer reply to it.