MDL-46649 gradereport_history: Add apis to get users and user count, also refactor ajax.php