"With this new information, would you be able to imagine the cause of the problem?"
Am not capable of 'Vulcun Mind Melds', so I cannot 'imagine the cause'.
Never had the issue so following is 100% guess ..
1. Can you change the status of the badge awarding via DB?
2. In the table for the badges, is there a contenthash column? (which is supposed to be the location and filename in the sea of files of moodledata/filedir/
Both above are not 'standard' way of fixing things and should be done only on one reference to a badge. Then checked to see if there has been any un-anticipated problem cause by actions.
In the case of #2 above ... let's say the contenthash column exist and shows something like:
t4nasdopirewgasdhsefjsrf
cd moodledata/filedir/
find ./ -name t4nasdopirewgasdhsefjsrf
Last command will grind away - lots of files to look through so be patient.
IF not found, one could create a 0 byte file as a 'placeholder'.
touch moodledata/filedir/t4/na/t4nasdopirewgasdhsefjsrf
If the t4 directory doesn't exist, manually create it as well as subdirectory of na as in the example given.
change own apache:apache moodledata/filedir/t4/ -R
chmod ugo+rwx moodledata/filedir/t4/ -R (liberal permissions ok in this case)
Now there is something in moodledata/filedir/ that matches the meta data in the DB.
With that there now the course_delete_modules should be able to find something to delete!
Above, is, like I said ... 100% guess!
Good luck!
'SoS', Ken