MDL-47274 core_grades: Correct totals when excluding hidden items

Part of: MDL-46576
MDL-47009 Grades: Improve natural weighting algorithm

It's still not perfect, but this is getting closer.

This is based on Johns work on MDL-47009 (just the algorithm). There are some additional
changes to scale the weights if they do not add up to 1.

Part of: MDL-46576
MDL-47078 Grades: Allow users to have different max grades due to exclusions etc.

This is about making this work with natural weightings.

Part of: MDL-46576
MDL-47059 Grades: Make natural weights work with exclude empty grades

Part of: MDL-46576
MDL-47059 Grades: Make natural weights work with extra credit

Part of: MDL-46576
MDL-47059 Grades: Update the grade_grade if the finalgrade/or the grademax has changed.

Part of: MDL-46576
MDL-46576 core_grades: MDL-47006 Refactor weightings code for readibility
MDL-46576 core_grades: MDL-47006 Change aggregationcoef2's comment
MDL-47006 core_grades: Fix float formatting

Part of MDL-46576
MDL-47006 core_grades: Add weightoverride to qualifies_for_regrading

Part of MDL-46576