if the teacher has given you a 'D' and in the exam you do exceptionally well, the exam board will have a look at your coursework and will see what they can do about it. they will reevaluate your results hopefully
You can still get a B, maybe even an A if you work really hard. Is this GCSE? For my GCSE biology I got a D for the coursework but I managed to get a B overall.
I have never taught a student who had the ability to only get a D on their coursework who could then go on to get close to 100% in exams. Typically, there is fairly good correlation between ability in coursework and exams.
If you can turn it on, I'd love to know your secret.
I usually get A's or A*'s in exams and on my other coursework i have gotten a two A's ,gcse by the way, i was only given two days and recieved no help because i had missed a few days