AGH!
That makes me so mad!!!
I would definately be upset if that happened to me!! I think you should talk to him about it!
If that doesn't work, what I would do is go up the chain to the next person (like the dean or whatever).
But that's just me
It definately is just WRONG that you would have been better off if you hadn't worked hard the entire semester and failed your midterm and just studied for the final!