MDL-46678 gradereport_history: Move hardcoded sql from index.php to an api

Part of MDL-46191
MDL-46678 gradereport_history: Write unit tests for get_graders api

Part of MDL-46191
MDL-46573 gradereport_history: Cross DB query relying on timemodified

Part of MDL-46191
MDL-46191 gradereport_history: Fix minor issues after the review

Part of MDL-46191