I have done something similar - and as Howard says, you need to look at web services - https://docs.moodle.org/dev/Web_services_API and additionally the External Services API - https://docs.moodle.org/dev/External_functions_API - they are closely related. You will need to be able to sync the external grade activity with the Moodle activity being graded so an identifier that is shared between the external system and Moodle.
General developer forum
Management of Moodle grades by an external system
This discussion has been locked so you can no longer reply to it.