Like described in this post: https://moodle.org/mod/forum/discuss.php?d=386490, I have a problem with deleting users in Moodle.
I tracked it down to grades in the DB that seem to be orphaned - does anyone know if this is a known Moodle Bug?
What happens is:
1) I cannot delete some users on the Moodle Interface, it will give an "invalid course id" error
2) in the DB table grade_grades, there are grades recorded for these users, even though no grades show up in their Moodle profile, and they are no longer enrolled in any existing courses (their courses have been already deleted)
3) If I manually delete the records associated with the userid from the DB table grade_grades, I am able to delete the user in Moodle