MDL-47064 Grades: Fix the contributed weights column for students and teachers.

Part of: MDL-46576
MDL-47064 Grades: Make the contribution to total column work

Part of: MDL-46576
MDL-47064 Grades: Add contribution to course total to behat test.

Part of: MDL-46576
MDL-47064 Grades: Fix contribution column for other types of aggregation

Part of: MDL-46576
MDL-47064 Grades: Add comments to explain this tricky code.

Part of: MDL-46576
MDL-47064 Grades: Peer review cleanups

Changes include:
 * Search for existing items to reduce DB queries in grade_category::aggregate_grades
 * Comments improvements
 * Move brackets to be part of lang string
 * Convert aggregationhints to be a class variable instead of passing it around

Part of: MDL-46576
MDL-47064 Grades: Final fix - set the grademax from the item, not the cat

Part of: MDL-46576
MDL-47417 core_grades: reset grademax when switching from Natural

in Natural aggregation method the grademax is automatically adjusted
when switching to another aggregation method it should be reset
to 100
MDL-47420 Grades: Get unit tests passing on natural grading branch

Part of: MDL-46576
MDL-47253 core_grades: set def aggregation method to Natural

Part of: MDL-46576
MDL-47253 core_grades: display scale in Natural setup

Part of: MDL-46576
MDL-47418 Grades: Fix debugging in behat test.
MDL-47377 core_grades: Handle items with a weight of 0

They do not contribute to the category/course total any more.

Part of: MDL-46576
MDL-47377 core_grades: Behat test to cover 0 weights
MDL-47110 core_grades: Normalisation of grade weights.

This includes behat tests for this change.

Part of: MDL-46576
MDL-47110 grades: more behat tests
MDL-47110 core_grades: Update to auto_adjust_weights

Part of: MDL-46576
MDL-47110 Grades: Change how updated weights notifications are detected.

Part of: MDL-46576
MDL-47110 Grades: Get the autoupdateweight behat tests to pass.

Part of: MDL-46576
MDL-47430 core_grades: Handle negative grademin with natural weighting

Part of: MDL-46576