Have a look if using grade calculations will get you there: https://docs.moodle.org/33/en/Grade_calculations
Alternatively, you could ask the teachers to manually override the category/course grade in the gradebook if/when they mark an assignment as failed.