Before you do any tinkering, make sure you have an sql dump of database for Moodle! You will never regret the time it takes to do that!
There is a hidden admin tool that doesn't appear in admin menus called 'Health Check' .... https://yoursite/admin/tool/health/
It is/could be memory intensive so suggest running during non-prime time for users.
That will gen a page showing issues it finds ... bet there will be a long listing for quizzes ... and at the bottom a button for 'show solutions'. Click that.
Will display an SQL statement (maybe more than one) to run via mysql client (that's why you did an MySQL dump ... uhhhh ... did I say that before?).
That will, hopefully, fix most ... when running the check again it might suggest posting to Quiz Forums for further resolution to issues.
With 3.x versions of Moodle there is an /admin/cli/ php script called 'fix_orphaned_question_categories.php' which might help.
Uhhh ... I did say do a mysqldump *before* using, didn't I?
'SoS', Ken