We have similar issue while a lecturer made his quizzes manually graded and changed to deferred feedback via interface does not fix or grade any attempts for him.
Your SQL to fix the problem using database is very useful. However, you have posted in another forum a while back (forum/discuss.php?d=213853) that there would be two tables involved when changing question behaviour. (mdl_question_attempts & mdl_question_usages)
I checked our database tables and found 'manualgraded' in both tables for the particular quizzes.
So, before I make any changes for my lecturer could you help confirming if I should also update 'mdl_question_usages' or it doesn't matter?
Another questions ... Do I need to add another condition to exclude 'essay' type of question as they can only be manualgraded? If so .. what other type (qtype) can only be manualgraded and needed in the SQL?