In MODX, you can bypass the database check for the login entirely in a plugin that's part of the Login process. I've used it as part of the GoRevo package to let Evo users log in to Revo using their Evo credentials after the migration.
That suggests a possible solution.
1. In the MODX plugin, use cURL, Rest, AJAX, or some other method to see if the user validates on Moodle and log them into MODX if they do. Username, id, email, or something else would have to match in order to identify the user to log in.
Bottom line: Some unique user attribute has to be present in the DBs of both platforms for any SSO system to work.
More info in this series of articles:
https://bobsguides.com/blog.html/2016/04/06/bypassing-the-modx-manager-login-i/